SA-MP Forums Archive
Admin Script. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Admin Script. (/showthread.php?tid=260158)



Admin Script. - iGetty - 07.06.2011

Okay, so I wanna make an admin command, for RCON only, it will be a /makeadmin command.

pawn Код:
COMMAND:makeadmin(playerid, params[])
{
    SendClientMessageToAll(WHITE, "Welcome an administrator to the team!");
           //this bit here, how would I make it to set someone else to an admin?
           //I have this for the level thing thing....
           dini_IntSet(file, "Level", gPlayerInfo[playerid][PLAYER_LEVEL]);
           //that is the admin level, how could I send it?
    return 1;
}
Thank you for all of your help!


Re: Admin Script. - Steven82 - 07.06.2011

pawn Код:
COMMAND:makeadmin(playerid, params[])
{
 new targetid;
 if(sscanf(params, "u", targetid))
  return SendClientMessage(playerid, COLOR_GREY, "USAGE: /makeadmin [playerid/name]");
 if(!IsPlayerConnected(targetid)))
 return SendClientMessage(playerid, COLOR_LIGHTRED, "Invalid name/id!");
 //
 SendClientMessageToAll(WHITE, "Welcome an administrator to the team!");
 gPlayerInfo[targetid][PLAYER_LEVEL] = 1; //(this being the admin level number)
 SendClientMessage(targetid, COLOR_WHITE, "Your now a server administrator");
 return 1;
}
And just create a save function so when the player disconnects all the dini_IntSet's go under that save function and you'd just get the info from the gPlayerInfo variables.


Re: Admin Script. - randomkid88 - 07.06.2011

If you want it to be usable for RCON admins only, use IsPlayerAdmin(playerid). For example:
pawn Код:
COMMAND:makeadmin(playerid, params[])
{
     if(IsPlayerAdmin(playerid)) //Checks to see if the user is logged in to RCON
     {
        //use code from above or your own



Re: Admin Script. - iGetty - 07.06.2011

Quote:
Originally Posted by Steven82
Посмотреть сообщение
pawn Код:
COMMAND:makeadmin(playerid, params[])
{
 new targetid;
 if(sscanf(params, "u", targetid))
  return SendClientMessage(playerid, COLOR_GREY, "USAGE: /makeadmin [playerid/name]");
 if(!IsPlayerConnected(targetid)))
 return SendClientMessage(playerid, COLOR_LIGHTRED, "Invalid name/id!");
 //
 SendClientMessageToAll(WHITE, "Welcome an administrator to the team!");
 gPlayerInfo[targetid][PLAYER_LEVEL] = 1; //(this being the admin level number)
 SendClientMessage(targetid, COLOR_WHITE, "Your now a server administrator");
 return 1;
}


And just create a save function so when the player disconnects all the dini_IntSet's go under that save function and you'd just get the info from the gPlayerInfo variables.
pawn Код:
COMMAND:makeadmin(playerid, params[])
{
 new targetid;
 if(sscanf(params, "u", targetid))
  return SendClientMessage(playerid, COLOR_GREY, "USAGE: /makeadmin [playerid/name]");
 if(!IsPlayerConnected(targetid)))
 return SendClientMessage(playerid, COLOR_RED, "Invalid name/id!");
 //
 SendClientMessageToAll(COLOR_WHITE, "Welcome an administrator to the team!");
 gPlayerInfo[targetid][PLAYER_LEVEL] = 1; //(this being the admin level number)
 SendClientMessage(targetid, COLOR_WHITE, "Your now a server administrator");
 return 1;
}
Код:
C:\Users\Dad\Desktop\gamemodes\new.pwn(718) : error 029: invalid expression, assumed zero
C:\Users\Dad\Desktop\gamemodes\new.pwn(718 -- 719) : warning 215: expression has no effect
C:\Users\Dad\Desktop\gamemodes\new.pwn(719) : error 001: expected token: ";", but found "return"
C:\Users\Dad\Desktop\gamemodes\new.pwn(721) : warning 225: unreachable code
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.



Re: Admin Script. - Steven82 - 07.06.2011

I think i added an extra ")" on the end of IsPlayerConnected try that. And yes add the if(IsPlayerAdmin(playerid)) thing i forgot that :S


EDIT: Thanks for correcting me randomkid


Re: Admin Script. - iGetty - 07.06.2011

Alright thanks for the help y'all, appreciate it!, also, I will be testing it later, and Steven82 if you don't mind, could I pm you to let you know the result?


Re: Admin Script. - Steven82 - 07.06.2011

Quote:
Originally Posted by getty154
Посмотреть сообщение
Alright thanks for the help y'all, appreciate it!, also, I will be testing it later, and Steven82 if you don't mind, could I pm you to let you know the result?
Sure feel free to PM me.