SA-MP Forums Archive
[HELP] Makeadmin command doesn't work - 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: [HELP] Makeadmin command doesn't work (/showthread.php?tid=190464)



[HELP] Makeadmin command doesn't work - .sparkY - 15.11.2010

Hello... Im making a new GM, and I added "AdminLvl" to my Enum Pinfo... I also coppied a makeadmin command from wiki... But... My command does not work When I compile it, it's perfect, but when I go in game and type /makeadmin, nothing happends....

Here's the command I used :


Код:
COMMAND:makeadmin(playerid,cmdtext[])
{
        new cmd[256], idx;
		cmd = strtok(cmdtext, idx);
       new string[128];
       new tmp[256];
       new player[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME];
       new giveplayerid;
       if (IsPlayerAdmin(playerid))
       {
               tmp = strtok(cmdtext, idx);
               if(!strlen(tmp))
               {
                       SendClientMessage(playerid, Crvena, "USAGE: /makeadmin [playerid] [level]");
                       SendClientMessage(playerid, Crvena, "FUNCTION: Player will be an admin.");
                       return 1;
               }
               giveplayerid = ReturnUser(tmp);
               tmp = strtok(cmdtext, idx);
               new level = strval(tmp);
               if(giveplayerid != INVALID_PLAYER_ID)
               {
                       GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                       GetPlayerName(playerid, player, sizeof(player));
                       PlayerInfo[giveplayerid][AdminLvl] = level;
                       printf("Admin %s made %s a level %d admin.", player, giveplayer, level);
                       format(string, sizeof(string), "You are now an administrator level %d thanks to %s.", level,  player);
                       SendClientMessage(giveplayerid, 0x00C2ECFF, string);
                       format(string, sizeof(string), "You have given %s level %d admin.",  giveplayer,PlayerInfo[giveplayerid][AdminLvl]);
                               SendClientMessage(playerid, 0x00C2ECFF, string);
               }
               else if(giveplayerid == INVALID_PLAYER_ID)
               {
                       format(string, sizeof(string), "%i is not an active player.", giveplayerid);
                       SendClientMessage(playerid, 0xE60000FF, string);
               }
       }
       else
       {
           SendClientMessage(playerid, 0xE60000FF, "You are not a lead admin!");
       }
       return 1;
}



Re: [HELP] Makeadmin command doesn't work - Jochemd - 15.11.2010

Man, why do you use the old and slow strtok? Use sscanf, very faster and simpler!

sscanf

Btw, your 'tmp' is oversized to, use '128' cells in stead.


Re: [HELP] Makeadmin command doesn't work - .sparkY - 15.11.2010

I coppied that command... Could you tell me how to put it using sscanf ? :/


Re: [HELP] Makeadmin command doesn't work - mmrk - 15.11.2010

Don't know if this will work..
pawn Код:
COMMAND:makeadmin(playerid,params[])
{
    new
        player[MAX_PLAYER_NAME],
        giveplayer[MAX_PLAYER_NAME],
        giveplayerid,
        level,
        string[128]
    ;
   
    if (!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xE60000FF, "You are not a lead admin!");
    if (sscanf(params, "ui", giveplayerid, level)) return SendClientMessage(playerid, Crvena, "USAGE: /makeadmin [playerid] [level]"), SendClientMessage(playerid, Crvena, "FUNCTION: Player will be an admin.");
    if (!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, COLOR_GREY, "* Player is not connected.");
   
    GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
    GetPlayerName(playerid, player, sizeof(player));
   
    PlayerInfo[giveplayerid][AdminLvl] = level;
    printf("Admin %s made %s a level %d admin.", player, giveplayer, level);
    format(string, sizeof(string), "You are now an administrator level %d thanks to %s.", level, player);
    SendClientMessage(giveplayerid, 0x00C2ECFF, string);
    format(string, sizeof(string), "You have given %s level %d admin.",giveplayer, PlayerInfo[giveplayerid][AdminLvl]);
    SendClientMessage(playerid, 0x00C2ECFF, string);
    return 1;
}



Re: [HELP] Makeadmin command doesn't work - Jochemd - 15.11.2010

Ok, try this. Please use it as an example for your other commands, and maybe it is nice if you update your zcmd include cause you had 'cmdtext' in it.. I thought it was params :S

pawn Код:
COMMAND:makeadmin(playerid,params[])
{
    new player[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME], level, giveplayerid;
    if(IsPlayerAdmin(playerid))
    {
        if(!sscanf(params,"ud",giveplayer,level))
        {
            if(giveplayerid != INVALID_PLAYER_ID)
            {
                GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                GetPlayerName(playerid, player, sizeof(player));
                PlayerInfo[giveplayerid][AdminLvl] = level;
                printf("Admin %s made %s a level %d admin.", player, giveplayer, level);
                format(string, sizeof(string), "You are now an administrator level %d thanks to %s.", level,  player);
                SendClientMessage(giveplayerid, 0x00C2ECFF, string);
                format(string, sizeof(string), "You have given %s level %d admin.",  giveplayer,PlayerInfo[giveplayerid][AdminLvl]);
                SendClientMessage(playerid, 0x00C2ECFF, string);
            }
            else
            {
                format(string, sizeof(string), "%i is not an active player.", giveplayerid);
                SendClientMessage(playerid, 0xE60000FF, string);
                return 1;
            }
        }
        else
        {
            SendClientMessage(playerid, Crvena, "USAGE: /makeadmin [playerid] [level]");
            SendClientMessage(playerid, Crvena, "FUNCTION: Player will be an admin.");
            return 1;
        }
    }
    else SendClientMessage(playerid, 0xE60000FF, "You are not a lead admin!");
    return 1;
}



Re: [HELP] Makeadmin command doesn't work - .sparkY - 15.11.2010

Thanks... Just one more thing... How to define sscanf ? xd
Quote:

error 017: undefined symbol "sscanf"




Re: [HELP] Makeadmin command doesn't work - Kidemo - 15.11.2010

To define something its #define


Re: [HELP] Makeadmin command doesn't work - Jochemd - 15.11.2010

Download the sscanf plugin & include. (****** sscanf SA:MP)


Re: [HELP] Makeadmin command doesn't work - .sparkY - 15.11.2010

Thanks... One more thing, I use the command you gave me, and get an warning "Symbol is never used 'makeadmin'"... Do I need to put something under onplayercommandtext or what ?


Re: [HELP] Makeadmin command doesn't work - mmrk - 15.11.2010

You need zcmd.