Police Faction
#1

Can someone tell me what i need to make a Police Faction. I know i need there Duty position and stuff like that but what else? Also can i find a guide around SAMP on how to make it so all the commands work, they duty works and everything else. I`m trying to make this in San Fierro.
Reply
#2

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).
Reply
#3

Ok i think i see what you are saying. But i`m not sure if you are familiar with the South-West Role Play script. I`m currently editing this one. So what you said here would i do the same to this script? Thing i know is that 0 is the Police Department.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)