Blockland Forums > Modification Help
admin/unadmin through scripting?
Mr. Wallet:
is there same way to grant/remove admin status in script?
Ideally I could grant admin to a trustworthy person when I'm going afk and revoke it when I get back.
-=>RR<=-MasterCE:
--- Code: ---function serverCmdAdminToggle(%client,%name) {
if(getRawIp(%client) $= "Local") {
if(findclientbyname(%name)) {
if(findclientbyname(%name).isAdmin)
findclientbyname(%name).isAdmin = 1;
else
findclientbyname(%name).isAdmin = 0;
}
}
}
--- End code ---
too lazy to add findclientbyname command I have. Also, the name would have to be 1 word if not done in console and not having a / mod like I did.
MrPickle:
Could you do %client.isAdmin to make and !%client.isAdmin to take away or cant you use ! that way?
Aloshi:
No. Doing %client.isadmin = 1; etc. does NOT work. It just messes up the GUIs etc. To admin it's easiest to do ServerCmdSAD(%client,$Pref::Server::AdminPassword);. De-admining I dunno about. Yes, you CAN do %client.isadmin = 1; but all the GUIs will be wrong-y...
Space Guy:
--- Code: ---function getPlayer(%mode,%player,%id) {
%cl = -1;
for( %i = 0; %i < ClientGroup.getCount(); %i++) {
%cl = ClientGroup.getObject(%i);
if ((%mode = 0 && %cl.name = %id) || (%mode = 1 && %cl.bl_id = %id))
%pobject = %cl;
}
if(%player)
return %pobject.player;
else
return %pobject;
return 0;
}
function servercmdAdminToggle(%client,%id)
{
%player = getPlayer(0,0,%id);
if(getRawIp(%client) $= "Local" && %player)
{
%player.isAdmin = 1 - %player.isAdmin;
messageall('',"\c2" @ %player.name @ " is now " @ (%player.isAdmin ? "" : "not ") @ an Admin. (Server Host Toggle)");
if(%player.isAdmin){commandtoclient(getPlayer(0,0,%id),'adminsuccess');}
}
}
--- End code ---
To use, type /adminToggle [id], so for me it'd be /admintoggle 130 - my BL_ID. The getPlayer function can be used for other things, too:
getPlayer(0,0,130) - would get my client object (Things like isAdmin, minigame option, etc) as my ID is 130.
getPlayer(1,1,"Space Guy") - would get my player object (Things like health, tools, etc) as my name is "Space Guy".