28.11.2015, 16:16
Hey,
I've been recently re-scripting my house system as there were many bugs in the previous system. I have came across one bug so far. The problem is, when you create a house (/createhouse) the House ID's get messed up and the house ID will just show as 0 on the house dialog instead of its usual number. And, when you restart the server, the house which had the problem will go back to normal. So I'm assuming there is something wrong with the /createhouse command.
Here is the loadhouse function
Please help me. Thanks
I've been recently re-scripting my house system as there were many bugs in the previous system. I have came across one bug so far. The problem is, when you create a house (/createhouse) the House ID's get messed up and the house ID will just show as 0 on the house dialog instead of its usual number. And, when you restart the server, the house which had the problem will go back to normal. So I'm assuming there is something wrong with the /createhouse command.
Код:
CMD:createhouse(playerid,params[]) { if( pInfo[playerid][pAdmin] < 6 ) return PlayerIsNotAdmin(playerid); new price, interior, Float:x, Float:y, Float:z, id = Iter_Free(Houses); if( sscanf(params, "ii", price, interior ) ) return SendUsageError( playerid, "/createhouse [Price] [Interior]" ); if( interior >= 10 || interior <= 0 ) return SendClientMessage( playerid, RED, "ERROR: {FFFFFF}Interior ID's range from 1 - 9"); if( Iter_Contains(Houses, MAX_HOUSES-1) ) return Error(playerid, "Max House Limit has been exceeded (500)"); GetPlayerPos(playerid, x, y, z); //=============================[Lets set it up]============================= format(hInfo[id][Owner], MAX_PLAYER_NAME, "None"); hInfo[id][Locked] = 0; hInfo[id][World] = id; hInfo[id][InteriorID] = interior; hInfo[id][Price] = price; hInfo[id][OX] = x; hInfo[id][OY] = y; hInfo[id][OZ] = z; hInfo[id][Label] = CreateDynamic3DTextLabel("This House is on Sale\n{FFFFFF}Press [F] to buy", 0xFF9900FF, hInfo[id][OX], hInfo[id][OY], hInfo[id][OZ]+0.5, 36.0, .testlos = 1); hInfo[id][Icon] = CreateDynamicMapIcon(hInfo[id][OX], hInfo[id][OY], hInfo[id][OZ], 31, -1); hInfo[id][EnterPickup] = CreateDynamicPickup(1273, 23, hInfo[id][OX], hInfo[id][OY], hInfo[id][OZ], -1, -1, -1, 36.0); new query[500]; mysql_format(mysql, query, sizeof(query), "INSERT INTO `"HouseTable"` (`ID`, `Owner`, `Owned`, `Locked`, `InteriorID`, `World`, `Price`, `OX`, `OY`, `OZ`) VALUES('%i', '%s', '%i', '%i', '%i', '%i', '%i', '%f', '%f', '%f')", hInfo[id][HID], hInfo[id][Owner], hInfo[id][Owned], hInfo[id][Locked], hInfo[id][InteriorID], hInfo[id][World], hInfo[id][Price], hInfo[id][OX], hInfo[id][OY], hInfo[id][OZ]); mysql_tquery(mysql, query, "", ""); SendClientMessage(playerid, INFO, "[HOUSE] You have successfully created a house"); Iter_Add(Houses, id); return 1; }
Код:
forward OnLoadHouses(); public OnLoadHouses() { new i, loaded; new rows = cache_num_rows(); if(rows) { while(loaded < rows) { i = cache_get_field_content_int(loaded, "ID"); cache_get_field_content(loaded, "Owner", hInfo[i][Owner], mysql, 128); hInfo[i][Owned] = cache_get_field_content_int(loaded, "Owned"); hInfo[i][Locked] = cache_get_field_content_int(loaded, "Locked"); hInfo[i][Price] = cache_get_field_content_int(loaded, "Price"); hInfo[i][OX] = cache_get_field_content_float(loaded, "OX"); hInfo[i][OY] = cache_get_field_content_float(loaded, "OY"); hInfo[i][OZ] = cache_get_field_content_float(loaded, "OZ"); hInfo[i][World] = cache_get_field_content_int(loaded, "World"); hInfo[i][OnSale] = cache_get_field_content_int(loaded, "OnSale"); hInfo[i][InteriorID] = cache_get_field_content_int(loaded, "InteriorID"); new lString[500]; if(hInfo[i][OnSale] == 0 ) { switch(hInfo[i][Owned]) { case 0: { hInfo[i][Label] = CreateDynamic3DTextLabel("This House is on Sale\n{FFFFFF}Press [F] to Buy", 0xFF9900FF, hInfo[i][OX], hInfo[i][OY], hInfo[i][OZ]+0.5, 36.0, .testlos = 1); hInfo[i][Icon] = CreateDynamicMapIcon(hInfo[i][OX], hInfo[i][OY], hInfo[i][OZ], 31, -1); hInfo[i][EnterPickup] = CreateDynamicPickup(1273, 23, hInfo[i][OX], hInfo[i][OY], hInfo[i][OZ], -1, -1, -1, 36.0); loaded++; Iter_Add(Houses, loaded); } case 1: { switch(hInfo[i][Locked]) { case 0: { format(lString, sizeof(lString), "%s's House\n{FFFFFF}Press [F] to Enter", hInfo[i][Owner]); hInfo[i][Label] = CreateDynamic3DTextLabel(lString, 0xFF9900FF, hInfo[i][OX], hInfo[i][OY], hInfo[i][OZ]+0.5, 36.0, .testlos = 1); hInfo[i][EnterPickup] = CreateDynamicPickup(1273, 23, hInfo[i][OX],hInfo[i][OY], hInfo[i][OZ], -1, -1, -1, 36.0); } case 1: { format(lString, sizeof(lString), "%s's House\n{E00B0B}Locked\n{FFFFFF}Press [F] to Enter", hInfo[i][Owner]); hInfo[i][Label] = CreateDynamic3DTextLabel(lString, 0xFF9900FF, hInfo[i][OX], hInfo[i][OY], hInfo[i][OZ]+0.5, 36.0, .testlos = 1); hInfo[i][EnterPickup] = CreateDynamicPickup(1273, 23, hInfo[i][OX],hInfo[i][OY], hInfo[i][OZ], -1, -1, -1, 36.0); } } loaded++; Iter_Add(Houses, loaded); } } } if(hInfo[i][OnSale] == 1) { format(lString, sizeof(lString),"House Owned: Yes\nHouse Owner: %s\nHouse Price: $%i\nHouse On Sale: Yes", hInfo[i][Owner], hInfo[i][Price]); hInfo[i][Label] = CreateDynamic3DTextLabel(lString, 0xD65418FF, hInfo[i][OX], hInfo[i][OY], hInfo[i][OZ]+0.5, 36.0, .testlos = 1); hInfo[i][Icon] = CreateDynamicMapIcon(hInfo[i][OX], hInfo[i][OY], hInfo[i][OZ], 32, -1); hInfo[i][EnterPickup] = CreateDynamicPickup(1273, 23, hInfo[i][OX],hInfo[i][OY], hInfo[i][OZ], -1, -1, -1, 36.0); loaded++; Iter_Add(Houses, loaded); } } } if(loaded > 1) printf("[House System] %i houses were created...", loaded); return 1; }