Houses load from the data base - 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: Houses load from the data base (
/showthread.php?tid=665444)
Houses load from the data base -
bosmania - 04.04.2019
I have this in my gamemode wich i downloaded and i don't understand,why is theres a "h = i - 1",i mean "i" is the row,and at the same time the house number,like when "i" is 2,it takes the ID for example from the second row from the `houses` tabel in the database,and the second row is also the second house so what if it's scripted lile this
for(new i = 1; i <= housess; i++)
{
HouseInfo[i][hID] = cache_get_field_content_int(i, "ID"); Here it's getting the id from row "i",not row "h",and i dont understand why isnt this correct.
}
This is the part from the gamemode
for(new i = 1; i <= housess; i++)
{
new h = i - 1;
HouseInfo[i][hID] = cache_get_field_content_int(h, "ID");
}
Re: Houses load from the data base -
rockys - 04.04.2019
i = in game id
h = database id
h = i-1 because for() start from 1
Re: Houses load from the data base -
bosmania - 04.04.2019
Quote:
Originally Posted by rockys
i = in game id
h = database id
h = i-1 because for() start from 1
|
But the house id in the game also starts from 1
Re: Houses load from the data base -
Logic_ - 04.04.2019
Quote:
Originally Posted by rockys
i = in game id
h = database id
h = i-1 because for() start from 1
|
Don't help when you have no idea of what you are talking about.
To the original poster:
MySQL row IDs start from 0 so you have to loop from 0. You need to remove that code where you subtract, that's useless.