24.07.2013, 18:36
I'm trying to create house system with mysql, but I don't know how to load and create every house from mysql table.
Here's my try, and that for() loop makes my server laggy
Here's my try, and that for() loop makes my server laggy
Код:
stock LoadHouses(playerid) { new query[300], pname[24],savingstring[20] ,labelstring[100]; new HousePrice,id = HouseCount; new world; new Float:x,Float:y,Float:z; for(new i = 0; i < MAX_HOUSES;i++) { GetPlayerName(playerid, pname, 24); format(query, sizeof(query), "SELECT * FROM housedata WHERE id = '%d'", i); mysql_query(query); mysql_store_result(); while(mysql_fetch_row_format(query,"|")) { mysql_fetch_field_row(savingstring, "price"); HousePrice = strval(savingstring); mysql_fetch_field_row(savingstring, "id"); HouseCount = strval(savingstring); mysql_fetch_field_row(savingstring, "world"); world = strval(savingstring); mysql_fetch_field_row(savingstring, "xpos"); x = strval(savingstring); mysql_fetch_field_row(savingstring, "ypos"); y = strval(savingstring); mysql_fetch_field_row(savingstring, "zpos"); z = strval(savingstring); format(labelstring,sizeof(labelstring),"House: %i \nPrice: %i",HouseCount, HousePrice); HInfo[id][HouseLabel] = Create3DTextLabel(labelstring,0xFF0000FF,x,y,z,25.0,world); } format(labelstring,sizeof(labelstring),"House: %i \nPrice: %i",HouseCount, HousePrice); HInfo[id][HouseLabel] = Create3DTextLabel(labelstring,0xFF0000FF,x,y,z,25.0,world); } mysql_free_result(); return 1; }