SA-MP Forums Archive
Gate moving 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: Gate moving problem (/showthread.php?tid=595041)



Gate moving problem - Dragonic - 27.11.2015

Well, everything is working perfectly with my script, exept one thing:
It is supposed to only open if the player is in a certain distance, that is supposed to be 1 meter from the gate, but no matter how far/close I am, if I press "Space" or "W" it opens up...

Here goes the code:

PHP код:
#define FILTERSCRIPT
#include <a_samp>
new Gate;
forward gate(playerid);
#define PRESSED(%0) \
      
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
public 
OnGameModeInit()
{
    
Gate CreateObject(980,-302.3114,1511.1448,76.6647,0.0000,0.0000,1.3273600);
    return 
1;
}
public 
OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
IsPlayerInRangeOfPoint(playerid1.0, -302.98521511.144874.3579)) return 1;
    {
       if(
PRESSED(KEY_SPRINT))//Gate open
       
{
           
MoveObject(Gate, -313.84031510.869476.66472.50);
           
SetTimerEx("gate"5000false"i"playerid);
       }
    }
    return 
1;
}
public 
gate(playerid)
{
   
MoveObject(Gate,-302.3114,1511.1448,76.6647,2.50);
   return 
1;




Re: Gate moving problem - Sawalha - 27.11.2015

Код:
if(IsPlayerInRangeOfPoint(playerid, 1.0, -302.9852, 1511.1448, 74.3579))
remove return 1;
it's not needed everywhere