25.03.2019, 16:11
Quote:
Код:
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(i, "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); for (new i; i < sizeof(ARepairPickups); i++) mysql_format(MySQL, query, 128, "INSERT INTO `repair_system` (`PickupID`, `pux`,`puy`,`puz`) VALUES (%d, %f, %f, %f)",ARepairPickups[i][PickupID], x, y, z); // Use %f specifier here, because we insert float for pux puy puz mysql_tquery(MySQL, query, "AddARepairPickups", "dfff", ARepairPickups[playerid][PickupID], x, y, z); // AddARepairPickups must be a public function return 1; } |
https://sampwiki.blast.hk/wiki/MySQL/R40