27.11.2015, 14:50
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:
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.3273, 600);
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, -302.9852, 1511.1448, 74.3579)) return 1;
{
if(PRESSED(KEY_SPRINT))//Gate open
{
MoveObject(Gate, -313.8403, 1510.8694, 76.6647, 2.50);
SetTimerEx("gate", 5000, false, "i", playerid);
}
}
return 1;
}
public gate(playerid)
{
MoveObject(Gate,-302.3114,1511.1448,76.6647,2.50);
return 1;
}