02.09.2009, 00:54
I have made some automatic gates the codes are as follows
Both the gates open but they dont close , i tried to add return 1; as well as return 0; but doesnt help it .... Please help me solving this riddle
Код:
PlayerToPoint(Float:radius, playerid, Float:X, Float:Y, Float:Z) { new Float:oldpos[3], Float:temppos[3]; GetPlayerPos(playerid, oldpos[0], oldpos[1], oldpos[2]); temppos[0] = (oldpos[0] -X); temppos[1] = (oldpos[1] -Y); temppos[2] = (oldpos[2] -Z); if(((temppos[0] < radius) && (temppos[0] > -radius)) && ((temppos[1] < radius) && (temppos[1] > -radius)) && ((temppos[2] < radius) && (temppos[2] > -radius))) { return true; } return false; }
Код:
new Lsgate; new Lvgate; forward CheckGate(); forward CheckGate2();
Код:
Lsgate = CreateObject(980, 1961.425415, -2189.519043, 15.320267, 0.0000, 0.0000, 0.0000); Lvgate = CreateObject(980, 1706.067505, 1607.601563, 11.983828, 0.0000, 0.0000, 253.4298); SetTimer("CheckGate", 1000, true); SetTimer("CheckGate2", 1000, true);
Код:
public CheckGate() { for(new i = 0; i < GetMaxPlayers(); i++) { if(!IsPlayerConnected(i)) continue; if(PlayerToPoint(9.5, i, 1961.425415, -2189.519043, 15.320267) && OpenGate[i] == 0) { MoveObject(Lsgate, 1961.434082, -2189.519043, 9.050316,3); PlayerPlaySound(1186,0,0,0,0); OpenGate[i] = 1; } else if(!PlayerToPoint(5.5, i, 1961.425415, -2189.519043, 15.320267) && OpenGate[i] == 1) { MoveObject(Lsgate,1961.425415, -2189.519043, 15.320267,3); PlayerPlaySound(1186,0,0,0,0); OpenGate[i] = 0; } } } public CheckGate2() { for(new i = 0; i < GetMaxPlayers(); i++) { if(!IsPlayerConnected(i)) continue; if(PlayerToPoint(9.5, i, 1706.067505, 1607.601563, 11.983828) && OpenGate[i] == 0) { MoveObject(Lvgate, 1706.055054, 1607.618652, 5.914435,3); PlayerPlaySound(1186,0,0,0,0); OpenGate[i] = 1; } else if(!PlayerToPoint(5.5, i, 1706.067505, 1607.601563, 11.983828) && OpenGate[i] == 1) { MoveObject(Lvgate,1706.067505, 1607.601563, 11.983828,3); PlayerPlaySound(1186,0,0,0,0); OpenGate[i] = 0; }