Blockland Forums > Modification Help
Yet another code problem
Pages: (1/1)
Bot:
This script is suppose to kill, kick, or ban a player if they touch the host.
--- Code: ---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);
--- End code ---
It doesn't work. Idk why but can someone tell me whats wrong?
lilboarder32:
Copy Cat :P
But here's a few things:
--- Quote from: Bot on June 23, 2010, 08:39:00 PM ---
--- Code: ---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);
--- End code ---
--- End quote ---
Bot:
--- Quote from: lilboarder32 on June 24, 2010, 04:03:41 AM ---Copy Cat :P
But here's a few things:
--- End quote ---
Thanks that helps alot.
Pages: (1/1)