Houses load from the data base
#1

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");

}
Reply
#2

i = in game id
h = database id

h = i-1 because for() start from 1
Reply
#3

Quote:
Originally Posted by rockys
View Post
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
Reply
#4

Quote:
Originally Posted by rockys
View Post
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)