Admin Script.
#1

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!
Reply
#2

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.
Reply
#3

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
Reply
#4

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.
Reply
#5

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
Reply
#6

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?
Reply
#7

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)