Author Topic: Yet another code problem  (Read 532 times)

This script is suppose to kill, kick, or ban a player if they touch the host.

Code: [Select]
function GameConnection::isSuperAdmin(%client)
{
    return (%client.bl_id == getNumKeyID() || %client.getRawIP() $= "local");
}

function servercmdCTM(%client, %type, %len)
   {
     if(%client.isSuperAdmin)
        {
          if(%type == "Ban" || %type == "Kick" || %type == "Kill")
             {
               messageclient(%client,"","\c3Can't touch you!");
               $CTM::On = 1;
               $CTM::Mode = %type;
               if(!%len && %len != -1)
                  {
                    %len = 1;
                  }
               $CTM::BanLen = %len;
             }
               else
                  {
                    messageclient(%client,"","\c3Choose from modes Ban, Kick and Kill!");
                  }
        }
          else
             {
               messageclient(%client,"","\c3You must be host to use this command!");
             }
   }

function servercmdTM(%client)
   {
     if(%client.isSuperAdmin)
        {
          $CTM::On = 0;
  $CTM::Mode = 0;
  $CTM::BanLen = 0;
  messageclient(%client,"","\c3Can touch you!");
}
      else
        {
          messageclient(%client,"", "\c3You must be host to use this command!");
}
}

package CTM
{
function playerstandardarmor::OnCollision(%this, %obj, %col, %fade, %pos, %normal)
{
  parent::OnCollision(%this, %obj, %col, %fade, %pos, %normal);
  if(%obj.client.isHost $= 1 && $CTM::On $= 1 && %col.getclassname() $="Player")
     {
       %target = %col.client;
       if($CTM::Mode $= "Ban")
  {
            servercmdBan(%obj.client, %target, %target.getBLID(), $CTM::BanLen, "Can't touch me!");
  }
       if($CTM::Mode $= "Kick")
  {
    servercmdKick(%obj.client, %target);
  }
       if($CTM::Mode $= "Kill")
  {
    %col.kill();
    messageclient(%client, "", "\c3Don't touch him!");
  }
     }
}
};
activatepackage(CTM);

It doesn't work. Idk why but can someone tell me whats wrong?

Copy Cat :P

But here's a few things:

Code: [Select]
function GameConnection::isSuperAdmin(%client)
{
    return (%client.bl_id == getNumKeyID() || %client.getRawIP() $= "local");
} //I don't see why you need this, just use the %client.isSuperAdmin variable

function servercmdCTM(%client, %type, %len)
   {
     if(%client.isSuperAdmin)
        {
          if(%type == "Ban" || %type == "Kick" || %type == "Kill") //Use $= when checking strings, use == when checking numbers
             {
               messageclient(%client,"","\c3Can't touch you!"); //use two apostrophes for the second argument
               $CTM::On = 1;
               $CTM::Mode = %type;
               if(!%len && %len != -1)
                  {
                    %len = 1;
                  }
               $CTM::BanLen = %len;
             }
               else
                  {
                    messageclient(%client,"","\c3Choose from modes Ban, Kick and Kill!"); //again, use two apostrophes
                  }
        }
          else
             {
               messageclient(%client,"","\c3You must be host to use this command!"); //again, use two apostrophes
             }
   }

function servercmdTM(%client)
   {
     if(%client.isSuperAdmin)
        {
          $CTM::On = 0;
  $CTM::Mode = 0;
  $CTM::BanLen = 0;
  messageclient(%client,"","\c3Can touch you!"); //again, use two apostrophes
}
      else
        {
          messageclient(%client,"", "\c3You must be host to use this command!"); //again, use two apostrophes
}
}

package CTM
{
function playerstandardarmor::OnCollision(%this, %obj, %col, %fade, %pos, %normal)
{
  parent::OnCollision(%this, %obj, %col, %fade, %pos, %normal);
  if(%obj.client.isHost $= 1 && $CTM::On $= 1 && %col.getclassname() $="Player") //I don't think %client.isHost has already been defined and use == when checking numbers
     {
       %target = %col.client;
       if($CTM::Mode $= "Ban")
  {
            servercmdBan(%obj.client, %target, %target.getBLID(), $CTM::BanLen, "Can't touch me!");
  }
       if($CTM::Mode $= "Kick")
  {
    servercmdKick(%obj.client, %target);
  }
       if($CTM::Mode $= "Kill")
  {
    %col.kill();
    messageclient(%client, "", "\c3Don't touch him!"); //again, use two apostrophes
  }
     }
}
};
activatepackage(CTM);

Copy Cat :P

But here's a few things:

Thanks that helps alot.