23.08.2009, 10:00
i get errors if i put this codes in my script and in the right place what is saying this wiki tutorial ..can i know why ?
Quote:
Additionally, you need to have coordinates of 2 locations - closed and open gate (X, Y, Z) and the closed gate must be created. // this will go above main(), as this is a global variable new c_gate; // this will go under OnGameModeInit or OnFilterScriptInit c_gate = CreateObject(object_ID, closed_X, closed_Y, closed_Z, closed_rad_X, closed_rad_Y, closed_rad_Z); And for third, you need to have the global variable for players: // this will go above main() new OpenGate[MAX_PLAYERS]; [edit] Making automatic gates Firstly, we will set a timer from OnGameModeInit() which will call after your selected time (mine has checked after 500ms, always). Feel free to change the 500ms to some other amount, but keep in mind that 1000ms equals one second. Learn more about the SetTimer function. SetTimer("CheckGate", 500, true); Now, we'll move on to the timer, which we'll forward properly. // this will go above main() forward CheckGate(); public CheckGate() { for(new i = 0; i < GetMaxPlayers(); i++) { if(!IsPlayerConnected(i)) continue; if(PlayerToPoint(10.0, i, closed_X, closed_Y, closed_Z) && OpenGate[i] == 0) { MoveObject(c_gate, open_X, open_Y, open_Z); OpenGate[i] = 1; } else if(!PlayerToPoint(10.0, i, closed_X, closed_Y, closed_Z) && OpenGate[i] == 1) { MoveObject(c_gate, closed_X, closed_Y, closed_Z); OpenGate[i] = 0; } } } |