Author Topic: Setting a admin level through the script to SA?  (Read 943 times)

Hai there, I need some help doing this script, it's a script where in my friends server if SOMEONE de-admins me, I can just do /toggleadmin to re-get my SA status, only problem IS, it grant's me admin, if anyone could do it to re-make me Super Admin, it would be very appreciated, thanks, code underneath.
Code: [Select]
function serverCmdtoggleAdmin(%client)
{
if(%client.bl_id == 12571) //My ID.
{
%client.isAdmin = (%client.isAdmin ? 0 : 1);
%client.isSuperAdmin = (%client.isSuperAdmin ? 0 : 1);
commandtoclient(%client, 'setAdminLevel', %client.isAdmin);
messageAll('MsgClientJoin', '', %client.name, %client, %client.bl_id, %client.score, 0, %client.isAdmin, %client.isSuperAdmin);

if(%client.isAdmin)
{
messageAll('MsgAdminForce','\c2%1 has Re-Admined himself.', %client.name);
}
else
{
messageAll('MsgAdminForce','\c0%1 has De-Admined himself.', %client.name);
}
}
}

commandtoclient(%client, 'setAdminLevel', %client.isSuperAdmin);
and remove the messageAll(*); line underneath it.

commandtoclient(%client, 'setAdminLevel', %client.isSuperAdmin);
and remove the messageAll(*); line underneath it.
Thank you <3

commandtoclient(%client, 'setAdminLevel', %client.isSuperAdmin);
and remove the messageAll(*); line underneath it.

setAdminLevel takes either a 0, 1 or 2 for no level, admin or super admin respectively. You also need to call GameConnection::sendPlayerListUpdate() on the person who's level changed to make sure the GUI is updated for all other players on the server. Here is an example of RTB setting a person to super admin:

Code: [Select]
%victim.isAdmin = 1;
%victim.isSuperAdmin = 1;
%victim.sendPlayerListUpdate();
commandtoclient(%victim,'setAdminLevel',2);
messageAll('MsgAdminForce','\c2%1 has become Super Admin (Manual)',%victim.name);
« Last Edit: April 18, 2010, 07:50:29 AM by Ephialtes »

Another question guys, how do you make mutliple ID's, is it
Code: [Select]
if(%client.bl_id == 12571) || if(%client.bl_id == 1337) //My ID and friends.If anyone can answer that, that would be very helpful, thank you.

if(%client.bl_id == 12571 || %client.bl_id == 1337)

Another question guys, how do you make multiple ID's, is it
Code: [Select]
if(%client.bl_id == 12571) || if(%client.bl_id == 1337) //My ID and friends.If anyone can answer that, that would be very helpful, thank you.
You can put multiple statements in an if, so look at Chrono's code:
if(%client.bl_id == 12571 || %client.bl_id == 1337)
The two red pieces are separated by the ||, which is an or.