SA-MP Forums Archive
Disable /go to a player while he's in drag/duel/race - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Disable /go to a player while he's in drag/duel/race (/showthread.php?tid=360201)



Disable /go to a player while he's in drag/duel/race - kbalor - 16.07.2012

How to disable /go to a player when hes in drag duel or race?

Example:

Player 1 go to /race
Player 2 try to go to Player 1

Gametextforplayer will appear to Player 2 "Can't use go while player is in Dm"


Re: Disable /go to a player while he's in drag/duel/race - park4bmx - 16.07.2012

in your /goto cmd
make a variable/bool check like
pawn Код:
if(IsPlayerInRace[playerid]==true) return //Player in the race
in order to use it you will need to do this
pawn Код:
//at the top
new IsPlayerInRace[MAX_PLAYERS];

//then when player enters the race add:
IsPlayerInRace[playerid]=1; //or "false" if using bool

//when the player leaves"
IsPlayerInRace[playerid]=0; //or "false" if using bool



Re: Disable /go to a player while he's in drag/duel/race - [KHK]Khalid - 16.07.2012

Declare a per-player global variable

pawn Код:
new InEvent[MAX_PLAYERS];
And when you set a player up for an event (drag/duel/race) set the value of this var to 1 (Which means he is in an event)

pawn Код:
InEvent[playerid] = 1;
Then you can simply use the var in your /go command like this

pawn Код:
if(InEvent[playerid] == 1) // if they are in an event
{
    // Do something
}



Re: Disable /go to a player while he's in drag/duel/race - kbalor - 16.07.2012

thanks both +rep!


Re: Disable /go to a player while he's in drag/duel/race - kaiks - 16.07.2012

But if the player is in the race and reconnects, then they can tele to him, so you must save the variable.


AW: Disable /go to a player while he's in drag/duel/race - dalkgamler - 16.07.2012

i think you would not spawn in a race?! if you reconnect you are mostly on any spawn
P.s do something like in OnPlayerDeath InEvent[playerid]=0;