2 weeks and still can't find a solution[REP][MYSQL]
#1

I tried everything but can't find a solution here is whole information of my house system.
How my system works.
1. /createhouse
2.A dialog with info is shown(Buttons : Ok,Cancel)
3: (If you press Ok)It tells you to Press n at the desired Exterior X,Y,Z
4.Then it tells you that it saves and press again n at Desired Interior X,Y,Z(i have some interiors already)
5.A dialog input style asks you to set virtualworld,then interiorid,then price
6.FINISHED(calls from script createhouse function)
7.Spawning pickup and textdraw
8./buyhouse
9.Asks you to put housename
10.Finished(calls buyhouse function)
BUT
1.You buyhouse doesn't update pickup
2.You createhouse 2 and when you try to buyhouse it says it is already bought
[b]Also before changing 1,2 things i noticed that i could buy correctly 2 houses but couldnt enter previous house but only the last one i buyed(for example if i buy 3 houses i can enter 3rd house but not other 2.)

PROBLEM NOTICED
It updates mysql house id 0 even if it doesnt exist because when i create a house it starts from HOUSE ID 1

CODE:
1.createhouse command(works correctly)
PHP код:
    CMD:createhouse(playerid,params[])
    {
        if( 
pinfo[playerid][ Admin] < 5) return 0;
        
ShowPlayerDialog(playerid,DIALOG_CHOUSE1,DIALOG_STYLE_MSGBOX"House Creator","Welcome to House Creator. From here you can create the houses you want by following 3 steps!\n"COL_RED"1."COL_WHITE"Choose Enter X,Y,Z\n"COL_RED"2."COL_WHITE"Choose Exit X.Y.Z\n"COL_RED"3."COL_WHITE"Set Virtual World, Interior and Price!","Continue","Cancel");
        return 
1;
    } 
2.(On dialogresponse)(works correctly)[calls createhouse function inside]
PHP код:
    case DIALOG_CHOUSE1:
        {
            if(!
response)
            {
                
SendClientMessage(playeridCOLOR_RED,"SERVER: You Choose not to create a house!");
            }
            else
            {
                
SendClientMessage(playerid, -1," "COL_GREEN"HOUSE CREATOR"COL_WHITE": Choose enter X,Y,Z coordinates and press "COL_YELLOW"N"COL_WHITE" when you decide!");
                
hcreating[playerid] = 1;
            }
        }
        case 
DIALOG_CHOUSE2:
        {
            if(
response)
            {
                new 
string[240];
                new 
hid;
                if(!
IsNumeric(inputtext)) return ShowPlayerDialog(playerid,DIALOG_CHOUSE2,DIALOG_STYLE_INPUT,"House Creator","ERROR : You must type an ID(Number)!","Select","");
                
format(string,sizeof(string),"You have choose EnterX: %f, EnterY: %f, EnterZ: %f\nExitX: %f, ExitY: %f, ExitZ: %f\nInteriorID: %d Please now Set house Virtual World",HouseInfo[hid][XEnt],HouseInfo[hid][YEnt],HouseInfo[hid][ZEnt],HouseInfo[hid][XExit],HouseInfo[hid][YExit],HouseInfo[hid][ZExit],inputtext);
                
ShowPlayerDialog(playeridDIALOG_CHOUSE3,DIALOG_STYLE_INPUT,"House Creator"string,"Select","");                
                
HouseInfo[hid][HInterior] = strval(inputtext);
            }
        }
        case 
DIALOG_CHOUSE3:
        {
            if(
response)
            {
                new 
string[240];
                new 
hid;
                if(!
IsNumeric(inputtext)) return ShowPlayerDialog(playerid,DIALOG_CHOUSE2,DIALOG_STYLE_INPUT,"House Creator","ERROR : You must type an ID(Number)!","Select","");
                
format(string,sizeof(string),"You have choose EnterX: %f, EnterY: %f, EnterZ: %f\n ExitX: %f, ExitY: %f, ExitZ: %f\nInteriorID: %d Virtual World: %d\n Please now set a price for the house!",HouseInfo[hid][XEnt],HouseInfo[hid][YEnt],HouseInfo[hid][ZEnt],HouseInfo[hid][XExit],HouseInfo[hid][YExit],HouseInfo[hid][ZExit],HouseInfo[hid][HInterior],inputtext);
                
HouseInfo[hid][HVirtualWorld] = strval(inputtext);
                
ShowPlayerDialog(playeridDIALOG_CHOUSE4,DIALOG_STYLE_INPUT,"House Creator"string,"Select","");                
            }
        }
        case 
DIALOG_CHOUSE4:
        {
            if(
response)
            {
                new 
string[240];
                new 
hid;
                if(!
IsNumeric(inputtext)) return ShowPlayerDialog(playerid,DIALOG_CHOUSE2,DIALOG_STYLE_INPUT,"House Creator","ERROR : You must type an ID(Number)!","Select","");
                
format(string,sizeof(string),"You have choose EnterX: %f, EnterY: %f, EnterZ: %f, ExitX: %f, ExitY: %f, ExitZ: %f, InteriorID: %d Virtual World: %d\n Price: %d. You have created the house!",HouseInfo[hid][XEnt],HouseInfo[hid][YEnt],HouseInfo[hid][ZEnt],HouseInfo[hid][XExit],HouseInfo[hid][YExit],HouseInfo[hid][ZExit],HouseInfo[hid][HInterior],HouseInfo[hid][HPrice],inputtext);
                
HouseInfo[hid][HPrice] = strval(inputtext);
                
ShowPlayerDialog(playeridDIALOG_CHOUSE5,DIALOG_STYLE_MSGBOX,"House Creator"string,"End","");                
            
            }
        }
        case 
DIALOG_CHOUSE5:
        {
            if(
response)
            {
                new 
hid;
                
CreateHouse(HouseInfo[hid][XEnt],HouseInfo[hid][YEnt],HouseInfo[hid][ZEnt],HouseInfo[hid][XExit],HouseInfo[hid][YExit],HouseInfo[hid][ZExit],HouseInfo[hid][HVirtualWorld],HouseInfo[hid][HInterior],HouseInfo[hid][HPrice]);
                
printf("ENTER X: %f Y: %f Z: %f EXIT X: %f Y: %f Z: %f vw: %d INTID: %d PRICE : %d",HouseInfo[hid][XEnt],HouseInfo[hid][YEnt],HouseInfo[hid][ZEnt],HouseInfo[hid][XExit],HouseInfo[hid][YExit],HouseInfo[hid][ZExit],HouseInfo[hid][HVirtualWorld],HouseInfo[hid][HInterior],HouseInfo[hid][HPrice]);
            }
        } 
3.createhouse function
PHP код:
function CreateHouse(Float:Xen,Float:Yen,Float:Zen,Float:Xex,Float:Yex,Float:Zex,virtualworld,interiorid,price)
{
        static 
hCount;
    new 
hid hCounthCount += 1;
    new 
string[100];
    new 
query[350];
    
hid += 1;
    
HouseInfo[hid][XEnt] = Xen;
    
HouseInfo[hid][YEnt] = Yen;
    
HouseInfo[hid][ZEnt] = Zen;
    
HouseInfo[hid][XExit] = Xex;
    
HouseInfo[hid][YExit] = Yex;
    
HouseInfo[hid][ZExit] = Zex;
    
HouseInfo[hid][HVirtualWorld] = virtualworld;
    
HouseInfo[hid][HInterior] = interiorid;
    
HouseInfo[hid][HPrice] = price;
    
HouseInfo[hid][HOwned] = 0;
    
HouseInfo[hid][HLocked] = 0;
    
HouseInfo[hid][HOwnerID] = -1;
    
HouseInfo[hid][HPickup] = CreateDynamicPickup(HUNOWNED_PICKUP1XenYenZen,0,0,-130.0);
    
format(string,sizeof(string),""COL_GREEN"HouseName"COL_WHITE": No Owner\n"COL_GREEN"Price"COL_WHITE": %d",price);
    
HouseInfo[hid][H3D] = CreateDynamic3DTextLabel(stringCOLOR_YELLOWXen,  Yen,  Zen40.0);
    
mysql_format(mysql,query,sizeof(query), "INSERT INTO `houses` (`Xent`, `Yent`, `Zent`, `XExit`, `YExit`, `ZExit`, `HVirtualWorld`, `HInterior`, `HPrice`,\
    `HOwned`, `HLocked`) VALUES (%f, %f, %f, %f, %f, %f, %d, %d, %d, 0, 0)"
Xen,Yen,Zen,Xex,Yex,Zex,virtualworld,interiorid,price);
       
mysql_tquery(mysqlquery"RegisterHouse","i",hid); 
    return 
1;

4.buyhouse command
PHP код:
CMD:buyhouse(playerid,params[])
{
    new 
hid GetHouseID(playerid);
    new 
price HouseInfo[hid][HPrice];
    if(
hid == INVALID_HOUSE_ID) return SendClientMessage(playerid, -1,""COL_RED"SERVER"COL_WHITE"Invalid House id!") ;
    if(
GetPlayerMoney(playerid) < price) return SendClientMessage(playerid, -1""COL_RED"SERVER"COL_WHITE": You don't have so much money to buy the house");
    if(
HouseInfo[hid][HOwned] == 1) return SendClientMessage(playerid,-1,""COL_RED"SERVER"COL_WHITE"You can't buy this house because it is already bought!");
    if(
HouseInfo[hid][HOwnerID] == pinfo[playerid][ID]) return SendClientMessage(playerid, -1""COL_RED"You can't buy your own house!");
    
//if(!IsPlayerNearHouse(playerid)) return SendClientMessage(playerid, -1, ""COL_RED"SERVER"COL_WHITE"You can't buy a house if you are not near it!");
    
ShowPlayerDialog(playerid,DIALOG_BUYHOUSE,DIALOG_STYLE_INPUT,"BUY A HOUSE",""COL_RED"You want to buy a house! Since you can afford it please insert HouseName you want!","OK","Cancel");
    return 
1;

5.dialog asking housename(calls buyhouse function)
PHP код:
        case DIALOG_BUYHOUSE:
        {
            new 
hid GetHouseID(playerid);
            new 
query[200];
            if(!
response) return SendClientMessage(playerid, -1""COL_RED"SERVER"COL_WHITE": You decided not to buy a house. The house sale got cancelled!");
            if(
strlen(inputtext) > 30) return SendClientMessage(playerid, -1""COL_RED"SERVER"COL_WHITE"You must set a name less than 30 characters!");
            
mysql_format(mysql,query,sizeof(query),"UPDATE `houses` SET `HName` = '%e' WHERE `hID` = '%d'",inputtext,hid);
            
mysql_tquery(mysql,query,"i",hid);
            
format(HouseInfo[hid][HName],30,"%s",inputtext);        
        } 
OTHER
1.Loadhouses ( i don't really think that's the problem since the loadhouses function is called after server restarting. The problem happens before i even restart the server
PHP код:
LoadHouses()
{
    new 
Cache:result,rows;
    new 
label[250];
    
result mysql_query(mysql"SELECT * FROM `houses`");
    if((
rows cache_num_rows()))
    {
        for(new 
i=0rowsi++)
        {
            
HouseInfo[i][hID] = cache_get_field_content_int(i"hID");
            
HouseInfo[i][XEnt] = cache_get_field_content_float(i"XEnt"); //we're getting a field 4 from row 0. And since it's an integer, we use cache_get_row_int
            
HouseInfo[i][YEnt] = cache_get_field_content_float(i"YEnt"); //Above
            
HouseInfo[i][ZEnt] = cache_get_field_content_float(i"ZEnt");//Above
            
HouseInfo[i][XExit] = cache_get_field_content_float(i"XExit");//Above. Since player's position is a float, we use cache_get_field_content_float
            
HouseInfo[i][YExit] = cache_get_field_content_float(i"YExit");//Above
            
HouseInfo[i][ZExit] = cache_get_field_content_float(i"ZExit");//Above
            
HouseInfo[i][HVirtualWorld] = cache_get_field_content_int(i"HVirtualWorld");
            
HouseInfo[i][HInterior] = cache_get_field_content_int(i"HInterior");
            
HouseInfo[i][HPrice] = cache_get_field_content_int(i"HPrice");
            
HouseInfo[i][HOwnerID] = cache_get_field_content_int(i"HOwnerID");
            
HouseInfo[i][HOwned] = cache_get_field_content_int(i"HOwned");
            
HouseInfo[i][HLocked] = cache_get_field_content_int(i"HLocked");
            
cache_get_field_content(i"HName"HouseInfo[i][HName], 1MAX_HOUSE_NAME);
            if(
HouseInfo[i][HOwned] == 1)
            {
                
format(label,sizeof(label),""COL_GREEN"HouseName"COL_WHITE":%s\n"COL_GREEN"",HouseInfo[i][HName]);
                
HouseInfo[i][H3D] = CreateDynamic3DTextLabel(labelCOLOR_YELLOWHouseInfo[i][XEnt],  HouseInfo[i][YEnt], HouseInfo[i][ZEnt], 40.0);
                
printf("HOUSE ID : %d Housename : %s FloatX:%f Float Y: %f FloatZ: %f",HouseInfo[i][hID],HouseInfo[i][HName],HouseInfo[i][XEnt],  HouseInfo[i][YEnt], HouseInfo[i][ZEnt]); 
                
CreateDynamicPickup(HOWNED_PICKUP1HouseInfo[i][XEnt],  HouseInfo[i][YEnt], HouseInfo[i][ZEnt]);
            }
        
            else if(
HouseInfo[i][HOwned] == 0)
            {
                
format(label,sizeof(label),""COL_GREEN"HouseName"COL_WHITE": No Owner\n"COL_GREEN"Price"COL_WHITE": %d",HouseInfo[i][HPrice]);
                
HouseInfo[i][H3D] = CreateDynamic3DTextLabel(labelCOLOR_YELLOWHouseInfo[i][XEnt],  HouseInfo[i][YEnt], HouseInfo[i][ZEnt], 40.0);
                
CreateDynamicPickup(HUNOWNED_PICKUP1HouseInfo[i][XEnt],  HouseInfo[i][YEnt], HouseInfo[i][ZEnt]);
            }
        }
        
printf("Successfully Loaded All Houses! ( %d )",rows);
    }
    else
    {
        print(
"There are no houses to load!");
    }
        
cache_delete(result);

2.Gethouseid stock
PHP код:
function BuyHouse(playerid)
{
    new 
houseid GetHouseID(playerid); // houseid is a slot not real ID
    
if(houseid == INVALID_HOUSE_ID) print("ERROR: BuyHouse failed, trying to buy house ID 0!");
    else{
        new 
str[128];
        
HouseInfo[houseid][HOwned] = 1;
        
HouseInfo[houseid][HOwnerID] = pinfo[playerid][ID]; //when i call loadhouses function i have to use the same somehow so server will understand that ownerid = account id again got it?
        
GivePlayerMoney(GetPlayerMoney(playerid), -HouseInfo[houseid][HPrice]);
        
mysql_format(mysql,str,sizeof(str),"UPDATE `houses` SET `HOwnerID`= %d, `HOwned` = 1 WHERE `hID` = %d",pinfo[playerid][ID],HouseInfo[houseid][hID]); // HouseInfo[houseid][hID] its real houseid
        
mysql_query(mysql,str);
        
format(str,sizeof(str),""COL_GREEN"HouseName"COL_WHITE":%s\n"COL_GREEN"",HouseInfo[houseid][HName]);
        
UpdateDynamic3DTextLabelText(HouseInfo[houseid][H3D],COLOR_YELLOW,str);
        
UpdateHousePickup(playerid);
    }
    return 
1;

3.REGISTERING HOUSEID
PHP код:
function RegisterHouse(houseid

    
HouseInfo[houseid][hID] = cache_insert_id();
    
printf("House Registered ID : %d",HouseInfo[houseid][hID]);
    return 
1;

edit: UPLOADED HOUSE.TABLE IN PICTURE TO CHECK IF everything is wrong
Reply
#2

You should save 'HOwned' and 'HLocked' values too.

Код:
mysql_format(mysql,query,sizeof(query), "INSERT INTO `houses` (`Xent`, `Yent`, `Zent`, `XExit`, `YExit`, `ZExit`, `HVirtualWorld`, `HInterior`, `HPrice`,\ 
    `HOwned`, `HLocked`) VALUES (%f, %f, %f, %f, %f, %f, %d, %d, %d, 0, 0, 0, 0)", Xen,Yen,Zen,Xex,Yex,Zex,virtualworld,interiorid,price);
And where do you update the pickups after buy?
Reply
#3

Quote:
Originally Posted by Miguel_Leopold
Посмотреть сообщение
You should save 'HOwned' and 'HLocked' values too.

Код:
mysql_format(mysql,query,sizeof(query), "INSERT INTO `houses` (`Xent`, `Yent`, `Zent`, `XExit`, `YExit`, `ZExit`, `HVirtualWorld`, `HInterior`, `HPrice`,\ 
    `HOwned`, `HLocked`) VALUES (%f, %f, %f, %f, %f, %f, %d, %d, %d, 0, 0, 0, 0)", Xen,Yen,Zen,Xex,Yex,Zex,virtualworld,interiorid,price);
And where do you update the pickups after buy?
This is when I create the house.. It sets howned and hlocked as 0= false . Update pickup is the last thing I need to fix I must fix ID problem
Reply
#4

So the houses are correctly saved in the database and then LoadHouses correctly loads all of the houses?
Reply
#5

1) Are you trying to get the house IDs to start at 1 instead of 0?

2) I would recommend making your house count a global variable that is intialized in LoadHouses() because your houseids are likely to become unstable without it.
Reply
#6

Quote:
Originally Posted by austin070
Посмотреть сообщение
1) Are you trying to get the house IDs to start at 1 instead of 0?

2) I would recommend making your house count a global variable that is intialized in LoadHouses() because your houseids are likely to become unstable without it.
1.Yes
2. Could you provide me with an example of how could this be implemented?
Reply
#7

Quote:
Originally Posted by vassilis
Посмотреть сообщение
1.Yes
2. Could you provide me with an example of how could this be implemented?
That's the reason it's not working correctly. Your houses array begins at 0, but you're trying to start it at 1. What this means is that your loop in LoadHouses() needs to be

pawn Код:
for(new i = 0; i <= rows; i++)
and for every use of i in that loop, it needs to be i+1 in order to skip 0. Same thing goes for any time you loop through all the houses.

As for using a global housecount variable, all you need to do is create a global variable with a name of your choice, and when you call LoadHouses(), it should set the count equal to the number of rows returned by the SQL query.

pawn Код:
new HouseCount = 0;

LoadHouses()
{
    new Cache:result,rows;
    new label[250];
    result = mysql_query(mysql, "SELECT * FROM `houses`");
    HouseCount = cache_num_rows();

        for(new i=0; i <= HouseCount; i++)
        {
            HouseInfo[i+1][hID] = cache_get_field_content_int(i, "hID");
            HouseInfo[i+1][XEnt] = cache_get_field_content_float(i, "XEnt"); //we're getting a field 4 from row 0. And since it's an integer, we use cache_get_row_int
            HouseInfo[i+1][YEnt] = cache_get_field_content_float(i, "YEnt"); //Above
            HouseInfo[i+1][ZEnt] = cache_get_field_content_float(i, "ZEnt");//Above
            HouseInfo[i+1][XExit] = cache_get_field_content_float(i, "XExit");//Above. Since player's position is a float, we use cache_get_field_content_float
            HouseInfo[i+1][YExit] = cache_get_field_content_float(i, "YExit");//Above
            HouseInfo[i+1][ZExit] = cache_get_field_content_float(i, "ZExit");//Above
            HouseInfo[i+1][HVirtualWorld] = cache_get_field_content_int(i, "HVirtualWorld");
            HouseInfo[i+1][HInterior] = cache_get_field_content_int(i, "HInterior");
            HouseInfo[i+1][HPrice] = cache_get_field_content_int(i, "HPrice");
            HouseInfo[i+1][HOwnerID] = cache_get_field_content_int(i, "HOwnerID");
            HouseInfo[i+1][HOwned] = cache_get_field_content_int(i, "HOwned");
            HouseInfo[i+1][HLocked] = cache_get_field_content_int(i, "HLocked");
            cache_get_field_content(i, "HName", HouseInfo[i+1][HName], 1, MAX_HOUSE_NAME);
            if(HouseInfo[i+1][HOwned] == 1)
            {

                format(label,sizeof(label),""COL_GREEN"HouseName"COL_WHITE":%s\n"COL_GREEN"",HouseInfo[i+1][HName]);
                HouseInfo[i+1][H3D] = CreateDynamic3DTextLabel(label, COLOR_YELLOW, HouseInfo[i+1][XEnt],  HouseInfo[i][YEnt], HouseInfo[i][ZEnt], 40.0);
                printf("HOUSE ID : %d Housename : %s FloatX:%f Float Y: %f FloatZ: %f",HouseInfo[i+1][hID],HouseInfo[i+1][HName],HouseInfo[i+1][XEnt],  HouseInfo[i+1][YEnt], HouseInfo[i+1][ZEnt]);  
                CreateDynamicPickup(HOWNED_PICKUP, 1, HouseInfo[i+1][XEnt],  HouseInfo[i+1][YEnt], HouseInfo[i+1][ZEnt]);

            }
         
            else if(HouseInfo[i+1][HOwned] == 0)
            {
                format(label,sizeof(label),""COL_GREEN"HouseName"COL_WHITE": No Owner\n"COL_GREEN"Price"COL_WHITE": %d",HouseInfo[i][HPrice]);
                HouseInfo[i][H3D] = CreateDynamic3DTextLabel(label, COLOR_YELLOW, HouseInfo[i+1][XEnt],  HouseInfo[i+1][YEnt], HouseInfo[i+1][ZEnt], 40.0);
                CreateDynamicPickup(HUNOWNED_PICKUP, 1, HouseInfo[i+1][XEnt],  HouseInfo[i+1][YEnt], HouseInfo[i+1][ZEnt]);
            }
        }
        printf("Successfully Loaded All Houses! ( %d )",rows);
        cache_delete(result);
}
Any time you loop through all the houses and use your HouseInfo[][] array, the hid in the array needs to be 1 more than the current position of the loop.
Reply
#8

I really can't find your problem, but as a suggestion, if it's been 2 weeks and you haven't figured it out yet, wipe it and rewrite it completely, it's worth the time, at least you won't be frustrated by something you can't find.
Reply
#9

Thanks for all suggestions any other suggestion is accepted.
I will check it in some minutes and give reply!
Uploaded a picture of my houses table in case i have done something wrong!
Reply
#10

Quote:
Originally Posted by austin070
Посмотреть сообщение
That's the reason it's not working correctly. Your houses array begins at 0, but you're trying to start it at 1. What this means is that your loop in LoadHouses() needs to be

pawn Код:
for(new i = 0; i <= rows; i++)
and for every use of i in that loop, it needs to be i+1 in order to skip 0. Same thing goes for any time you loop through all the houses.

As for using a global housecount variable, all you need to do is create a global variable with a name of your choice, and when you call LoadHouses(), it should set the count equal to the number of rows returned by the SQL query.

pawn Код:
new HouseCount = 0;

LoadHouses()
{
    new Cache:result,rows;
    new label[250];
    result = mysql_query(mysql, "SELECT * FROM `houses`");
    HouseCount = cache_num_rows();

        for(new i=0; i <= HouseCount; i++)
        {
            HouseInfo[i+1][hID] = cache_get_field_content_int(i, "hID");
            HouseInfo[i+1][XEnt] = cache_get_field_content_float(i, "XEnt"); //we're getting a field 4 from row 0. And since it's an integer, we use cache_get_row_int
            HouseInfo[i+1][YEnt] = cache_get_field_content_float(i, "YEnt"); //Above
            HouseInfo[i+1][ZEnt] = cache_get_field_content_float(i, "ZEnt");//Above
            HouseInfo[i+1][XExit] = cache_get_field_content_float(i, "XExit");//Above. Since player's position is a float, we use cache_get_field_content_float
            HouseInfo[i+1][YExit] = cache_get_field_content_float(i, "YExit");//Above
            HouseInfo[i+1][ZExit] = cache_get_field_content_float(i, "ZExit");//Above
            HouseInfo[i+1][HVirtualWorld] = cache_get_field_content_int(i, "HVirtualWorld");
            HouseInfo[i+1][HInterior] = cache_get_field_content_int(i, "HInterior");
            HouseInfo[i+1][HPrice] = cache_get_field_content_int(i, "HPrice");
            HouseInfo[i+1][HOwnerID] = cache_get_field_content_int(i, "HOwnerID");
            HouseInfo[i+1][HOwned] = cache_get_field_content_int(i, "HOwned");
            HouseInfo[i+1][HLocked] = cache_get_field_content_int(i, "HLocked");
            cache_get_field_content(i, "HName", HouseInfo[i+1][HName], 1, MAX_HOUSE_NAME);
            if(HouseInfo[i+1][HOwned] == 1)
            {

                format(label,sizeof(label),""COL_GREEN"HouseName"COL_WHITE":%s\n"COL_GREEN"",HouseInfo[i+1][HName]);
                HouseInfo[i+1][H3D] = CreateDynamic3DTextLabel(label, COLOR_YELLOW, HouseInfo[i+1][XEnt],  HouseInfo[i][YEnt], HouseInfo[i][ZEnt], 40.0);
                printf("HOUSE ID : %d Housename : %s FloatX:%f Float Y: %f FloatZ: %f",HouseInfo[i+1][hID],HouseInfo[i+1][HName],HouseInfo[i+1][XEnt],  HouseInfo[i+1][YEnt], HouseInfo[i+1][ZEnt]);  
                CreateDynamicPickup(HOWNED_PICKUP, 1, HouseInfo[i+1][XEnt],  HouseInfo[i+1][YEnt], HouseInfo[i+1][ZEnt]);

            }
         
            else if(HouseInfo[i+1][HOwned] == 0)
            {
                format(label,sizeof(label),""COL_GREEN"HouseName"COL_WHITE": No Owner\n"COL_GREEN"Price"COL_WHITE": %d",HouseInfo[i][HPrice]);
                HouseInfo[i][H3D] = CreateDynamic3DTextLabel(label, COLOR_YELLOW, HouseInfo[i+1][XEnt],  HouseInfo[i+1][YEnt], HouseInfo[i+1][ZEnt], 40.0);
                CreateDynamicPickup(HUNOWNED_PICKUP, 1, HouseInfo[i+1][XEnt],  HouseInfo[i+1][YEnt], HouseInfo[i+1][ZEnt]);
            }
        }
        printf("Successfully Loaded All Houses! ( %d )",rows);
        cache_delete(result);
}
Any time you loop through all the houses and use your HouseInfo[][] array, the hid in the array needs to be 1 more than the current position of the loop.
As i mentioned at the main post.. The main problem is not the loading. LoadHouses is called only when the sa-mp server restarts(Or starts). So if in case i didn't have create any houses and create the first house and then the second..(The loadhouse is not called because i didn't restart server) i already have a problem.
edit:Sorry for double post
Reply
#11

BUMP D:
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)