Detect if a Player has left their Position. - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Detect if a Player has left their Position. (
/showthread.php?tid=84341)
Detect if a Player has left their Position. -
Abernethy - 30.06.2009
Once again, I need help. I was how I would detect when a person types /holdup if he moves 5.0+ radius away before he's robbed the store/house. I'll Kill the timer. Help?
<3
Re: Detect if a Player has left their Position. -
Grim_ - 30.06.2009
Can you explain a little more please?
Re: Detect if a Player has left their Position. -
Abernethy - 30.06.2009
I walk up the the 24/7.
I type /holdup.
The Timer has been Activated.
If I move 5.0 radius (I duno wtf I'm saying here) away from the place where /holdup was put.
The timer will be killed, therefore meaning you failed to rob the store.
Re: Detect if a Player has left their Position. -
Grim_ - 30.06.2009
Untested, but somethign like this.
pawn Код:
//top
new Timer[MAX_PLAYERS];
//onplayercommandtext
if(strcmp(cmdtext, "/holdup", true) == 0)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
SendClientMessage(playerid, color, "Don't move from this position or the robbery will fail!");
Timer[playerid] = SetTimerEx("LeftArea", 500, 1, "ifff", playerid, x, y, z);
return 1;
}
//after main()
forward LeftArea(playerid, Float:X, Float:Y, Float:Z);
public LeftArea(playerid, Float:X, Float:Y, Float:Z)
{
if(!PlayerToPoint(5, playerid, X, Y, Z);
{
KillTimer(Timer[playerid]);
SendClientMessage(playerid, color, "You left the area! The robbery is a bust!");
//your code for stoping, w/e
}
}