Don't say thank you before you test it
because if you did test it, you would've found it doesn't work AT ALL.
First off, the first argument in every server command is the client that sent the command, you can't just change the name of the variable and hope that it magically knows that you want it to be a name.
second, even if that first error didn't happen, you have it set to message the client whether or not the players tools were cleared! You can't just assume that people always put in valid input.
Here is a fixed version, with error messages and that super-admin-only addition:
function serverCmdClearTools(%client, %name)
{
//Make sure the user is super admin
if(!%client.isSuperAdmin)
{
messageClient(%client, '', "\c6You must be super admin to clear other player's tools!");
return false;
}
//Find the target by their name
%target = findclientbyname(%name);
%player = %target.player;
//Make sure the target is on the server, and has spawned.
//If not, give an error message to the sender.
if(isObject(%target))
{
if(isObject(%player))
%player.clearTools();
else
{
messageClient(%client, '', "\c6That person has not spawned yet!");
return false;
}
}
else
{
messageClient(%client, '', "\c6There is nobody by that name on the server!");
return false;
}
messageClient(%client,'',"Your tools were cleared."); //Message the victim
return true;
}
Thank you, Ipquarx. I'll try to make something similar on my own now.
Thanks, this is resolved!