SA-MP Forums Archive
Problem, with loading houses. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem, with loading houses. (/showthread.php?tid=462934)



Problem, with loading houses. - AA9 - 09.09.2013

Hello, i have a problem, with my house system. When i create house InGame, then it should use ReloadHouses() function.
(It destroys all houses 3D text labels and pickups). Next it should use LoadHouses() function, it loads all houses from MySQL database and once all houses are loaded, it starts loading them again. And it doesnt stop. I writed House system like Business system, and business system is correctly working. I have also readed MySQL debug file and there isnt any errors. Sorry, if my english is bad.


pawn Код:
stock LoadHouses()
{
for(new i = 1; i < MAX_HOUSES; i++)
    {
new query[600], savingstring[24], string[128];
format(query, sizeof(query), "SELECT * FROM housedata WHERE HouseID = %i", i);
mysql_query(query);
mysql_store_result();
while(mysql_fetch_row_format(query, "|"))
{
mysql_fetch_field_row(savingstring, "HouseID");hInfo[i][mID] = strval(savingstring);
mysql_fetch_field_row(savingstring, "Price");hInfo[i][Price] = strval(savingstring);
mysql_fetch_field_row(savingstring, "EnterX");hInfo[i][EnterX] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "EnterY");hInfo[i][EnterY] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "EnterZ");hInfo[i][EnterZ] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "ExitX");hInfo[i][ExitX] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "ExitY");hInfo[i][ExitY] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "ExitZ");hInfo[i][ExitZ] = floatstr(savingstring);
mysql_fetch_field_row(savingstring, "Interior");hInfo[i][mInterior] = strval(savingstring);
mysql_fetch_field_row(savingstring, "World");hInfo[i][World] = strval(savingstring);
mysql_fetch_field_row(savingstring, "Text");hInfo[i][Text] = savingstring;
mysql_fetch_field_row(savingstring, "Owner");hInfo[i][Owner] = savingstring;
mysql_fetch_field_row(savingstring, "Owned"); hInfo[i][Owned] = strval(savingstring);
mysql_fetch_field_row(savingstring, "Locked"); hInfo[i][Locked] = strval(savingstring);
}
mysql_free_result();
new HouName[24]; format(HouName, 24, "%s", hInfo[i][Text]);
strreplace(HouName, '_', ' ');
if(!strcmp(hInfo[i][Owner], "None", false)) format(string, sizeof(string), "[MЬЬA]\n%s\nHind: %i", HouName, hInfo[i][Price]);
else format(string, sizeof(string), "%s\n[Omanik]:%s", hInfo[i][Text], hInfo[i][Owner]);
hInfo[i][Label] = Create3DTextLabel(string, COLOR_LIGHTORANGE, hInfo[i][EnterX],hInfo[i][EnterY], hInfo[i][EnterZ], 35.0, 0, 1);
hInfo[i][Pickup] = CreatePickup(1273, 1, hInfo[i][EnterX], hInfo[i][EnterY], hInfo[i][EnterZ], 0);
printf("Maja ID %i laetud;  Aadress: %s", i, hInfo[i][Text]);
}
return 1;
}
stock ReloadHouses()
{
    for(new i = 1; i < MAX_HOUSES; i++)
    {
        Delete3DTextLabel(hInfo[i][Label]);
        DestroyPickup(hInfo[i][Pickup]);
    }
    LoadHouses();
    return 1;
}
CMD:teemaja(playerid, params[])
{
for(new i = 1; i < MAX_HOUSES; i++)
    {
new string[80];
if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid, V_PUNANE, NOTADMIN);
new maID, mHind, meX, meY, meZ, mint, mvw = random(9999), aadress[24],Float:fenX, Float:fenY, Float:fenZ, oname[24];
if(IsHouseCreated(maID)) return SendClientMessage(playerid, V_PUNANE, "Sellise ID-ga maja juba eksiteerib");
if(sscanf(params,"iifffis[24]",maID, mHind, meX, meY, meZ, mint, aadress)) return SendClientMessage(playerid, V_PUNANE, "KASUTA: /teemaja [ID][Hind][VдljumineX][VдljumineY][VдljumineZ][Interior][Firmanimi]");
GetPlayerName(playerid, oname, sizeof(oname));
GetPlayerPos(playerid, fenX, fenY, fenZ);
if(mint > 99) return SendClientMessage(playerid, V_PUNANE, "Maja interiццr vali valikus 1-99");
if(strlen(aadress) > 24) return SendClientMessage(playerid, V_PUNANE, "Maja aadress vali vahemikus 1-24 tдhemдrki");
format(string, sizeof(string), "[MЬЬA]\n%s\nHind:%i",aadress, mHind);
hInfo[i][Label] = Create3DTextLabel(string, COLOR_LIGHTORANGE,fenX,fenY, fenZ, 35.0, 0, 0);
hInfo[i][Pickup] = CreatePickup(1273,23, fenX, fenY, fenZ, -1);
hInfo[i][mID] = maID;
hInfo[i][Price] = mHind;
hInfo[i][EnterX] = fenX;
hInfo[i][EnterY] = fenY;
hInfo[i][EnterZ] = fenZ;
hInfo[i][ExitX] = meX;
hInfo[i][ExitY] = meY;
hInfo[i][ExitZ] = meZ;
hInfo[i][mInterior] = mint;
hInfo[i][World] = mvw;
hInfo[i][Text] = aadress;
new query[400];
format(query, sizeof(query), "INSERT INTO housedata (HouseID, Price, EnterX, EnterY, EnterZ, ExitX, ExitY, ExitZ, Interior, World, Text, Owner, Owned, Locked) VALUES(%i, %i, %f, %f, %f, %f, %f, %f, %i, %i, '%s', 'None', 0, 0)", maID, mHind, fenX, fenY, fenZ, meX, meY, meZ, mint, mvw, aadress);
mysql_query(query);
ReloadHouses();
}
return 1;
}



Re: Problem, with loading houses. - Emmet_ - 10.09.2013

pawn Код:
stock LoadHouses()
{
    new i, query[200], field[64], housename[24];
    mysql_query("SELECT * FROM `housedata`");
    mysql_store_result();

    while (mysql_retrieve_row())
    {
        mysql_fetch_field_row(field, "HouseID"); hInfo[i][mID] = strval(field);
        mysql_fetch_field_row(field, "Price"); hInfo[i][Price] = strval(field);
        mysql_fetch_field_row(field, "EnterX"); hInfo[i][EnterX] = floatstr(field);
        mysql_fetch_field_row(field, "EnterY"); hInfo[i][EnterY] = floatstr(field);
        mysql_fetch_field_row(field, "EnterZ"); hInfo[i][EnterZ] = floatstr(field);
        mysql_fetch_field_row(field, "ExitX"); hInfo[i][ExitX] = floatstr(field);
        mysql_fetch_field_row(field, "ExitY"); hInfo[i][ExitY] = floatstr(field);
        mysql_fetch_field_row(field, "ExitZ"); hInfo[i][ExitZ] = floatstr(field);
        mysql_fetch_field_row(field, "Interior"); hInfo[i][mInterior] = strval(field);
        mysql_fetch_field_row(field, "World"); hInfo[i][World] = strval(field);
        mysql_fetch_field_row(field, "Text"); format(hInfo[i][Text], 128, field);
        mysql_fetch_field_row(field, "Owner"); format(hInfo[i][Owner], 24, field);
        mysql_fetch_field_row(field, "Owned"); hInfo[i][Owned] = strval(field);
        mysql_fetch_field_row(field, "Locked"); hInfo[i][Locked] = strval(field);
        i++;
    }
    mysql_free_result();

    format(housename, 24, "%s", hInfo[i][Text]);
    strreplace(housename, '_', ' ');

    if(!strcmp(hInfo[i][Owner], "None", false)) format(query, sizeof(query), "[MЬЬA]\n%s\nHind: %i", housename, hInfo[i][Price]);
    else format(query, sizeof(query), "%s\n[Omanik]:%s", hInfo[i][Text], hInfo[i][Owner]);

    hInfo[i][Label] = Create3DTextLabel(string, COLOR_LIGHTORANGE, hInfo[i][EnterX],hInfo[i][EnterY], hInfo[i][EnterZ], 35.0, 0, 1);
    hInfo[i][Pickup] = CreatePickup(1273, 1, hInfo[i][EnterX], hInfo[i][EnterY], hInfo[i][EnterZ], 0);
    printf("Maja ID %i laetud;  Aadress: %s", i, hInfo[i][Text]);
    return 1;
}

stock ReloadHouses()
{
    for(new i = 1; i < MAX_HOUSES; i++)
    {
        Delete3DTextLabel(hInfo[i][Label]);
        DestroyPickup(hInfo[i][Pickup]);
    }
    LoadHouses();
    return 1;
}