About Factions
#1

hi
i want to make factions for my rp server
i have an idea for it:

player go to an place
like lspd officer room and type /duty

then an menu about skin showed to him,after select skin he recive a few armorys

i havent any prob with this and can make this part but i dont know what must do for when
player select skin change her colorname

and on more think is i want lock cars
i mean only cops can enter an car or medics or ...


and one more think about keys in server

i want when player press f key TP to a posision

anyone help please
Reply
#2

You should define the factions, then you can make some player stats into enum like.

Код:
#define POLICE 1
#define MAFIA 2

enum players
{

    faction,
    rank
}
new PlayerInfo[MAX_PLAYERS][players];

Then you can use - 

If(PlayerInfo[playerid][faction] == POLICE)
{
    // code here just for cops
}
else
{
    SendClientMessage(playerid, 0xCC3300FF, "You are not allowed to use it, Only for cops.");
    return 1;
}
Here is for clicking enter and tping

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if(newkeys & KEY_SECONDARY_ATTACK) // ENTER
	{
	    if(IsPlayerInRangeOfPoint(playerid, 3.0, 0.0,0.0,0.0)) // Put the coords you want
	    {
	        SetPlayerPos(playerid, 0.0,0.0,0.0); // put player pos coords
	    }
	    else
		{
		    SendClientMessage(playerid, 0xCC3300FF, "You are not at the currect place.");
		    return 1;
		}
	}
	return 1;
}
Reply
#3

ty bro but please explain more information
Reply
#4

UP!...
Reply
#5

In basics: You need to compare two variables, if lets say your factionvariable(enum)(like previous example above)

if( PlayerInfo[playerid][Faction] == police)

Police was defined as 1 if you read the previous example so what's happening is basically this:

if faction is 1 it will continue, if it isn't it won't continue


Код:
if("Factionvariable" == POLICE)
Do something; // here you could set the skin or show the menu for an example.
Reply
#6

i use your helps but not answered right
Код:
#define people 1
#define police 2


enum players
{

    faction,
    rank
}
new PlayerInfo[MAX_PLAYERS][players];




public OnPlayerCommandText(playerid, cmdtext[])
{
				if(strcmp(cmdtext,"/duty",true)==0)
				{
				if(IsPlayerInRangeOfPoint(playerid,4,233.3000000,124.4000000,1002.8000000))
	             {
				  if(PlayerInfo[playerid][faction] == people)
				   {
					 
					 SetPlayerSkin(playerid, 480);
					 SendClientMessage(playerid, -1, "you are police officer");
					 SetPlayerColor(playerid, 255);
				   }
	 	          return 1;
	              }
				 }

public OnPlayerConnect(playerid)
{
if(PlayerInfo[playerid][faction] == police)
{
    SetPlayerSkin(playerid, 480);
    SendClientMessage(playerid, -1, "You are police officer");
    SetPlayerColor(playerid, 255);
    
}
return 1;
}
its right script to create factions?
but it not work
i think i dont use it correctly
help pls


i use one more way
Код:
#define people 1
#define police 2
#define peoplecolor F0F8FF
#define policecolor 0000FF




new pTeam[MAX_PLAYERS];

public OnPlayerCommandText(playerid, cmdtext[])
{
				if(strcmp(cmdtext,"/police",true)==0)
				{
				if(IsPlayerInRangeOfPoint(playerid,4,233.3000000,124.4000000,1002.8000000))
	            {
    			 pTeam[playerid] = police;
				 SetPlayerSkin(playerid, 480);
				 SendClientMessage(playerid, -1, "You are a cop");
			    }
	 	        return 1;
           		}
in this code when i use /police in point game crash
whats problem
Reply
#7

158 view
and i dont get right way
Reply
#8

UP...
Reply
#9

1. Define factions, an unique ID for each:

#define LSPD 1
#define FBI 2

2. You need three arrays to detect: rank, duty and the faction each player is in.

FactionRank[MAX_PLAYERS];
Faction[MAX_PLAYERS];
bool:FactionDuty[MAX_PLAYERS = false;

3. You then can make a command to set the faction that player is in, another command to set the rank. This should set Faction[playerid] equal to the faction ID the player is in.

4. A /duty command that sets the player skin, colour and weapons. You should then set FactionDuty[playerid] to true.




-----------------

I would actually do,

enum playerinfo {
faction,
rank,
duty
}
new pInfo[MAX_PLAYERS][playerinfo];

instead of what I said above, however I split it to make it easier to understand for you ! Hope that helps!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)