SA-MP Forums Archive
[HELP] House Load - 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: [HELP] House Load (/showthread.php?tid=500315)



[HELP] House Load - Luca12 - 12.03.2014

Hello I have house created in database and know I try everything to load houses but no sucess

so this on ongamemodeinit

pawn Код:
new rows,fields;
    cache_get_data(rows,fields,mysql);
    for(new i = 1; i <= rows; i++)
    {
        mysql_format(mysql,query,sizeof(query),"SELECT * FROM houses WHERE ID = '%d' LIMIT 1",i);
        mysql_tquery(mysql,query,"LoadHouses","i");
    }
and this is LoadHouses public

pawn Код:
LoadHouses(extraid,type);
public LoadHouses(extraid,type)
{
        new rows,fields;
        cache_get_data(rows,fields,mysql);
        switch(type)
        {
                case THREAD_UCITAJKUCU:
                {
                        if(IsPlayerConnected(extraid))
                        {
                                new i = 0;
                                while( i < rows)
                                {
                                        if(i >= MAX_KUCA)
                                        break;
                                        new result[128];
                                        cache_get_field_content(i,"ID",result,mysql); KucaInfo[extraid][KucaID] = strval(result);
                                        cache_get_field_content(i,"UlazX",result,mysql); KucaInfo[extraid][hUlazX] = floatstr(result);
                                        cache_get_field_content(i,"UlazY",result,mysql); KucaInfo[extraid][hUlazY] = floatstr(result);
                                        cache_get_field_content(i,"UlazZ",result,mysql); KucaInfo[extraid][hUlazZ] = floatstr(result);
                                        cache_get_field_content(i,"IzlazX",result,mysql); KucaInfo[extraid][hIzlazX] = floatstr(result);
                                        cache_get_field_content(i,"IzlazY",result,mysql); KucaInfo[extraid][hIzlazY] = floatstr(result);
                                        cache_get_field_content(i,"IzlazZ",result,mysql); KucaInfo[extraid][hIzlazZ] = floatstr(result);
                                        cache_get_field_content(i,"Tip",result,mysql); KucaInfo[extraid][hTip] = strval(result);
                                        cache_get_field_content(i,"Level",result,mysql); KucaInfo[extraid][hLevel] = strval(result);
                                        cache_get_field_content(i,"BrojSoba",result,mysql); KucaInfo[extraid][hRooms] = strval(result);
                                        cache_get_field_content(i,"Interior",result,mysql); KucaInfo[extraid][hInt] = strval(result);
                                        cache_get_field_content(i,"hHel",result,mysql); KucaInfo[extraid][hHel] = strval(result);
                                        cache_get_field_content(i,"hArm",result,mysql); KucaInfo[extraid][hArm] = strval(result);
                                        cache_get_field_content(i,"ImaVlasnika",result,mysql); KucaInfo[extraid][hImaVlasnika] = strval(result);
                                        cache_get_field_content(i,"hWorld",result,mysql); KucaInfo[extraid][hWorld] = strval(result);
                                        cache_get_field_content(i,"Cijena",result,mysql); KucaInfo[extraid][hCijena] = strval(result);
                                        cache_get_field_content(i,"Opis",KucaInfo[extraid][hOpis],mysql,128);
                                        cache_get_field_content(i,"Vlasnik",KucaInfo[extraid][hVlasnik],mysql,128);
                                        cache_get_field_content(i,"DostupnoZaRent",result,mysql); KucaInfo[extraid][hRentabil] = strval(result);
                                        cache_get_field_content(i,"Rent",result,mysql); KucaInfo[extraid][hRent] = strval(result);
                                        cache_get_field_content(i,"Zakljucano",result,mysql); KucaInfo[extraid][hLock] = strval(result);
                                        cache_get_field_content(i,"Adresa",KucaInfo[extraid][hAdresa],mysql,128);
                                        cache_get_field_content(i,"hSef",result,mysql); KucaInfo[extraid][hSef] = strval(result);
                                        cache_get_field_content(i,"hDroga",result,mysql); KucaInfo[extraid][hDroga] = strval(result);
                                        cache_get_field_content(i,"hMats",result,mysql); KucaInfo[extraid][hMats] = strval(result);
                                        cache_get_field_content(i,"Oruzje1",result,mysql); KucaInfo[extraid][Oruzje1] = strval(result);
                                        cache_get_field_content(i,"Municija1",result,mysql); KucaInfo[extraid][Municija1] = strval(result);
                                        cache_get_field_content(i,"Oruzje2",result,mysql); KucaInfo[extraid][Oruzje2] = strval(result);
                                        cache_get_field_content(i,"Municija2",result,mysql); KucaInfo[extraid][Municija2] = strval(result);
                                        cache_get_field_content(i,"Oruzje3",result,mysql); KucaInfo[extraid][Oruzje3] = strval(result);
                                        cache_get_field_content(i,"Municija3",result,mysql); KucaInfo[extraid][Municija3] = strval(result);
                                        new str[800];
                                        if(KucaInfo[extraid][hImaVlasnika] == 0)
                                        {
                                            format(str,sizeof(str),"{0ed400}Na Prodaju\n{0ed400}Opis: {FFFFFF}%s\n{0ed400}Level: {FFFFFF}%d\n{0ed400}Adresa: {FFFFFF}%s\n{0ed400}Cijena: {FFFFFF}%d$",KucaInfo[extraid][hOpis],KucaInfo[extraid][hLevel],KucaInfo[extraid][hAdresa],KucaInfo[extraid][hCijena]);
                                            UpdateDynamic3DTextLabelText(KucaLabel[extraid],0x00FFFFFF,str);
                                            DestroyDynamicPickup(KucaPickup[extraid]);
                                            KucaPickup[extraid] = CreateDynamicPickup(1273,1,KucaInfo[extraid][hUlazX],KucaInfo[extraid][hUlazY],KucaInfo[extraid][hUlazZ]);
                                        }
                                        if(KucaInfo[extraid][hImaVlasnika] == 1)
                                        {
                                            if(KucaInfo[extraid][hRentabil] == 0)
                                            {
                                                format(str,800,"{0ed400}Vlasnik Kuce: {FFFFFF}%s\n{0ed400}Opis: {FFFFFF}%s\n{0ed400}Level: {FFFFFF}%d\n{0ed400}Adresa: {FFFFFF}%s",KucaInfo[extraid][hVlasnik],KucaInfo[extraid][hOpis],KucaInfo[extraid][hLevel],KucaInfo[extraid][hAdresa]);
                                            }
                                            else if(KucaInfo[extraid][hRentabil] == 1)
                                            {
                                                format(str,800,"{0ed400}Vlasnik Kuce: {FFFFFF}%s\n{0ed400}Opis: {FFFFFF}%s\n{0ed400}Level: {FFFFFF}%d\n{0ed400}Adresa: {FFFFFF}%s\n{0ed400}Rent: {FFFFFF}%d$\n{0ed400}Najam: {FFFFFF}/rentroom",KucaInfo[extraid][hVlasnik],KucaInfo[extraid][hOpis],KucaInfo[extraid][hLevel],KucaInfo[extraid][hAdresa],KucaInfo[extraid][hRent]);
                                            }
                                            UpdateDynamic3DTextLabelText(KucaLabel[extraid],0x00FF00AA,str);
                                            DestroyDynamicPickup(KucaPickup[extraid]);
                                            KucaPickup[extraid] = CreateDynamicPickup(1239,1,KucaInfo[extraid][hUlazX],KucaInfo[extraid][hUlazY],KucaInfo[extraid][hUlazZ]);
                    }
                }
            }
        }
    }
        return 1;
}



Re: [HELP] House Load - shulk - 12.03.2014

Ovo na drugciji nacin uradi pogledaj moje postove kako bi vidio moju temu za pomoć.


Re: [HELP] House Load - CuervO - 12.03.2014

1) Why limiting the result to 1? If the ID's are non repeated (or auto incremental) there's no point in limiting it since there will only be one unique key.

2)
Код:
mysql_tquery(mysql,query,"LoadHouses","i");
yet the function has two parameters
Код:
public LoadHouses(extraid,type)
3) In the while loop you have to increase the value of i each time it's run (i++) otherwise you'll get an infinite loop loading only the row 0.


Re: [HELP] House Load - Luca12 - 12.03.2014

So what can I do know to work this I use auto increment


Re: [HELP] House Load - CuervO - 12.03.2014

I already told you what's wrong, it has nothing to do with the limit as that was just a tip, check the other two points.

Quote:
Originally Posted by CuervO
Посмотреть сообщение
2)
Код:
mysql_tquery(mysql,query,"LoadHouses","i");
yet the function has two parameters
Код:
public LoadHouses(extraid,type)
3) In the while loop you have to increase the value of i each time it's run (i++) otherwise you'll get an infinite loop loading only the row 0.



Re: [HELP] House Load - Knappen - 12.03.2014

Have you considered using ORM? Might be easier if you are having trouble understanding the cache functions. There's a great tutorial on the forum here.


Re: [HELP] House Load - Luca12 - 12.03.2014

I understand cache and read tutorials Cuervo I was put two ii and still nothing it says there's no active cache


Re: [HELP] House Load - Luca12 - 13.03.2014

anyone?thanks