Fairly simple my friend.
On top of your script add:
Код:
#define COLOR_WHITE 0xFFFFFFAA
enum pInfo
{
Faction, // This is a list of variables you can use for a player
};
new Account[MAX_PLAYERS][pInfo]; // This will read from a players "account", consisting of the variables from pInfo
Now, down let's make it so anyone who connects is a Officer for testing.
Код:
public OnPlayerConnect(playerid)
{
Account[playerid][Faction] = 1; // Assuming 0 is Civilian, and 1 if Officer
}
Now for a simple command.
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/checkme", true) == 0)
{
if(Account[playerid][Faction] == 0)
{
SendClientMessage(playerid, COLOR_WHITE, "** You are a Civilian"); // Assuming 0 is a Civilian
return 1;
}
if(Account[playerid][Faction] == 1)
{
SendClientMessage(playerid, COLOR_WHITE, "** You are a Police Officer"); // Assuming 1 is a Officer
return 1;
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "** Your faction is undetected"); // If the players Faction ID isn't 0 or 1
return 1;
}
}
}
What's all this mean? Fairly simple. See, enum(s) are very useful as it can be used to define a set number of variables for a player. The variable Account[playerid][Faction] simply checks what digit that is being represented as. In this case, 0 is a Civilian, and 1 is a Officer. Everything else is just unknown. You could make 3 be Medics, or anything you wanted. But it doesn't really do anything until you use it as a check. We checked to see what that variable was, and if it equaled (==) 1, then the script let it continue. So in order to make a command for the Police Force, just simply have it check for that variable to equal 1 (or any number you want).