16.03.2014, 14:12
(
Last edited by Ciarannn; 16/03/2014 at 02:45 PM.
)
Like the title says, this is a tutorial on how to give only certain players commands. Like an admin command, only admins can use it. Lets get started.
Here are the main things we will be using today:
Ok, so now making the commands and stuff. I will just make a command for lets say a Cop team.
To start, under the #endif at the top of your script, type:
Now that we have defined our team, we need to make a command for the cops like giving them armour. ((This is highly un-roleplay like, but for the purpose of the tutorial I'm just using it.))
Making the command:
Explaining time:
The command below, is a simple strcmp command that you type to activate the command you set. (Giving armour.))
Next, this command will check if the player is on that team, scroll down for information on setting them to that team.
Now to do whatever command you wan't like giving the player armour:
Then you need to end the command by typing:
Ok, so now we need to know how to set that players team:
Explaining:
This code will set the players team to the cops, if you wan't to set another players team to cops, you need to use ZCMD or another third party code. You can ****** ZCMD Tutorial, and I'm sure you will get some results.
The rest has already been explained above.
If you want to return an error message to a player that is trying to use the command but isn't a cop, this is how you do it:
Then you need to put under you armour command:
You might want to add this into your script:
You would then have to have an Cop login command, so they can sign in as a cop.
For more information on how to make teams, and spawn players, with custom chat colours, please take a look at this tutorial.
Here are the main things we will be using today:
Code:
new gTeam[MAX_PLAYERS]; //Making teams #define [TEAM NAME] 1 //Defining your team gTeam[playerid] = [TEAM NAME]; //Setting a player to that team if(gTeam[playerid] == [TEAM NAME]) // checking if a player is on that team, to give him access to the CMD.
To start, under the #endif at the top of your script, type:
Code:
new gTeam[MAX_PLAYERS]; //Creating the team function #define TEAM_COP 1 //Defining your team, the "1" is there to define the team number.
Making the command:
Code:
if (strcmp("/coparmour", cmdtext, true, 10) == 0) { if(gTeam[playerid] == TEAM_COP) { SendClientMessage(playerid, 0,"You have been given full armour."); SetPlayerArmour(playerid, 100.0); return 1; } }
The command below, is a simple strcmp command that you type to activate the command you set. (Giving armour.))
Code:
if (strcmp("/coparmour", cmdtext, true, 10) == 0)
Code:
if(gTeam[playerid] == TEAM_COP) { //Don't forget the "{" after or this won't work.
Code:
SendClientMessage(playerid, 0,"You have been given full armour."); //Sends the player a message saying he has been given full armour. SetPlayerArmour(playerid, 100.0); //Set the players armour to 100%.
Code:
return 1; } //Make sure you have the "}" to close the above one after "if(gTeam[playerid] == TEAM_COP) {".
Code:
if (strcmp("/setcop", cmdtext, true, 10) == 0) { gTeam[playerid] = TEAM_COP; SendClientMessage(playerid, 0, "You have set yourself to be a cop."); return 1; }
This code will set the players team to the cops, if you wan't to set another players team to cops, you need to use ZCMD or another third party code. You can ****** ZCMD Tutorial, and I'm sure you will get some results.
Code:
gTeam[playerid] = TEAM_COP;
If you want to return an error message to a player that is trying to use the command but isn't a cop, this is how you do it:
Code:
Above where you defined the Cops team, you need to ad: #define TEAM_COP 1 //You should already have this. #define TEAM_NORMAL 2 //Add this below the cop define
Code:
if (strcmp("/coparmour", cmdtext, true, 10) == 0) { if(gTeam[playerid] == TEAM_COP) { SendClientMessage(playerid, 0,"You have been given full armour."); SetPlayerArmour(playerid, 100.0); return 1; } if(gTeam[playerid] == TEAM_NORMAL) { //This will check if the players team is normal. SendClientMessage(playerid, 0xFFFFFFAA, "Only cops can use this command."); // <-- Tells them that. return 1; } }
Code:
public OnPlayerConnect(playerid) //Under this in your script, add the code below. { gTeam[playerid] = TEAM_NORMAL; return 1; }
For more information on how to make teams, and spawn players, with custom chat colours, please take a look at this tutorial.