[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
#2

woah. Nice dude. Goodly explained. And useful. 5/5
Reply
#3

Thank you
Reply
#4

Quote:
Originally Posted by Neonman
View Post
woah. Nice dude. Goodly explained. And useful. 5/5
Tbh, No. If I would be new to scripting, it would be hard/almost impossible for me to figure out what some of the code is doing.
Reply
#5

Quote:
Originally Posted by Neonman
View Post
woah. Nice dude. Goodly explained. And useful. 5/5
The tutorial is just as goodly and fully as your level of English.

Quote:
Originally Posted by Infinity
View Post
Tbh, No. If I would be new to scripting, it would be hard/almost impossible for me to figure out what some of the code is doing.
You even understood anything at all 0.o?

This is just a copy-paste tutorial, which you copy-pasted from some other guy's work.
Reply
#6

Quote:
Originally Posted by Infinity
View Post
Tbh, No. If I would be new to scripting, it would be hard/almost impossible for me to figure out what some of the code is doing.
Usually when new scripter joins they would just use ******* first then know a bit and i added // for some of the lines so they could read and know what does it do.
Reply
#7

did everything and this is what I got:

Code:
C:\Users\user\Desktop\SAMP SERVER STUFF\samp server\pawno\FADM.pwn(586) : error 017: undefined symbol "ID"
C:\Users\user\Desktop\SAMP SERVER STUFF\samp server\pawno\FADM.pwn(587) : error 017: undefined symbol "ID"
C:\Users\user\Desktop\SAMP SERVER STUFF\samp server\pawno\FADM.pwn(588) : error 017: undefined symbol "Nam"
C:\Users\user\Desktop\SAMP SERVER STUFF\samp server\pawno\FADM.pwn(588) : error 017: undefined symbol "Nam"
C:\Users\user\Desktop\SAMP SERVER STUFF\samp server\pawno\FADM.pwn(588) : error 029: invalid expression, assumed zero
C:\Users\user\Desktop\SAMP SERVER STUFF\samp server\pawno\FADM.pwn(588) : fatal error 107: too many error messages on one line
Reply
#8

strange i added new ID near the setadmin. PM your full script to me
Reply
#9

I took out the /akill and it fixed it. I dont really need it.
Reply
#10

...

This is more than funny...
Reply
#11

Sorry nogh let me edit that, and wor how is it funny
Reply
#12

https://sampforum.blast.hk/showthread.php?tid=65567

Read this, before posting a tutorial.

+ Nothing here is explained.. You just copy pasted..
Reply
#13

i explained it with //
Reply
#14

This may be a setadmin command, and some admin commands, but How does it save the level? How does it load it? How does one know their level?

Explain it more, good thought, but needs more explaining.
Reply
#15

Lol rebel i didnt add how to save admin level, i only added /setadmin and a admin command on my title
Reply
#16

pawn Code:
format(str,sizeof(str),"Administrator %s has admin killed you",Nam);
format(str,sizeof(str),"You have admin killed %s",pname);
Same Strings for Both?
Reply
#17

CSSI when i use /akill it works properly, did you test it?
Reply
#18

I mean if you will use same strings for both messages it will send to both players!
Reply
#19

You should add some links of where to download sscanf and zcmd.

I know its simple just easy to use ******.ca but would make your tutorial better
Reply
#20

Quote:
Originally Posted by CSSI
View Post
I mean if you will use same strings for both messages it will send to both players!
it doesnt happen to me
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)