23.01.2019, 19:10
Code:
CMD:createhouse(playerid, params[]) { new price, Float:x, Float:y, Float:z, query[800], str[350]; if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, COLOR_GREY, "Not authorized!"); if(sscanf(params, "d", price)) return SendClientMessage(playerid, COLOR_GREY, "Usage:{FFFFFF} /createhouse [price]"); new id=GetFreeHouseID(); GetPlayerPos(playerid, x, y, z); HouseInfo[id][hOutInterior] = GetPlayerInterior(playerid); HouseInfo[id][hOutWorld] = GetPlayerVirtualWorld(playerid); HouseInfo[id][hOutPos][0] = x; HouseInfo[id][hOutPos][1] = y; HouseInfo[id][hOutPos][2] = z; HouseInfo[id][hPrice] = price; HouseInfo[id][hID] = id; format(query, sizeof(query), "INSERT INTO `houses` (`Out_X`, `Out_Y`, `Out_Z`, `OutInt`, `OutWorld`, `Price`, `ID`) VALUES ('%f', '%f', '%f', '%i', '%i', '%i', '%i')", HouseInfo[id][hOutPos][0], HouseInfo[id][hOutPos][1], HouseInfo[id][hOutPos][2], HouseInfo[id][hOutInterior], HouseInfo[id][hOutWorld], HouseInfo[id][hPrice], id); mysql_function_query(dbhandle, query, true, "", ""); HouseInfo[id][hPickup] = CreatePickup(1273, 23, HouseInfo[id][hOutPos][0], HouseInfo[id][hOutPos][1], HouseInfo[id][hOutPos][2], -1); format(str, sizeof(str), "This house is for sell!\nPrice: %d\nType /buyhouse to buy it.\nType /enter to go inside.", HouseInfo[id][hPrice]); HouseInfo[id][hLabel] = CreateDynamic3DTextLabel(str ,COLOR_ORANGE, HouseInfo[id][hOutPos][0], HouseInfo[id][hOutPos][1], HouseInfo[id][hOutPos][2],30.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 7.0); format(str, sizeof(str), "You created a house at X: %f, Y: %f, Z: %f, for price of: %d: %d", x, y, z, price); SendClientMessage(playerid, COLOR_GREY, str); HouseInfo[id][hForSell] = 1; return 1; } forward LoadHouses(); public LoadHouses() { new str[250]; new loadstr[850]; new rows = cache_get_row_count(dbhandle); format(loadstr, sizeof(loadstr), "====================LOADING HOUSES===================="); printf(loadstr); for(new i = 1; i < rows && i < MAX_HOUSES; i ++) { cache_get_field_content(i, "Owner", HouseInfo[i][hOwner], dbhandle, MAX_PLAYER_NAME); HouseInfo[i][hID] = cache_get_field_content_int(i, "ID", dbhandle); HouseInfo[i][hOutPos][0] = cache_get_field_content_float(i, "Out_X", dbhandle); HouseInfo[i][hOutPos][1] = cache_get_field_content_float(i, "Out_Y", dbhandle); HouseInfo[i][hOutPos][2] = cache_get_field_content_float(i, "Out_Z", dbhandle); HouseInfo[i][hIntPos][0] = cache_get_field_content_float(i, "Int_X", dbhandle); HouseInfo[i][hIntPos][1] = cache_get_field_content_float(i, "Int_Y", dbhandle); HouseInfo[i][hIntPos][2] = cache_get_field_content_float(i, "Int_Z", dbhandle); HouseInfo[i][hOutInterior] = cache_get_field_content_int(i, "OutInt", dbhandle); HouseInfo[i][hOutWorld] = cache_get_field_content_int(i, "OutWorld", dbhandle); HouseInfo[i][hInsideInterior] = cache_get_field_content_int(i, "InsideInt", dbhandle); HouseInfo[i][hInsideWorld] = cache_get_field_content_int(i, "InsideWorld", dbhandle); HouseInfo[i][hLocked] = cache_get_field_content_int(i, "Locked", dbhandle); HouseInfo[i][hForSell] = cache_get_field_content_int(i, "ForSell", dbhandle); HouseInfo[i][hPrice] = cache_get_field_content_int(i, "Price", dbhandle); if(cache_get_field_content_int(i, "ForSell") == 0) { HouseInfo[i][hForSell] = 0; } if(cache_get_field_content_int(i, "Locked") == 1) { HouseInfo[i][hForSell] = 1; } if(HouseInfo[i][hForSell] == 1) { HouseInfo[i][hPickup] = CreatePickup(1273, 23, HouseInfo[i][hOutPos][0], HouseInfo[i][hOutPos][1], HouseInfo[i][hOutPos][2], -1); format(str, sizeof(str), "This house is for sell!\nPrice: %d\nType /buyhouse to buy it.\nType /enter to go inside.", HouseInfo[i][hPrice]); HouseInfo[i][hLabel] = CreateDynamic3DTextLabel(str ,COLOR_ORANGE, HouseInfo[i][hOutPos][0], HouseInfo[i][hOutPos][1], HouseInfo[i][hOutPos][2],30.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 7.0); } else { HouseInfo[i][hPickup] = CreatePickup(1273, 23, HouseInfo[i][hOutPos][0], HouseInfo[i][hOutPos][1], HouseInfo[i][hOutPos][2], -1); format(str, sizeof(str), "House\nOwner: %s\nTo enter inside type /enter.", HouseInfo[i][hOwner]); HouseInfo[i][hLabel] = CreateDynamic3DTextLabel(str ,COLOR_ORANGE, HouseInfo[i][hOutPos][0], HouseInfo[i][hOutPos][1], HouseInfo[i][hOutPos][2],30.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 7.0); } format(loadstr, sizeof(loadstr), "Loading house at %f %f %f[ID: %d]", HouseInfo[i][hOutPos][0], HouseInfo[i][hOutPos][1], HouseInfo[i][hOutPos][2], HouseInfo[i][hID]); printf(loadstr); } format(loadstr, sizeof(loadstr), "====================LOADED: %d HOUSES=================", rows); printf(loadstr); return 1; }
I create 10 houses, the last house should be ID 10, and it is, last house I created is ID 10. After GMX, that last spawned house [ID: 10] is now ID 1, and all other houses are 2,3,4,5..
Second problem:
I create 10 houses, I delete houseid 9, after GMX everything is mixed, it spawns houses from id 1 to id 8.
When I /createhouse, after the GMX, it creates house ID 10. After GMX, that house id 10 is deleted, does not even spawn.
If you have any clue and could help me, it'd be appreciated.
If you don't understand what I mean, I will explain more, just reply if you're willing to help.