SA-MP Forums Archive
Where should I put IsPlayerInRangeOfPoint? - 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: Where should I put IsPlayerInRangeOfPoint? (/showthread.php?tid=358162)



Where should I put IsPlayerInRangeOfPoint? - newbienoob - 09.07.2012

Well, I'm making an automatic gate for my gamemode. But I don't know where should I put IsPlayerInRangeOfPoint.
pawn Code:
if(IsPlayerInRangeOfPoint(playerid,3,-839.4182,1398.3528,13.6094))
    {
        SendClientMessage(playerid,red,"Opening gate, please wait...");
        MoveObject(trgate[0],-835.0771, 1397.9591, 13.4000,2,0.0000, 15.0000, 207.1798);
        gate[playerid] = SetTimerEx("gate1",5000,false,"i",playerid);
        return 1;
    }
I've tried to put it under OnPlayerSpawn, but it doesn't work. If I put it under OnPlayerUpdate, it will spam me with this message "Opening gate, please wait...".


Re: Where should I put IsPlayerInRangeOfPoint? - kepa333 - 09.07.2012

try here public
Code:
OnGameModeInit()



Re: Where should I put IsPlayerInRangeOfPoint? - newbienoob - 09.07.2012

SendClientMessage(playerid
I will get an error.


Re: Where should I put IsPlayerInRangeOfPoint? - Jarok - 09.07.2012

The only way to do it is OnPlayerUpdate, try removing the message.

EDIT: The reason it will spam you is because OnPlayerUpdate is updated every 2 seconds.


Re:: Where should I put IsPlayerInRangeOfPoint? - newbienoob - 09.07.2012

Well... Look at this video

[ame]http://www.youtube.com/watch?v=Bfc3rPQtBsc[/ame]


Re: Where should I put IsPlayerInRangeOfPoint? - kepa333 - 09.07.2012

add unde gamemode int:

Code:
new trgate1;
trgate1 = CreateDynamicObject(...);

f(IsPlayerInRangeOfPoint(playerid,3,-839.4182,1398.3528,13.6094))
    {
        SendClientMessage(playerid,red,"Opening gate, please wait...");
        MoveObject(trgate1,-835.0771, 1397.9591, 13.4000,1000);
        gate[playerid] = SetTimerEx("gate1",5000,false,"i",playerid);
        return 1;
    }

// timer
forward gate1();
public gate1()
{
     SendClientMessage(playerid,red,"gate closing...");
     MoveObject(trgate1,yourcordinats,speed);
}



Re: Where should I put IsPlayerInRangeOfPoint? - newbienoob - 09.07.2012

I will get an errors.


Re: Where should I put IsPlayerInRangeOfPoint? - kepa333 - 09.07.2012

lol jsut try not just say "i will get erors". it the tested way.


Re: Where should I put IsPlayerInRangeOfPoint? - milanosie - 09.07.2012

Quote:
Originally Posted by Jarok
View Post
The only way to do it is OnPlayerUpdate, try removing the message.

EDIT: The reason it will spam you is because OnPlayerUpdate is updated every 2 seconds.
Uhhm wrong?

It's called every 1/16 of a second, AKA 16 times a second.


Re: Where should I put IsPlayerInRangeOfPoint? - Infinity - 09.07.2012

Quote:
Originally Posted by milanosie
View Post
Uhhm wrong?

It's called every 1/16 of a second, AKA 16 times a second.
It's called when a player updates, this can vary. And yes, if you want to make it automatic OnPlayerUpdate would be a good guess.