25.03.2019, 15:39
I have a problem with saving repair id and which it won't load.
prints in database,
which it keep using -1
prints in database,
Код:
PickupID pux puy puz -1 -2030.85 179.518 28.8359 -1 -2027.27 172.638 28.8359 -1 -2033.39 175.956 28.8429
Код:
public OnGameModeInit() { for(new i = 0; i != sizeof(ARepairPickups); i++) ARepairPickups[i][PickupID] = -1; mysql_tquery(MySQL, "SELECT * FROM repair_pickups", "OnLoadRepairPickups"); }
Код:
forward OnLoadRepairPickups(playerid); public OnLoadRepairPickups() { new count; cache_get_row_count(count); // Get total rows for(new i; i < count; i++) { cache_get_value_name_int(0, "PickupID", ARepairPickups[i][PickupID]); cache_get_value_float(0, "pux",ARepairPickups[i][pux]); cache_get_value_float(0, "puy",ARepairPickups[i][puy]); cache_get_value_float(0, "puz",ARepairPickups[i][puz]); } return 1; } AddARepairPickups(Float:x, Float:y, Float:z) { for (new i; i < sizeof(ARepairPickups); i++) { if (ARepairPickups[i][PickupID] == -1) { ARepairPickups[i][PickupID] = CreatePickup(3096, 1, x, y, z, 0); ARepairPickups[i][pux] = x; ARepairPickups[i][puy] = y; ARepairPickups[i][puz] = z; Create3DTextLabel("{FFFF00}Type {00FF00}/repair {FFFF00}to repair your vehicle!", -1, x, y, z +0.5, 50.0, 0); CreateDynamicMapIcon(x, y, z, 27, 0, 0, 0, -1, 300.0); printf("PickupID: %d, PosX: %.4f, PosY: %.4f, PosZ: %.4f",ARepairPickups[i][PickupID],x,y,z); break; } } } bool:IsPlayerAtRepair(playerid) { for(new i; i != sizeof(ARepairPickups); i++) { if(ARepairPickups[i][PickupID] != -1) { printf("IsPlayerAtRepair: PosX: %.4f, PosY: %.4f, PosZ: %.4f",ARepairPickups[i][pux], ARepairPickups[i][puy], ARepairPickups[i][puz]); } if(ARepairPickups[i][PickupID] != -1 && IsPlayerInRangeOfPoint(playerid, 5.0, ARepairPickups[i][pux], ARepairPickups[i][puy], ARepairPickups[i][puz])) return true; } return false; } CMD:createrepair(playerid, params[]) { new Float:x, Float:y, Float:z; new query[128]; if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOUR_RED, "Administrator status required."); GetPlayerPos(playerid, x, y, z); AddARepairPickups(x, y, z); mysql_format(MySQL, query, 128, "INSERT INTO `repair_system` (`PickupID`, `pux`,`puy`,`puz`) VALUES (%d, %f, %f, %f)",ARepairPickups[playerid][PickupID], x, y, z); // Use %f specifier here, because we insert float for pux puy puz mysql_tquery(MySQL, query, "AddARepairPickups", "ffff", ARepairPickups[playerid][PickupID], x, y, z); // AddARepairPickups must be a public function return 1; }