Gate System - Regicide - 2021-06-15
Okay so, for some reason when more than one gate loads it goes to shit the second gate moves to the position of the first gate, the third gate moves to the second gate position, and so on, why is this happening?
PHP Code: enum _GateEnum { ? ? GateID, ? ? Float:gate_place[4], ? ? Float:grX, ? ? Float:grY, ? ? Float:grZ, ? ?GateFaction, ? ?GateModel, ? ?GateObject, ? ?GateStatus }
PHP Code: new Gates[MAX_GATES][_GateEnum];
PHP Code: new Iterator:server_gates<MAX_GATES>;
PHP Code: load_gates() { ? ? inline LoadGates() ? ? { ? ? ? ? if(!cache_num_rows()) ? ? ? ? { ? ? ? ? ? ? printf("[MYSQL]: No Gate data found!"); ? ? ? ? ? ? return 0; ? ? ? ? } ? ? ? ? foreach (new i : Range(0, cache_num_rows())) ? ? ? ? { ? ? ? ? ? ? cache_get_value_int(i, "id", Gates[i][GateID]); ? ? ? ? ? ? cache_get_value_float(i, "x", Gates[i][gate_place][0]); ? ? ? ? ? ? cache_get_value_float(i, "y", Gates[i][gate_place][1]); ? ? ? ? ? ? cache_get_value_float(i, "z", Gates[i][gate_place][2]);
? ? ? ? ? ? cache_get_value_float(i, "rx", Gates[i][grX]); ? ? ? ? ? ? cache_get_value_float(i, "ry", Gates[i][grY]); ? ? ? ? ? ? cache_get_value_float(i, "rz", Gates[i][grZ]); ? ? ? ? ? ? cache_get_value_int(i, "faction", Gates[i][GateFaction]); ? ? ? ? ? ? cache_get_value_int(i, "model", Gates[i][GateModel]);
? ? ? ? ? ? Gates[i][GateStatus] = 0;
? ? ? ? ? ? Gates[i][GateObject] = CreateObject(Gates[i][GateModel], Gates[i][gate_place][0], Gates[i][gate_place][1], Gates[i][gate_place][2], Gates[i][grX], Gates[i][grY], Gates[i][grZ], 300.0);
? ? ? ? ? ? Iter_Add(server_gates, i); ? ? ? ? } ? ? ? ? printf("%d gates loaded.", i); ? ? ? ? return 1; ? ? } ? ? MySQL_TQueryInline(g_SQL, using inline LoadGates, "SELECT * FROM `server_gates`"); ? ? return 1; }
PHP Code: YCMD:gate(playerid, params[], help) { ? ? foreach(new i:server_gates) ? ? { ? ? ? ? if(IsPlayerInRangeOfPoint(playerid, 5, Gates[i][gate_place][0], Gates[i][gate_place][1], Gates[i][gate_place][2])) ? ? ? ? { ? ? ? ? ? ? if(user_faction[playerid] == Gates[i][GateFaction]) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? if(Gates[i][GateStatus] == 0) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? MoveObject(Gates[i][GateObject], Gates[i][gate_place][0], Gates[i][gate_place][1], Gates[i][gate_place][2] -7.0, 3.0); ? ? ? ? ? ? ? ? ? ? Gates[i][GateStatus] = 1; ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? else ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? MoveObject(Gates[i][GateObject], Gates[i][gate_place][0], Gates[i][gate_place][1], Gates[i][gate_place][2], 3.0); ? ? ? ? ? ? ? ? ? ? Gates[i][GateStatus] = 0; ? ? ? ? ? ? ? ? }? ? ? ? ? ? ? } ? ? ? ? ? ? else ? ? ? ? ? ? { ? ? ? ? ? ? ? ? SendClientMessage(playerid, -1, "[SERVER] You don't have access to this gate!"); ? ? ? ? ? ? } ? ? ? ? } ? ? ? ? else ? ? ? ? { ? ? ? ? ? ? SendClientMessage(playerid, -1, "[SERVER]: You're not near any gate!"); ? ? ? ? } ? ? } ? ? return 1; }
RE: Gate System - Kwarde - 2021-06-16
Do some debugging. Either print to the console (or a file) or (which I find easier when being in-game) to the client.
Print out things such as what loop you're in/value of variable i, which statement was triggered, position of gate "i" etc...
|