16.09.2013, 09:46
Hello. There's one more bug issue in my house script. All houses work even when I restart the game mode unless I delete a house, then the rest don't work once the game mode has restarted (weird as hell). I've looked through my code like a thousand times and cannot find out why.
/deletehouse command:
This stock somehow may be the problem. None of the variables are fetched from the database after the /deletehouse command is used, but only after the server is restarted.
I would highly appreciate it if someone could clear my frustration, the help will make my house script complete once and for all
/deletehouse command:
pawn Код:
CMD:deletehouse(playerid, params[])
{
new string[256], query[1000], houseid;
if(sscanf(params, "i", houseid)) return SendClientMessage(playerid, -1, ""Grey"Syntax"White": /deletehouse [house id].");
if(houseid < 1)
{
SendClientMessage(playerid, -1, ""Red"Error"White": The house ID must be over 1.");
return 1;
}
if(houseid != HouseInfo[houseid][hID])
{
SendClientMessage(playerid, -1, ""Red"Error"White": That house ID does not exist.");
return 1;
}
DestroyDynamicPickup(HouseInfo[houseid][hPickUp]);
DestroyDynamic3DTextLabel(HouseInfo[houseid][hText]);
format(query, sizeof(query), "DELETE FROM `houses` WHERE ID='%d'", houseid);
mysql_query(query);
format(string, sizeof(string), ""Green"Notice"White": You have deleted house ID %d.", houseid);
SendClientMessage(playerid, -1, string);
LoadHouses();
return 1;
}
pawn Код:
stock LoadHouses()
{
new query[1500], savingstring[20], string[256];
new houseid = 1;
mysql_query("SELECT * FROM `houses`");
mysql_store_result();
while(mysql_fetch_row_format(query,"|"))
{
mysql_fetch_field_row(savingstring, "ID"); HouseInfo[houseid][hID] = strval(savingstring);
mysql_fetch_field_row(savingstring, "Address"); format(HouseInfo[houseid][hAddress], 100, "%s", savingstring);
mysql_fetch_field_row(savingstring, "Owner"); format(HouseInfo[houseid][hOwner], MAX_PLAYER_NAME, "%s", savingstring);
mysql_fetch_field_row(savingstring, "Owned"); HouseInfo[houseid][hOwned] = strval(savingstring);
mysql_fetch_field_row(savingstring, "Price"); HouseInfo[houseid][hPrice] = strval(savingstring);
mysql_fetch_field_row(savingstring, "X"); HouseInfo[houseid][hX] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "Y"); HouseInfo[houseid][hY] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "Z"); HouseInfo[houseid][hZ] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "EnterX"); HouseInfo[houseid][hEnterX] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "EnterY"); HouseInfo[houseid][hEnterY] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "EnterZ"); HouseInfo[houseid][hEnterZ] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "EnterA"); HouseInfo[houseid][hEnterA] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "ExitX"); HouseInfo[houseid][hExitX] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "ExitY"); HouseInfo[houseid][hExitY] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "ExitZ"); HouseInfo[houseid][hExitZ] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "ExitA"); HouseInfo[houseid][hExitA] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "Interior"); HouseInfo[houseid][hInterior] = strval(savingstring);
mysql_fetch_field_row(savingstring, "VirtualWorld"); HouseInfo[houseid][hVirtualWorld] = strval(savingstring);
mysql_fetch_field_row(savingstring, "Type"); HouseInfo[houseid][hType] = strval(savingstring);
HouseInfo[houseid][hPickUp] = CreateDynamicPickup(1273, 1, HouseInfo[houseid][hX], HouseInfo[houseid][hY], HouseInfo[houseid][hZ], 0);
format(string, sizeof(string), "ID: %d\n"Fuschia"Address"White": %s\n"Fuschia"Owner"White": %s\n"Fuschia"Price"White": $%d", HouseInfo[houseid][hID], HouseInfo[houseid][hAddress], HouseInfo[houseid][hOwner], HouseInfo[houseid][hPrice]);
HouseInfo[houseid][hText] = CreateDynamic3DTextLabel(string, -1, HouseInfo[houseid][hX], HouseInfo[houseid][hY], HouseInfo[houseid][hZ], 20.0);
houseid++;
}
printf("All houses have been successfully loaded.");
mysql_free_result();
return 1;
}

