24.05.2015, 11:02
Just wondering, is this proper way to load houses from mysql db, since i'm the only one testing the server i can't really test it, so will this load houses propertly, every house, owned or not, i've started learning mysql and this is the only thing that comes into my mind when it comes to loading.. Language is serbian, if you need me to translate anything to english just tell me and i will..
So this is under Ongamemodeinit
This is function ucitajkuce
THis is Threaded Query:
Thanks in advanced, if it's not correct please tell me
So this is under Ongamemodeinit
pawn Код:
UcitajKuce();
pawn Код:
stock UcitajKuce()
{
new szQuery[2048];
format(szQuery, sizeof(szQuery), "SELECT * FROM `kuce`");
mysql_function_query(konekt, szQuery, true, "OnQueryFinish", "i", THREAD_UCITAJKUCE);
return 1;
}
pawn Код:
case THREAD_UCITAJKUCE:
{
if(szRows)
{
new temp[130];
for(new i = 0; i < szRows; i++)
{
new hID;
cache_get_field_content(i, "ID", temp);
hID = strval(temp);
cache_get_field_content(i, "ImaVlasnika", temp);
HInfo[hID][ImaVlasnika] = strval(temp);
cache_get_field_content(i, "Vlasnik", temp);
format(HInfo[hID][Vlasnik], 50, "%s", temp);
cache_get_field_content(i, "Vrsta", temp);
format(HInfo[hID][Vrsta], 50, "%s", temp);
cache_get_field_content(i, "Adresa", temp);
format(HInfo[hID][Adresa], 32, "%s", temp);
cache_get_field_content(i, "UlazX", temp);
HInfo[hID][UlazX] = floatstr(temp);
cache_get_field_content(i, "UlazY", temp);
HInfo[hID][UlazY] = floatstr(temp);
cache_get_field_content(i, "UlazZ", temp);
HInfo[hID][UlazZ] = floatstr(temp);
cache_get_field_content(i, "UlazA", temp);
HInfo[hID][UlazA] = floatstr(temp);
cache_get_field_content(i, "IzlazX", temp);
HInfo[hID][IzlazX] = floatstr(temp);
cache_get_field_content(i, "IzlazY", temp);
HInfo[hID][IzlazY] = floatstr(temp);
cache_get_field_content(i, "IzlazZ", temp);
HInfo[hID][IzlazZ] = floatstr(temp);
cache_get_field_content(i, "IzlazA", temp);
HInfo[hID][IzlazA] = floatstr(temp);
cache_get_field_content(i, "DostupanRent", temp);
HInfo[hID][DostupanRent] = strval(temp);
cache_get_field_content(i, "RentCena", temp);
HInfo[hID][RentCena] = strval(temp);
cache_get_field_content(i, "Droga", temp);
HInfo[hID][Droga] = strval(temp);
cache_get_field_content(i, "Mats", temp);
HInfo[hID][Mats] = strval(temp);
cache_get_field_content(i, "Zakljucano", temp);
HInfo[hID][Zakljucano] = strval(temp);
cache_get_field_content(i, "Cena", temp);
HInfo[hID][Cena] = strval(temp);
cache_get_field_content(i, "VW", temp);
HInfo[hID][VW] = strval(temp);
cache_get_field_content(i, "Interior", temp);
HInfo[hID][Interior] = strval(temp);
cache_get_field_content(i, "kLevel", temp);
HInfo[hID][Level] = strval(temp);
cache_get_field_content(i, "Novac", temp);
HInfo[hID][Novac] = strval(temp);
SpawnedHouses++;
new str[500];
switch(HInfo[hID][ImaVlasnika])
{
case 0:
{
format(str, sizeof(str), "{F3FF02}Kuca na prodaju\n{FFFFFF}Vrsta: {0049FF}%s\n{FFFFFF}Cena: {0049FF}$%d\n{FFFFFF}Level: {0049FF}%d\n{FFFFFF}Adresa: {0049FF}%s", HInfo[hID][Vrsta], HInfo[hID][Cena], HInfo[hID][Level], HInfo[hID][Adresa]);
}
case 1:
{
if(HInfo[hID][DostupanRent] == 0)
{
format(str, sizeof(str), "{FFFFFF}Vlasnik Kuce: {0049FF}%s\n{FFFFFF}Vrsta: {0049FF}%s\n{FFFFFF}Level: {0049FF}%d\n{FFFFFF}Adresa: {0049FF}%s", HInfo[hID][Vlasnik], HInfo[hID][Vrsta], HInfo[hID][Level], HInfo[hID][Adresa]);
}
else if(HInfo[hID][DostupanRent] == 1)
{
format(str, sizeof(str), "{FFFFFF}Vlasnik Kuce: {0049FF}%s\n{FFFFFF}Vrsta: {0049FF}%s\n{FFFFFF}Level: {0049FF}%d\n{FFFFFF}Cena Renta: {0049FF}$%d\n{FFFFFF}Adresa: {0049FF}%s", HInfo[hID][Vlasnik], HInfo[hID][Vrsta], HInfo[hID][Level], HInfo[hID][RentCena], HInfo[hID][Adresa]);
}
}
}
KucaLabel[hID] = Create3DTextLabel(str, 0x00FF00AA, HInfo[hID][UlazX], HInfo[hID][UlazY], HInfo[hID][UlazZ], 10, 0, 1);
KucaPickup[hID] = CreatePickup(1273, 1, HInfo[hID][UlazX], HInfo[hID][UlazY], HInfo[hID][UlazZ]);
}
printf("Roleplay Factory - Server loaded %d houses", SpawnedHouses);
}
}
}