[Include] mGates (Easily create automatic gates with one function!)
#2

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:

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;
}
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.

pawn Code:
#define TEAM_COP 1

new gTeam[MAX_PLAYERS];
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.

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 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?
Reply


Messages In This Thread
mGates (Easily create automatic gates with one function!) + 'access' conditions i.e. cops only - by MP2 - 07.06.2012, 06:39
Re: mGates (Easily create automatic gates with one function!) - by MP2 - 07.06.2012, 06:41
Re: mGates (Easily create automatic gates with one function!) - by MP2 - 07.06.2012, 07:17
Re: mGates (Easily create automatic gates with one function!) - by System64 - 07.06.2012, 07:24
Re: mGates (Easily create automatic gates with one function!) - by SkL_MD - 07.06.2012, 07:36
Re: mGates (Easily create automatic gates with one function!) - by MP2 - 07.06.2012, 07:50
Re: mGates (Easily create automatic gates with one function!) - by davve95 - 07.06.2012, 08:16
Re: mGates (Easily create automatic gates with one function!) - by MP2 - 07.06.2012, 08:18
Re: mGates (Easily create automatic gates with one function!) - by ReneG - 10.06.2012, 02:33
Re: mGates (Easily create automatic gates with one function!) - by MP2 - 10.06.2012, 03:42
Re: mGates (Easily create automatic gates with one function!) - by SDraw - 10.06.2012, 08:06
Respuesta: mGates (Easily create automatic gates with one function!) - by Marricio - 10.06.2012, 16:29
Re: mGates (Easily create automatic gates with one function!) - by Rg-Gaming.Info - 10.06.2012, 16:32
Re: mGates (Easily create automatic gates with one function!) - by KingHual - 10.06.2012, 16:37
Re: mGates (Easily create automatic gates with one function!) - by Fool - 10.06.2012, 16:38
Re: mGates (Easily create automatic gates with one function!) - by Littlehelper - 10.06.2012, 16:45
Re: mGates (Easily create automatic gates with one function!) - by dr.pepper - 10.06.2012, 16:47
Re: mGates (Easily create automatic gates with one function!) - by MP2 - 11.06.2012, 00:24
Re: mGates (Easily create automatic gates with one function!) - by Cena44 - 11.06.2012, 11:37
Re: mGates (Easily create automatic gates with one function!) - by MP2 - 11.06.2012, 13:13
Re: mGates (Easily create automatic gates with one function!) - by Jonny5 - 23.06.2012, 14:44
Re: mGates (Easily create automatic gates with one function!) - by MP2 - 23.06.2012, 23:54
Re: mGates (Easily create automatic gates with one function!) - by Lorenzo* - 25.06.2012, 06:44
Re: mGates (Easily create automatic gates with one function!) - by LavaHDProkiller - 22.01.2013, 19:06
Re: mGates (Easily create automatic gates with one function!) - by MP2 - 22.01.2013, 19:45
Re: mGates (Easily create automatic gates with one function!) - by Flashbrot - 26.01.2013, 19:22
Re: mGates (Easily create automatic gates with one function!) - by freddy smyth - 09.02.2013, 11:44
Re: mGates (Easily create automatic gates with one function!) - by Simm - 03.05.2013, 12:35
Re: mGates (Easily create automatic gates with one function!) - by Pottus - 03.05.2013, 12:40
Re: mGates (Easily create automatic gates with one function!) - by Lostlife - 03.05.2013, 12:49
Re: mGates (Easily create automatic gates with one function!) - by Simm - 03.05.2013, 13:24
Re: mGates (Easily create automatic gates with one function!) - by Simm - 04.05.2013, 09:19
Re: mGates (Easily create automatic gates with one function!) - by Simm - 05.05.2013, 03:58
Re: mGates (Easily create automatic gates with one function!) - by MP2 - 05.05.2013, 16:51
Re: mGates (Easily create automatic gates with one function!) - by MP2 - 29.06.2013, 15:26
Re: mGates (Easily create automatic gates with one function!) - by Uberanwar - 08.09.2013, 03:29
Re: mGates (Easily create automatic gates with one function!) - by Shinta307 - 09.09.2014, 13:35
Re: mGates (Easily create automatic gates with one function!) - by stormchaser206 - 06.03.2018, 03:05

Forum Jump:


Users browsing this thread: 2 Guest(s)