Help needed
#1

What am i doing wrong here? (im a begginer please help me understand this)
pawn Код:
dcmd_setadmin(playerid,params[])
{
    if(AdminLvL[playerid] >= 5 || IsPlayerAdmin(playerid))
    {
      new giveplayerid, givelvl;
        if(sscanf(params,"dz",giveplayerid,givelvl))
      {
        SendClientMessage(playerid,COLOR_RED,"Usage: /setadmin [id] [lvl]");
            return 1;
        }
        if(!IsPlayerConnected(giveplayerid))
        {
          new Stringy[128];
            format(Stringy, sizeof(Stringy), "ID (%d) Is not an active player", giveplayerid);
            SendClientMessage(playerid, COLOR_RED, Stringy);
            return 1;
      }
      new Stringy[128];
      format(Stringy, sizeof(Stringy), "You gave ID(%d) LVL %d Admin", giveplayerid,givelvl);
      SendClientMessage(playerid, COLOR_RED, Stringy);
       format(Stringy, sizeof(Stringy), "You are now lvl %d Admin",givelvl);
      SendClientMessage(giveplayerid, COLOR_RED, Stringy);
      AdminLvL[giveplayerid] = givelvl;
       return 1;
       
     
    }
    return 0;
}
I am using DUDB.
Reply
#2

What is the problem you are having?

your sscanf statement formatting was incorrect got the givelvl. it should be "ii" not "iz", though i think this may not be your problem.
https://sampwiki.blast.hk/wiki/Fast_Commands#Data_types

pawn Код:
dcmd_setadmin(playerid,params[])
{
    if(AdminLvL[playerid] >= 5 || IsPlayerAdmin(playerid))
    {
        new giveplayerid, givelvl;
        if(!sscanf(params,"ii", giveplayerid, givelvl))
        {
            if(!IsPlayerConnected(giveplayerid))
            {
                new Stringy[128];
                format(Stringy, sizeof(Stringy), "ID (%d) Is not an active player", giveplayerid);
                SendClientMessage(playerid, COLOR_RED, Stringy);
                return 1;
            }
            new Stringy[128];
            format(Stringy, sizeof(Stringy), "You gave ID(%d) LVL %d Admin", giveplayerid, givelvl);
            SendClientMessage(playerid, COLOR_RED, Stringy);
            format(Stringy, sizeof(Stringy), "You are now lvl %d Admin", givelvl);
            SendClientMessage(giveplayerid, COLOR_RED, Stringy);
            AdminLvL[giveplayerid] = givelvl;
            return 1;
        }
        else SendClientMessage(playerid,COLOR_RED,"Usage: /setadmin [id] [lvl]");
    }
    else SendClientMessage(playerid,COLOR_RED,"You need to be admin level 5+ or RCON Admin to do that!");
}
Reply
#3

thanks man this worked.... now i understand
Reply
#4

Quote:
Originally Posted by GhOstY93
thanks man this worked.... now i understand
Dont forget to save the player's level to the player's file if you are using a file based admin system. Otherwise when they re-login their admin level would not be found
Reply
#5

Quote:
Originally Posted by [B2K
Hustler ]
Quote:
Originally Posted by GhOstY93
thanks man this worked.... now i understand
Dont forget to save the player's level to the player's file if you are using a file based admin system. Otherwise when they re-login their admin level would not be found
you mean something like this under onplayerdisconnect:

Код:
dUserSetINT(ReturnPlayerName(playerid)).("Adminlvl",AdminLvL[playerid]);
I made this before the command lol ;P... and the command was correct either except that i didn't read about data types for sscanf and i didn't know whats that "dz" for
Reply
#6

There was nothing wrong with you're code, well indented as well, only the formatting i guess. Anyways, its best if you change the data in the players file immediately after as well.

pawn Код:
AdminLvL[giveplayerid] = givelvl; // after this line put the next line in your command.
dUserSetINT(ReturnPlayerName(giveplayerid)).("Adminlvl",AdminLvL[giveplayerid]);
Reply
#7

Quote:
Originally Posted by [B2K
Hustler ]
There was nothing wrong with you're code, well indented as well, only the formatting i guess. Anyways, its best if you change the data in the players file immediately after as well.

pawn Код:
AdminLvL[giveplayerid] = givelvl; // after this line put the next line in your command.
dUserSetINT(ReturnPlayerName(giveplayerid)).("Adminlvl",AdminLvL[giveplayerid]);
i think i don't have to do it because the commands read from AdminLvL[playerid] not from the file... the file only gets loaded onplayerconnect... tell me if i've mistaken, but everything seems alright without adding that..
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)