OnPlayerUpdate And GangZone Problem - 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: OnPlayerUpdate And GangZone Problem (
/showthread.php?tid=508662)
OnPlayerUpdate And GangZone Problem -
lonalovegood1 - 23.04.2014
I used this code to protect my house from others ...
so i want it to do things just once , but if player has no key, he will be teleported by system every 2 seconds !!!!
and he cant move because he is teleporting every 2 seconds ...
Код:
public OnPlayerUpdate(playerid)
{
if(IsPlayerInArea(playerid, X,Y,Z))
{
if(HasPlayerKey(playerid))
{
SendClientMessage(playerid,COLOR_WHITE,"Hi, Welcome to My House :)");
}
if(!HasPlayerKey(playerid))
{
SendClientMessage(playerid,COLOR_WHITE,"You Can Not Enter Without Key.");
Wait(2000);
SetPlayerPos(playerid,-1445.2992, -1500.8733, 102.1641);
}
}
return 1;
}
Help me Please
Re: OnPlayerUpdate And GangZone Problem -
BroZeus - 23.04.2014
that wrong way of doing it use checkpoints for it
Re: OnPlayerUpdate And GangZone Problem -
Konstantinos - 23.04.2014
Instead of using the OnPlayerUpdate callback for that kind, using dynamic zones would be much better. Then in OnPlayerEnterDynamicArea callback, you can easily check whether the player has key or not for a specific zone/area.
As for the
Wait function, I wouldn't recommend it and here's the reason:
https://sampforum.blast.hk/showthread.php?tid=257660
You can use a non-repeated timer for teleporting the player once and it'll be fine.
Re: OnPlayerUpdate And GangZone Problem -
lonalovegood1 - 23.04.2014
thank you guys
So what can i use instead of that ?
Re: OnPlayerUpdate And GangZone Problem -
Konstantinos - 23.04.2014
A timer. You want to teleport that player (without the key) after 2 seconds, don't you?
pawn Код:
// in OnPlayerEnterDynamicArea callback (OPU is not for that purpose):
SetTimerEx("TeleportPlayerWithoutKey", 2000, false, "i", playerid);
and:
pawn Код:
forward TeleportPlayerWithoutKey(playerid);
public TeleportPlayerWithoutKey(playerid)
{
SetPlayerPos(playerid,-1445.2992, -1500.8733, 102.1641);
}