[Tutorial] How to make the "/adminduty" command.
#1

Welcome to my first tutorial!

In this tutorial, I am going to show you how to make the "/adminduty" command,
it is very easy, hope you will enjoy.


For this you are gonna need to define some colors, and you are gonna need the sscanf and Y_INI plugins. You can easily find that here on the forum.

It's going to look something like this:
https://prnt.sc/fyzflr

So let's begin.

For this you are going to need this Login/Register system, which includes an admin system that we are gonna use: https://sampforum.blast.hk/showthread.php?tid=273088

Now when you have that, let's begin.

First at the top of our script we add:
Code:
new AdminDuty[MAX_PLAYERS];
When that's done, we are going to start making the actual command.
We go to the bottom of the script, or wherever are your commands are, and type:
Code:
YCMD:adminduty(playerid, params[], help)
{
	if(PlayerInfo[playerid][pAdmin] < 1) return SCM(playerid, RED, "You don't have the right to use this 
        command.");
NOTE:You don't have to type YCMD:adminduty, you can type whatever you want the command to be,
like YCMD:aduty or whatever
That is going to check is the player that's typing the command an admin.
If he's not, it's going to send him the message saying that he doesn't have the right to use that command.
Now this part is all about formatting, I won't explain that to you, you have plenty of tutorials about that, I'm just going to add the code:
Code:
	new string[256], name1[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name1, sizeof(name1));
	if(AdminDuty[playerid] == 0)
	{
	    format(string, sizeof(string), "Admin {FF0000}%s {FFFFFF} is on the duty, for help type 
            /help", name1);
	    SCMTA(-1, string);
	    AdminDuty[playerid] = 1;
            SetPlayerArmour(playerid, 100);
	    SetPlayerColor(playerid, GREEN);
	    SetPlayerSkin(playerid, 294);
          }
So basically this checks is player already on admin duty, if not, it's gonna send a message to everyone on the server saying that he is now on duty.
And it's also gonna set his skin to 294 and set his name color to green.
If you know at least a little bit about formatting you can edit this.
Let's move on.

Code:
	else if(AdminDuty[playerid] == 1)
        {
		SetPlayerHealth(playerid, 0);
		SetPlayerColor(playerid, -1);
		SetPlayerSkin(playerid, 1);
		format(string, sizeof(string), "Admin {FF0000}%s {FFFFFF}is no longer on duty.", name1);
		SCMTA(-1, string);
		AdminDuty[playerid] = 0;
	}
	return 1;
}
Now, this is just reversed, if the player is on duty, it's gonna kill him, set his name color to white, set his skin to default, and tell everyone that he is no longer on duty.

That was my first tutorial, it might be a bit confusing, but it's actually not.
If you have any problems, just send me a message! If I helped you +rep me. Thank you!
Reply


Messages In This Thread
How to make the "/adminduty" command. - by AmarPlayer - 22.07.2017, 22:38
Re: How to make the "/adminduty" command. - by Eoussama - 22.07.2017, 22:42
Re: How to make the "/adminduty" command. - by Logic_ - 22.07.2017, 23:45
Re: How to make the "/adminduty" command. - by Henson - 06.08.2017, 15:12
Re: How to make the "/adminduty" command. - by SyS - 06.08.2017, 15:14
Re: How to make the "/adminduty" command. - by Bolex_ - 06.08.2017, 15:18
Re: How to make the "/adminduty" command. - by Toroi - 06.08.2017, 15:24
Re: How to make the "/adminduty" command. - by coool - 06.08.2017, 15:49
Re: How to make the "/adminduty" command. - by Henson - 06.08.2017, 16:05
Re: How to make the "/adminduty" command. - by GhostHacker9 - 07.08.2017, 13:55

Forum Jump:


Users browsing this thread: 1 Guest(s)