SA-MP Forums Archive
Command: /makeadmin help - 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)
+--- Thread: Command: /makeadmin help (/showthread.php?tid=428063)



Command: /makeadmin help - Areax - 04.04.2013

Hey!

I need some help...

How can I make /makeadmin command with sscanf2 and zcmd?

Thanks for your help...


Re: Command: /makeadmin help - Konstantinos - 04.04.2013

Read me.


Re: Command: /makeadmin help - SilverKiller - 04.04.2013

How do you detect if the player is an admin in your script?


Re: Command: /makeadmin help - Areax - 04.04.2013

Quote:
Originally Posted by SilverKiller
Посмотреть сообщение
How do you detect if the player is an admin in your script?
if(gPlayerInfo[playerid][PLAYER_LEVEL] < 5)


Re: Command: /makeadmin help - SilverKiller - 04.04.2013

Using ZCMD - sscanf :

pawn Код:
CMD:makeadmin(playerid, params[])
{
    new id,
        level;
       
    if(gPlayerInfo[playerid][PLAYER_LEVEL] < 5)
        return SendClientMessage(playerid, -1, "You need to be Level 10 to use this command!");
       
    if(sscanf(params, "ui", id, level))
        return SendClientMessage(playerid, -1, "Usage: /makeadmin <playerid> <level>");
       
    if(id == playerid)
        return SendClientMessage(playerid, -1, "ERROR:{00CED1} You cannot set your own Admin Level!");
       
    if(!IsPlayerConnected(id))
        return SendClientMessage(playerid, -1, "ERROR:{00CED1} Player is not connected!");

    if ( level < 0 || level > 5 )
        return SendClientMessage(playerid, -1, "ERROR:{00CED1} Invalid Admin level");
       
    gPlayerInfo[id][PLAYER_LEVEL] = level;
    new pName[MAX_PLAYER_NAME], str[128], pName1[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    GetPlayerName(id, pName1, sizeof(pName1));
    format(str, sizeof(str), "Administrator %s has changed %s's Admin level to %i",pName, pName1, level);
    SendClientMessageToAll(-1, str);
    return 1;
}
Should work


Re: Command: /makeadmin help - Areax - 04.04.2013

Thx, let me try it


Re: Command: /makeadmin help - DaRk_RaiN - 04.04.2013

Well depends on your registration system make the following code suitable to it.
pawn Код:
CMD:makeadmin(playerid, params[])
{
        if(PlayerInfo[ playerid ][ PLAYER_LEVEL] < 5) return SendClientMessage(playerid, -1, "ERROR: You are not high enough level bla bla");//If his level is less than 5 he can't use this command
        //Change the line above to be suiable
        new level, aname[MAX_PLAYER_NAME];//Variables to be used further on
        new targetid;//This variable will be assigned to the dude who's level will be changed
        if(sscanf(params, "ui", targetid, level)) return SendClientMessage(playerid, -1, "ERROR: /makeadmin (playerid/name) (level)");
        if (level > 5 || level < 0) return SendClientMessage(playerid, -1, "ERROR:INVALID level");//This will limit the levels from 1 to 5,(editable)
        if(!IsPlayerConnected( targetid )) return SendClientMessage(playerid, -1, "ERROR:INVALID player");//This will be called incase the player isn't connected
        new string1[130], tname[MAX_PLAYER_NAME], string2[130];//String to send
        PlayerInfo[targetid][ PLAYER_LEVEL ] = level;//This part will set his level
        GetPlayerName(playerid, aname, sizeof(aname));
        GetPlayerName(targetid, tname, sizeof(tname));
        format(string2, sizeof(string1), "Admin %s has set %s's level to %i", aname, tname, level);//This will be sent to all players
        SendClientMessageToAll(Yellow, string2);
    return 1;
}



Re: Command: /makeadmin help - SilverKiller - 04.04.2013

Quote:
Originally Posted by DaRk_RaiN
Посмотреть сообщение
Well depends on your registration system make the following code suitable to it.
pawn Код:
CMD:makeadmin(playerid, params[])
{
        if(PlayerInfo[ playerid ][ PLAYER_LEVEL] < 5) return SendClientMessage(playerid, -1, "ERROR: You are not high enough level bla bla");//If his level is less than 5 he can't use this command
        //Change the line above to be suiable
        new level, aname[MAX_PLAYER_NAME];//Variables to be used further on
        new targetid;//This variable will be assigned to the dude who's level will be changed
        if(sscanf(params, "ui", targetid, level)) return SendClientMessage(playerid, -1, "ERROR: /makeadmin (playerid/name) (level)");
        if (level > 5 || level < 0) return SendClientMessage(playerid, -1, "ERROR:INVALID level");//This will limit the levels from 1 to 5,(editable)
        if(!IsPlayerConnected( targetid )) return SendClientMessage(playerid, -1, "ERROR:INVALID player");//This will be called incase the player isn't connected
        new string1[130], tname[MAX_PLAYER_NAME], string2[130];//String to send
        PlayerInfo[targetid][ PLAYER_LEVEL ] = level;//This part will set his level
        GetPlayerName(playerid, aname, sizeof(aname));
        GetPlayerName(targetid, tname, sizeof(tname));
        format(string2, sizeof(string1), "Admin %s has set %s's level to %i", aname, tname, level);//This will be sent to all players
        SendClientMessageToAll(Yellow, string2);
    return 1;
}
I can only see that you changed his Admin Variable and changed some Variable names.....


Re: Command: /makeadmin help - DaRk_RaiN - 04.04.2013

Quote:
Originally Posted by SilverKiller
Посмотреть сообщение
I can only see that you changed his Admin Variable and changed some Variable names.....
Yes exactly,if you just read the post properly i noted that he should make it suitable to his system, also the command was an example not a 'ready to use' i used it to explain because this is scripting help forums not scripting requests.


Re: Command: /makeadmin help - SilverKiller - 04.04.2013

Quote:
Originally Posted by DaRk_RaiN
Посмотреть сообщение
Yes exactly,if you just read the post properly i noted that he should make it suitable to his system, also the command was an example not a 'ready to use' i used it to explain because this is scripting help forums not scripting requests.
Oh, sorry, i misunderstood