[HELP]setlevel admin sa-mp
#1

Hello guys, I created this command to settarsi admin in my gamemode but it gives me the following errors!

PHP код:
    if (strcmp("/settaadmin"cmdtexttrue10) == 0)
{
    new 
id;
    if(
pInfo[playerid][Admin] >= || IsPlayerAdmin(playerid))
    {
        if(
sscanf(params,"ui"idlevel))
        {
            return 
SendClientMessage(playeridLBLUE"Usage: /setlevel (playerid) (level)") &&
            
SendClientMessage(playeridGREEN"Function: Set a person a admin");
        }
        if(
id == INVALID_PLAYER_ID) return SendClientMessage(playeridRED"ERROR: That is a invalid player ID");
        
format(strsizeof(str), "UPDATE `playerinfo` SET `Admin` = %d WHERE `User` = '%s'"levelpName(id));
        
format(strsizeof(str), "|- Administrator %s has made %s (%d) admin level %d -|"pName(playerid), pName(id), idlevel);
        
PlayerInfo[playerid][Admin] = level;
    }
    else 
SendClientMessage(playeridRED"ERROR: You are not a level 5 admin!");
    return 
1;



ERROR:

PHP код:
C:\Users\Fabio Falcone\Desktop\OklaHoma City\gamemodes\gm.pwn(198) : error 017undefined symbol "params"
C:\Users\Fabio Falcone\Desktop\OklaHoma City\gamemodes\gm.pwn(204) : error 017undefined symbol "str"
C:\Users\Fabio Falcone\Desktop\OklaHoma City\gamemodes\gm.pwn(204) : error 017undefined symbol "str"
C:\Users\Fabio Falcone\Desktop\OklaHoma City\gamemodes\gm.pwn(204) : error 029invalid expressionassumed zero
C
:\Users\Fabio Falcone\Desktop\OklaHoma City\gamemodes\gm.pwn(204) : fatal error 107too many error messages on one line 
Reply
#2

add this above new id;

new str[128];
Reply
#3

but error params??
Reply
#4

try using ZCMD
Reply
#5

Above new str[128]; then add new params;
Reply
#6

pawn Код:
if (!strcmp("/settaadmin", cmdtext, true, 11))
{
    new id;
    if (pInfo[playerid][Admin] < 5 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED, "ERROR: You are not a level 5 admin!");
    if (sscanf(cmdtext[12], "ui", id, level))
    {
        SendClientMessage(playerid, LBLUE, "Usage: /setlevel (playerid) (level)") &&
        return SendClientMessage(playerid, GREEN, "Function: Set a person a admin");
    }
    if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, RED, "ERROR: That is a invalid player ID");
    new str[100];
    format(str, sizeof (str), "UPDATE `playerinfo` SET `Admin` = %d WHERE `User` = '%s'", level, pName(id));
    // ??? Execute query
    format(str, sizeof (str), "|- Administrator %s has made %s (%d) admin level %d -|", pName(playerid), pName(id), id, level);
    PlayerInfo[id][Admin] = level; // setting the level of the "id", not "playerid" as you wrote.
    return 1;
}
However I agree with what ChandraLouis suggested.
Reply
#7

this:
pawn Код:
if(sscanf(params,"ui", id, level))
is working for ZCMD,to make it work in strcmp use this:
pawn Код:
if(sscanf(cmdtext[12],"ui", id, level))
because in ZCMD they write the params near the command..
Reply
#8

Thanks All!!
i have a problem!!
https://sampforum.blast.hk/showthread.php?tid=498608
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)