SA-MP Forums Archive
Detect if player moved. - 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 player moved. (/showthread.php?tid=187160)



Detect if player moved. - ZamaXor - 01.11.2010

I need something like when someonce type /joinstant it will say him "Please don't move and wait 10 seconds." If player move in this 10 seconds it will say him "You moved and failed to join the stunt area."So it must teleport the player after 10 sec if he not moved to sunt zone.


Re: Detect if player moved. - CJ101 - 01.11.2010

Just freeze the player for ten seconds.


Re: Detect if player moved. - ZamaXor - 01.11.2010

i don't want to freeze the player. i just want what i asked for. so if you can help reply if you can't, don't!


Re: Detect if player moved. - Zimon95 - 01.11.2010

You can check if the player position is the same every X seconds using a timer and function GetPlayerPos.


Re: Detect if player moved. - Bessensap - 01.11.2010

put this from when u dont want him to move:
pawn Код:
new Float:x,Float:y,Float:z;
    GetPlayerPos(playerid,x,y,z);
   
    SetPVarFloat(playerid,"posx",x);
    SetPVarFloat(playerid,"posy",y);
    SetPVarFloat(playerid,"posz",z);
      PlayerCanMove[playerid] = false;
in onplayerupdate:
pawn Код:
public OnPlayerUpdate(playerid)
{
    if(!PlayerCanMove[playerid])
    {
        new Float:x,Float:y,Float:z;
        GetPlayerPos(playerid,x,y,z);
                SetTimerEx("PlayerCanMove",10000,false,"i",playerid);
        if(GetPVarFloat(playerid,"posx") != x && GetPVarFloat(playerid,"posx") != y && GetPVarFloat(playerid,"posz") != z)
        {
            SetPlayerPos(playerid,your_x_here,your_y_here,your_z_here);
            SendClientMessage(playerid,YOUR_COLOR,"Failed to enter stuntzone, you moved!");
        }
    else
    {
        SetPlayerPos(playerid,stuntparkcoords);
        SendClientMessage(playerid,YOUR_COLOR,"Welcome to the stuntzone.");
    }
}
global new:
pawn Код:
new bool:PlayerCanMove[MAX_PLAYERS];
Anywhere:
pawn Код:
forward PlayerCanMove(playerid);
public PlayerCanMove(playerid)
{
    PlayerCanMove[playerid] = true;
}

not tested