OnPlayerUpdate And GangZone Problem
#1

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
Reply
#2

that wrong way of doing it use checkpoints for it
Reply
#3

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.
Reply
#4

thank you guys
So what can i use instead of that ?
Reply
#5

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);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)