Help dcmd /setadmin ID LEVEL
#1

Hello All,
I need to create a command /setadmin ID LEVEL
What I did:
pawn Код:
dcmd_setadmin(playerid,params[])
{
if(PlayerInfo[playerid][admin]>=8 || IsPlayerAdmin(playerid))
{
new id,livello;
id = strval(params);
if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "Uso /setadmin [ID] [LIVELLO]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "Giocatore non connesso.");
livello = strval(params);
format(astring,sizeof(astring),"[ADMIN]: L'Admin %s ha settato %s livello %d.",Nome(playerid),Nome(id),livello);
SendClientMessageToAll(COLORE_MESSAGGI,astring);

PlayerInfo[id][admin]=livello;
} else { SendClientMessage(playerid, COLOR_RED, "Devi essere minimo admin livello 8 per usare questo comando!"); }
return 1;
}
The problem is that the id of the player and the level are the same ie I can not share with the ID LEVEL
Sorry for my English, I used a translator xD
Reply
#2

alone did u write these??how did u do it
Reply
#3

Using sscanf (https://sampwiki.blast.hk/wiki/Sscanf_code):

pawn Код:
dcmd_setadmin(playerid,params[])
{
    new string[128], id, level;
    if(sscanf(params, "ud", id, level))
    {
      SendClientMessage(playerid, COLOR_RED, "Uso /setadmin [ID] [LIVELLO]");
    }
    else
    {
        if(PlayerInfo[playerid][admin]>= 8 || IsPlayerAdmin(playerid))
        {
          if(IsPlayerConnected(id))
          {
            Player[playerid][admin] = level;
                format(astring,sizeof(astring),"[ADMIN]: L'Admin %s ha settato %s livello %d.",Nome(playerid),Nome(id),livello);
                SendClientMessageToAll(COLORE_MESSAGGI,astring);
          }
          else
          {
            SendClientMessage(playerid, COLOR_RED, "Giocatore non connesso.");
          }
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)