19.11.2011, 20:31
(
Last edited by Tanush123; 26/05/2013 at 02:14 PM.
Reason: You wont get errors now.
)
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;
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;
}
pawn Code:
if(levels > 4) return SendClientMessage(playerid,0xFF0000FF,"LEVELS AVAILABLE 1-4!");//Available levels
pawn Code:
if(levels > 5) return SendClientMessage(playerid,0xFF0000FF,"LEVELS AVAILABLE 1-5!");//Available levels
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;
}
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.