07.06.2012, 06:41
Explanation of 'condition' system.
The 'condition' value in CreateAutomaticGate() determines whether a player must meet certain contitions if they are to pass through a gate, for example you may wish to create a gate that only a police officer can open. This makes it extremely easy to do so.
First, create the gate with a GLOBAL VARIABLE to store the gate's ID in:
Notice how the last parameter is a 1? That is the 'condition' parameter. If set to 1, players must meet conditions we set.
Now, pretend we have a variable called 'gTeam' and a team defined as TEAM_COP. If the player's gTeam is TEAM_COP, we will allow them to trigger the gate to open.
To set permissions, we need to use the OnPlayerRequestGate callback. If we return 0 here, the gate will not open, if we return 1 it will.
If that is not obvious, allow me to break it down:
if(gateid == BARRIER_LSPD
If the gate that they requested is BARRIER_LSPD
&& gTeam[playerid] != TEAM_COP
and their gTeam is NOT TEAM_COP
return 0, denying entrance.
Extremely simple eh?
The 'condition' value in CreateAutomaticGate() determines whether a player must meet certain contitions if they are to pass through a gate, for example you may wish to create a gate that only a police officer can open. This makes it extremely easy to do so.
First, create the gate with a GLOBAL VARIABLE to store the gate's ID in:
pawn Code:
new BARRIER_LSPD;
public OnGameModeInit()
{
BARRIER_LSPD = CreateAutomaticGate(968, 1544.692993, -1630.822509, 13.08, 0.000000, 90.000000, 90.000000, 1544.692993, -1630.822509, 13.08+0.01, 0.000000, 10.000000, 90.000000, 1544.6627, -1627.4036, 13.1099, 20.0, 0.003, 1);
return 1;
}
Now, pretend we have a variable called 'gTeam' and a team defined as TEAM_COP. If the player's gTeam is TEAM_COP, we will allow them to trigger the gate to open.
pawn Code:
#define TEAM_COP 1
new gTeam[MAX_PLAYERS];
pawn Code:
#define TEAM_COP 1
new gTeam[MAX_PLAYERS];
public OnPlayerRequestGate(playerid, gateid)
{
if(gateid == BARRIER_LSPD && gTeam[playerid] != TEAM_COP) return 0;
return 1; // Player can pass
}
if(gateid == BARRIER_LSPD
If the gate that they requested is BARRIER_LSPD
&& gTeam[playerid] != TEAM_COP
and their gTeam is NOT TEAM_COP
return 0, denying entrance.
Extremely simple eh?