05.03.2018, 01:07
Hey guys, lately ive been playing around with a script, ive got everything working except the damn payphones and im at my wits end with it, the issue is i use the cmd /createphone and it spawns a payphone at my position with a random generated number, it all works good until i restart the server, upon reloading everything and logging back in the payphones are now at 0,0,0,0 which is just under the ground at blueberry in the field, but in the database the co-ordinates are still what they should be so im pretty sure its a problem with the script, il post some codes below
And heres a few screenshots of how the table in the database is setup
https://imgur.com/a/D2kRM
https://imgur.com/a/wA7se
Код:
LoadPayPhones() { print("[Pay Phones] Loading pay phones from database..."); mysql_tquery(MainPipeline, "SELECT * FROM `payphones`", "OnLoadPayPhones", ""); } forward OnLoadPayPhones(); public OnLoadPayPhones() { new iRows; cache_get_row_count(iRows); if(!iRows) return print("[Pay Phones] No pay phones were found in the database."); new iRow, value, Float:fValue; while(iRow < iRows) { cache_get_value_name_int(iRow, "number", arrPayPhoneData[iRow][pp_iNumber]); arrPayPhoneData[iRow][pp_iCallerID] = INVALID_PLAYER_ID; ProcessPayPhone(iRow, cache_get_value_name_float(iRow, "posx", fValue), cache_get_value_name_float(iRow, "posy", fValue), cache_get_value_name_float(iRow, "posz", fValue), cache_get_value_name_float(iRow, "rotz", fValue), cache_get_value_name_int(iRow, "vw", value), cache_get_value_name_int(iRow, "int", value)); iRow++; } return printf("[MySQL] Loaded %i pay phones from database.", iRows); }
Код:
forward OnCreatePayPhone(playerid, i, Float:X, Float:Y, Float:Z, Float:RZ, iVW, iINT); public OnCreatePayPhone(playerid, i, Float:X, Float:Y, Float:Z, Float:RZ, iVW, iINT) { if(mysql_errno(MainPipeline)) return SendClientMessageEx(playerid, COLOR_GRAD1, "Something went wrong. Please contact the development team."); ProcessPayPhone(i, X, Y, Z, RZ, iVW, iINT); format(szMiscArray, sizeof szMiscArray, "You have created a pay phone using ID %i.", i); SendClientMessageEx(playerid, COLOR_GRAD1, szMiscArray); format(szMiscArray, sizeof szMiscArray, "%s has creatd a pay phone using ID %i.", GetPlayerNameEx(playerid), i); Log("logs/payphones.log", szMiscArray); return 1; }
Код:
ProcessPayPhone(i, Float:X, Float:Y, Float:Z, Float:RZ, iVW, iINT) { if(X != 0 && Y != 0) { arrPayPhoneData[i][pp_iCallerID] = INVALID_PLAYER_ID; arrPayPhoneData[i][pp_iObjectID] = CreateDynamicObject(1216, X, Y, Z - 0.3, 0.0, 0.0, RZ + 180.0, .worldid = iVW, .interiorid = iINT); format(szMiscArray, sizeof(szMiscArray), "Pay Phone {DDDDDD}(ID: %d)\n{FFFF00} Number: %d\n\n{DDDDDD}Press ~k~~CONVERSATION_YES~ to dial.", i, arrPayPhoneData[i][pp_iNumber]); arrPayPhoneData[i][pp_iTextID] = CreateDynamic3DTextLabel(szMiscArray, COLOR_YELLOW, X, Y, Z + 1.0, 5.0, .worldid = iVW, .interiorid = iINT); arrPayPhoneData[i][pp_iAreaID] = CreateDynamicSphere(X, Y, Z, 3.0, iVW, iINT); } }
Код:
PayPhone_Save(i, Float:X, Float:Y, Float:Z, Float:RZ, iVW, iINT) { if(!IsValidDynamicArea(arrPayPhoneData[i][pp_iAreaID])) return 1; mysql_format(MainPipeline, szMiscArray, sizeof szMiscArray, "UPDATE `payphones` SET\ `number` = %d, \ `vw` = %i, \ `int` = %i, \ `posx` = %f, \ `posy` = %f, \ `posz` = %f, \ `rotz` = %f", arrPayPhoneData[i][pp_iNumber], iVW, iINT, X, Y, Z, RZ ); mysql_tquery(MainPipeline, szMiscArray, "OnQueryFinish", "i", SENDDATA_THREAD); return 1; }
https://imgur.com/a/D2kRM
https://imgur.com/a/wA7se