Author Topic: Banhammer  (Read 716 times)

« Last Edit: April 26, 2009, 02:04:03 AM by Amade »

Code: (Torque) [Select]
function BanHammerImage::OnMount(%this, %obj)
{
   Parent::OnMount(%this, %obj);
   %client = %obj.client;
   if(%client.isAdmin)
   {
      if($Pref::BanHammer::SuperAdminOnly && (!%client.isSuperAdmin))
      {
         %client.player.unMountImage("BanHammerImage");//We end up here if the player isn't a super admin
      }
      else
      {
         centerPrint(%this, "This tool is Super Admin only!", 3, 2);
      }
   }
}

Read the comment

Oops... The pref was false. That probably had something to do with it. And it will only display the print message if they are a non-admin. I'll look at that some more.

What about the second function?

A non-super admin would pass true for the first function
Oh, I didn't see the %client.admin there

Code: (Torque) [Select]
function BanHammerImage::OnMount(%this, %obj)
{
    %client = %obj.client;
    if(%client.isAdmin)
    {
if($Pref::BanHammer::SuperAdminOnly && (!%client.isSuperAdmin))
    %client.player.unMountImage("BanHammerImage");

else
    centerPrint(%this, "This tool is Super Admin only!", 3, 2);

return;
    }

   Parent::OnMount(%this, %obj);
}

It would try to mount before it reaches the admin check.
And you would need a return too.


I also suggest using multiple's of four for formatting(use 4 spaces and tabs)

Well, here's what I have right now, I'm pretty sure it works.
Code: [Select]
function BanHammerImage::OnMount(%this, %obj)
{
   %client = %obj.client;
   Parent::OnMount(%this, %obj);
   {
      if($Pref::BanHammer::SuperAdminOnly && (!%client.isSuperAdmin)) //pref is true and client is not super admin?
      {
         %client.player.unMountImage("BanHammerImage"); //this is true, unmount, display message:
         centerPrint('', 'This tool is for Super Admins only.', '');
      }
      else //if that didn't stop it...
      {
         if(!%client.isAdmin) //check for not normal admin
         {
            %client.player.unMountImage("BanHammerImage"); //if not, unmount, display message:
            centerPrint('', 'This tool is for Admins only.', '');
      }
   }
}
Where would I need a return;?

I not only explained it but already posted the correct code.
I'll fix for new code

Code: (Torque) [Select]
function BanHammerImage::OnMount(%this, %obj)
{
    %client = %obj.client;

    if($Pref::BanHammer::SuperAdminOnly && !%client.isSuperAdmin) //pref is true and client is not super admin?
    {
  %client.player.unMountImage("BanHammerImage"); //this is true, unmount, display message:
centerPrint('', 'This tool is for super admins only.', '');
    }

    else if(!%client.isAdmin) //if it's not an admin
    {
%client.player.unMountImage("BanHammerImage"); //if not, unmount, display message:
centerPrint('', 'This tool is for admins only.', '');
    }

    else
Parent::OnMount(%this, %obj);
}

All right.
Can you see what the problem is in the second part of the script?

The first arg on servercmdban needs to be %obj.client, the person whos using the weapon.

All right, got it all figured out.
« Last Edit: April 26, 2009, 02:03:50 AM by Amade »