28.06.2016, 10:16
Introduction
Hello there fellow SA-MP members!I've decided to make a simple /setlevel or /makeadmin command to explain to those who don't understand it.I've looked up some tutorials but they were not explain properly (imo that is) so I've decided to make this tutorial.This is my first tutorial so I'll try to do my best and try to explain as much as I can.
Basics
For this command to work you'll need a Login-Register System Y_ini, which there are a lot of tutorials for that.
Second thing you'll need are these plugins
zcmd: https://sampforum.blast.hk/showthread.php?tid=91354
sscanf: https://sampforum.blast.hk/showthread.php?tid=570927
Once you have these plugins included a long with the LR System Y_ini you're good to go!
Command
Open up a new pawn script or use your own and lets get started.First off you need to define some colors or again you can use your own, I'll include these colors to make it as simple as possible
Next, find an empty space where you'll want your command to be.When you did that, now we need to decide what to call our command, I'll go with "/setlevel" because it's simple but again you can call it however you want.
Now we need to define the things we wan't.
Ok.Now I'll explain what we just defined since I feel you already lost me.
The id, represents the player who we wan't to make admin.The level is the admin level which we want to set, first of all I didn't want to include a string so I added these messages (msg and msg2) and last but not least the name is the player name whom we are setting the level
Now we will add
To check if the player is logged in rcon, if hes not it will display a message I will add at the end of the script.
Now lets see what will happen when the player enters the command.Put this next in the script.
So when a player enters "/setlevel" it will display this message.
Now we wan't a message to display when you've entered an incorrect or invalid player id.
Next off we want to decide how many admin levels we'll be having.
I added max. 5 levels but you can put any number you want.So if you've entered for e.g "/setlevel 0 6" it will display the message that the admin levels are between 1 and 5.
Now let's see what will happen when we use the command.First off add this
So now we will be putting a code that will display the command.
By adding this to the code we are actually setting the players admin level.Before we go any further this "pInfo and Adminlevel" depend on what you've included in your enum.Yours might be different so keep an eye on that.
So now that we actually added what the command will do here is where those msg's we included come.
This line will tell the player we've gave admin to the info that his admin level has been set.
Under this line put
This is always need to put under the format message.
Now we need to do is get the player name by adding this
Now here is where the second msg will come.What the second msg does, is informs you that you've set someones admin level to something.
And of course we need
But this time it's not "id", it's "playerid".Why?Well because it's informing you not the other player.
Now for the ending of the command I told that we were gonna display a message if the player isn't logged in rcon.
Add another "else"
And under it add this
When you've finished the command it should look like this
I didn't want to add any comments to the script since you'd probably delete it and it would be a waste of my and your time but everything is explained here.If you had problems with the command feel free to post about it in the commands.I know this tutorial isn't the best but since it's my first hah .I'll maybe try doing more of these command if you guys want.
Note:Have in mind that if you are new to zcmd or pawn DO NOT try this command!
Hello there fellow SA-MP members!I've decided to make a simple /setlevel or /makeadmin command to explain to those who don't understand it.I've looked up some tutorials but they were not explain properly (imo that is) so I've decided to make this tutorial.This is my first tutorial so I'll try to do my best and try to explain as much as I can.
Basics
For this command to work you'll need a Login-Register System Y_ini, which there are a lot of tutorials for that.
Second thing you'll need are these plugins
zcmd: https://sampforum.blast.hk/showthread.php?tid=91354
sscanf: https://sampforum.blast.hk/showthread.php?tid=570927
Once you have these plugins included a long with the LR System Y_ini you're good to go!
Command
Open up a new pawn script or use your own and lets get started.First off you need to define some colors or again you can use your own, I'll include these colors to make it as simple as possible
Code:
#define COLOR_GREEN 0x33AA33AA #define COLOR_RED 0xAA3333AA
Code:
CMD:setlevel(playerid, params[]) { return 1; }
Code:
new id,level,msg[128],msg2[128],name[MAX_PLAYER_NAME];
The id, represents the player who we wan't to make admin.The level is the admin level which we want to set, first of all I didn't want to include a string so I added these messages (msg and msg2) and last but not least the name is the player name whom we are setting the level
Now we will add
Code:
if(IsPlayerAdmin(playerid))
Now lets see what will happen when the player enters the command.Put this next in the script.
Code:
if(sscanf(params,"ud",id,level))return SendClientMessage(playerid, COLOR_RED,"Usage: /setlevel [player id] [level]");
Now we wan't a message to display when you've entered an incorrect or invalid player id.
Code:
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "That player is not connected.");
Code:
else if(level > 5)return SendClientMessage(playerid, COLOR_RED,"Admin levels are between 1 and 5!");
Now let's see what will happen when we use the command.First off add this
Code:
else { }
Code:
pInfo[id][Adminlevel] = level;
So now that we actually added what the command will do here is where those msg's we included come.
Code:
format(msg,sizeof(msg),"Your admin level has been set to %d.",level);
Under this line put
Code:
SendClientMessage(id,COLOR_GREEN,msg);
Now we need to do is get the player name by adding this
Code:
GetPlayerName(id,name,sizeof(name));
Code:
format(msg2,sizeof(msg2),"You have set %s's admn level to %d.",name,level);
Code:
SendClientMessage(playerid,COLOR_GREEN,msg2);
Now for the ending of the command I told that we were gonna display a message if the player isn't logged in rcon.
Add another "else"
Code:
} else {
Code:
SendClientMessage(playerid, COLOR_RED,">>Error<< You have to be logged in rcon to use this command!"); } return 1;
Code:
CMD:setlevel(playerid, params[]) { new id,level,msg[128],msg2[128],name[MAX_PLAYER_NAME]; if(IsPlayerAdmin(playerid)) { if(sscanf(params,"ud",id,level))return SendClientMessage(playerid, COLOR_RED,"Usage: /setlevel [player id] [level]"); if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "That player is not connected."); else if(level > 5)return SendClientMessage(playerid, COLOR_RED,"Admin levels are between 1 and 5!"); else { pInfo[id][Adminlevel] = level; format(msg,sizeof(msg),"Your admin level has been set to %d.",level); SendClientMessage(id,COLOR_GREEN,msg); GetPlayerName(id,name,sizeof(name)); format(msg2,sizeof(msg2),"You have set %s's admn level to %d.",name,level); SendClientMessage(playerid,COLOR_GREEN,msg2); } } else { SendClientMessage(playerid, COLOR_RED,">>Error<< You have to be logged in rcon to use this command!"); } return 1; }
Note:Have in mind that if you are new to zcmd or pawn DO NOT try this command!