I'll help you.
Variables are very very useful in SAMP scripting. They help you out in making conditions like
if and other important things. Here is the description in examples:
Above, you created a new variable, and this variable can be anything written replacing
MyVariable. Now let's make it easy, suppose the variable was:
Note, that we used
MAX_PLAYERS, which will set your variable's
Array to your maximum players in
server.cfg.
Now, we need to define our teams just for the ease. This needs to be put below the
#includes and above the
forwards:
pawn Код:
#define TEAM_COP 1
#define TEAM_GANG1 2
These can also be changed to whatever you want. Now as we defined our teams, let's get to the main work. Now you need to set the player's team. We'll do it in a easy command:
pawn Код:
//This message, after the two slashes '//' will be ignored by the compiler.
if (strcmp("/Police", cmdtext, true, 10) == 0)//This will be the command /police
{
Team[playerid] = 1;//The team here has been set to TEAM_COP, as we defined TEAM_COP as '1'
SendClientMessage(playerid, 0xFFFFFFFF,"Your now a member of San Andreas Police.");//This will send a confirmation message to the Commander.
return 1;
}
Now, let's make our final step, and try a command which will only be used by 'Cops':
pawn Код:
if(strcmp("/Flash", cmdtext, true, 10) == 0)
{
new string[56];//this is needed for formatting.
new playername[24];//this is going to be used for GetPlayerName.
if(Team[playerid] == 1)
{
GetPlayerName(playerid, playername, sizeof(playername));//Getting the player's name.
format(string, sizeof(string), "%s raises his Police badge and shows it around", playername);//formating the text with the player's name.
SendClientMessage(playerid,0xFFFFFFFF,string);//This is incomplete with out the format.
}
return 1;
}