[Tutorial] Making a easy /setadmin command with some admin commands (zcmd & sscanf)
#1

Making a easy /setadmin command with a admin commands (zcmd & sscanf)
Hello everyone, in this tutorial i would tell you how to make a simple setadmin command for people that thinks it is hard, you must need zcmd and sscanf to make this work.

On the top under your colors you defined add

pawn Code:
enum pData
{
    AdminLevel
};
new PlayerData[MAX_PLAYERS][pData];
new levels,Nam[MAX_PLAYER_NAME],pname[MAX_PLAYER_NAME],str[128],ID;
With that you have defined AdminLevel so you wouldn't get errors like "AdminLevel not defined."

Now you add this script below
pawn Code:
CMD:setadmin(playerid, params[])
{
    if(!IsPlayerAdmin(playerid))return 0; //This command only works for rcon
    if(sscanf(params,"ui",ID,levels)) return SendClientMessage(playerid,0xFF9900AA, "USAGE: /setadmin [ID] [Level 1-4]");//it will show this if you dont use the format properly
    if(levels > 4) return SendClientMessage(playerid,0xFF0000FF,"LEVELS AVAILABLE 1-4!");//Available levels
    if(!IsPlayerConnected(ID))return SendClientMessage(playerid,red,"That user is not connected.");//Detect if the id/partofname is connected
    if(PlayerData[ID][AdminLevel] == levels) return SendClientMessage(playerid,0xFF0000FF, "ERROR: That person is already this admin level!");//Detect if the guy is already the level you setted
    GetPlayerName(playerid,Nam, MAX_PLAYER_NAME);//define the playerid name
    GetPlayerName(ID,pname,MAX_PLAYER_NAME);//define the other person name
    if(levels == 0)
    {
        format(str, sizeof(str),"%s has your Admin level to %d on the server. *cry *cry",Nam,levels);
        SendClientMessage(ID,0xFF9900AA,str);
        format(str, sizeof(str),"You had set %s Admin level to %d!",pname,levels);
        SendClientMessage(playerid,0xFF9900AA,str);
        PlayerData[ID][AdminLevel] = levels;//this sets the player level
        return 1;
    }
    format(str, sizeof(str),"%s has your Admin level to %d on the server.",Nam,levels);
    SendClientMessage(ID,0xFF9900AA,str);
    format(str, sizeof(str),"You had set %s Admin level to %d!",pname,levels);
    SendClientMessage(playerid,0xFF9900AA,str);
    PlayerData[ID][AdminLevel] = levels;
    return 1;
}
Now you guys would be wondering how to change the max admin level so this is what you do, search for
pawn Code:
if(levels > 4) return SendClientMessage(playerid,0xFF0000FF,"LEVELS AVAILABLE 1-4!");//Available levels
Then you change the if(levels > 4) to any number you want, for example if you want 5 do
pawn Code:
if(levels > 5) return SendClientMessage(playerid,0xFF0000FF,"LEVELS AVAILABLE 1-5!");//Available levels
Now i will show you how to make a command like /akill (admin killed)

pawn Code:
CMD:akill(playerid,params[])
{
    if(PlayerData[playerid][AdminLevel] < 1) return 0;//Edit the number to what admin level + you want to use, i put 1 so only level 2 and higher could use it
    if(sscanf(params,"u",ID)) return SendClientMessage(playerid,grey,"USAGE: /akill [playerid / Partofname]");//if player doesnt use the /akill format properly
    if(!IsPlayerConnected(ID)) return SendClientMessage(playerid,red,"ERROR: That user is not connected!");//checks if player is not connected
    GetPlayerName(playerid,Nam,sizeof(Nam));//define playerid name
    GetPlayerName(ID,pname,sizeof(pname));//define other person name
    format(str,sizeof(str),"Administrator %s has admin killed you",Nam);
    SendClientMessage(ID,orange,str);
    format(str,sizeof(str),"You have admin killed %s",pname);
    SendClientMessage(playerid,orange,str);
    SetPlayerHealth(ID,0);
    return 1;
}
Includes Download
Sscanf.inc
Zcmd.inc

Plugins Download
sscanf.dll (Windows ONLY!)
sscanf.so (Linux ONLY!)

You could also get all those in 1 winzip/winrar file with the link below
Winzip/Winrar Download


Now if you guys have any question please post below, if this helped you please subscribe me and thank you.
Reply


Messages In This Thread
Making an easy /setadmin command with some admin commands (zcmd & sscanf) - by Tanush123 - 19.11.2011, 20:31
Re: Making a easy /setadmin command with some admin commands (zcmd & sscanf) - by Astralis - 19.11.2011, 20:35
Re: Making a easy /setadmin command with some admin commands (zcmd & sscanf) - by Tanush123 - 19.11.2011, 20:36
Re: Making a easy /setadmin command with some admin commands (zcmd & sscanf) - by Infinity - 19.11.2011, 20:43
Re: Making a easy /setadmin command with some admin commands (zcmd & sscanf) - by Hiddos - 19.11.2011, 20:49
Re: Making a easy /setadmin command with some admin commands (zcmd & sscanf) - by Tanush123 - 19.11.2011, 20:53
Re: Making a easy /setadmin command with some admin commands (zcmd & sscanf) - by nogh445 - 20.11.2011, 18:46
Re: Making a easy /setadmin command with some admin commands (zcmd & sscanf) - by Tanush123 - 20.11.2011, 19:24
Re: Making a easy /setadmin command with some admin commands (zcmd & sscanf) - by nogh445 - 20.11.2011, 21:17
Re: Making a easy /setadmin command with some admin commands (zcmd & sscanf) - by =WoR=G4M3Ov3r - 20.11.2011, 23:33
Re: Making a easy /setadmin command with some admin commands (zcmd & sscanf) - by Tanush123 - 20.11.2011, 23:34
Re: Making a easy /setadmin command with some admin commands (zcmd & sscanf) - by =WoR=G4M3Ov3r - 20.11.2011, 23:37
Re: Making a easy /setadmin command with some admin commands (zcmd & sscanf) - by Tanush123 - 20.11.2011, 23:37
Re: Making a easy /setadmin command with some admin commands (zcmd & sscanf) - by -Rebel Son- - 21.11.2011, 04:11
Re: Making a easy /setadmin command with some admin commands (zcmd & sscanf) - by Tanush123 - 22.11.2011, 01:00
Re: Making a easy /setadmin command with some admin commands (zcmd & sscanf) - by CSSI - 25.11.2011, 09:19
Re: Making a easy /setadmin command with some admin commands (zcmd & sscanf) - by Tanush123 - 25.11.2011, 12:15
Re: Making a easy /setadmin command with some admin commands (zcmd & sscanf) - by CSSI - 25.11.2011, 17:01
Re: Making a easy /setadmin command with some admin commands (zcmd & sscanf) - by krystiang1 - 25.11.2011, 20:46
Re: Making a easy /setadmin command with some admin commands (zcmd & sscanf) - by Tanush123 - 25.11.2011, 21:29
Re: Making a easy /setadmin command with some admin commands (zcmd & sscanf) - by Wickeed - 05.01.2012, 22:51
Re: Making a easy /setadmin command with some admin commands (zcmd & sscanf) - by Tanush123 - 06.01.2012, 00:29
Re: Making a easy /setadmin command with some admin commands (zcmd & sscanf) - by James Coral - 06.01.2012, 06:46
Re: Making a easy /setadmin command with some admin commands (zcmd & sscanf) - by Wickeed - 06.01.2012, 14:56
Re: Making a easy /setadmin command with some admin commands (zcmd & sscanf) - by Tanush123 - 06.01.2012, 17:03
Re: Making a easy /setadmin command with some admin commands (zcmd & sscanf) - by Shooter3 - 17.01.2012, 01:43
Re: Making a easy /setadmin command with some admin commands (zcmd & sscanf) - by Wickeed - 05.02.2012, 11:46
Re: Making a easy /setadmin command with some admin commands (zcmd & sscanf) - by Tanush123 - 05.02.2012, 14:03
Re: Making a easy /setadmin command with some admin commands (zcmd & sscanf) - by Wickeed - 05.02.2012, 16:05
Re: Making a easy /setadmin command with some admin commands (zcmd & sscanf) - by Djean - 26.06.2013, 05:51
Re: Making a easy /setadmin command with some admin commands (zcmd & sscanf) - by K3 - 28.06.2013, 07:12
Re: Making a easy /setadmin command with some admin commands (zcmd & sscanf) - by qazwsx - 30.07.2013, 05:54

Forum Jump:


Users browsing this thread: 3 Guest(s)