Houseid
#1

Alright so the simple problem.
When you purchase a house, it doesnt set the correct house ID.
No matter what house you purchase it will insert it into ID 0

PHP код:
CMD:buyhouse(playerid,params[]) {
    
#pragma unused params
    
new Float:MyPos[3],string[128], query[128];
    
GetPlayerPos(playerid,MyPos[0],MyPos[1],MyPos[2]);
    for(new 
0MAX_HOUSES;x++) {
        if(
IsPlayerInRangeOfPoint(playerid,2,HouseInfo[x][EnterX],HouseInfo[x][EnterY],HouseInfo[x][EnterZ])){
            if(
HouseInfo[x][Owned] == 0) {
                if(
AccInfo[playerid][HouseOwner] == 0) {
                        if(
GetPlayerCash(playerid) < HouseInfo[x][HousePrice]) return SendClientMessage(playerid,COLOR_RED,"You dont have enough money");
                        
HouseInfo[x][Owned] = 1;
                        
HouseInfo[x][Locked] = 0;
                        
GivePlayerCash(playerid,-HouseInfo[x][HousePrice]);
                        
AccInfo[playerid][HouseOwner] = HouseInfo[x][HID];
                        
format(string,sizeof(string),"You have purchased a house, server ID: %i for %i$",HouseInfo[x][HID],HouseInfo[x][HousePrice]);
                        
SendClientMessage(playerid,COLOR_GREEN,string);
                        
                        
HouseInfo[x][Owned] = 1;
                        
HouseInfo[x][HID] = x;
                        
mysql_format(mysqlquerysizeof(query), "UPDATE `houses` SET `Owned`=%i,`Owner`='%e',`MasterID`=%i WHERE `ID`=%i",1,GetName(playerid),AccInfo[playerid][ID],HouseInfo[x][HID]);
                        
mysql_tquery(mysqlquery);
                        
                        
DestroyPickup(HouseInfo[x][HPickup]);
                        
Delete3DTextLabel(HouseInfo[x][HouseText]);
                        
HouseInfo[x][HPickup] = CreatePickup(12721HouseInfo[x][EnterX], HouseInfo[x][EnterY], HouseInfo[x][EnterZ]);
                        
format(string,sizeof(string),"House Name: %s\nHouse Owner: %s\nHouse ID: %i",HouseInfo[x][HouseName],GetRoleplayName(playerid),HouseInfo[x][HID]);
                        
HouseInfo[x][HouseText] = Create3DTextLabel(string0x008080FFHouseInfo[x][EnterX], HouseInfo[x][EnterY], HouseInfo[x][EnterZ], 40.000);
                        
GivePlayerCash(playerid,-HouseInfo[x][HousePrice]);
                        
                        
                        
format(string,sizeof(string),"%s has purchased house ID: %i for %i$",GetName(playerid),HouseInfo[x][HID],HouseInfo[x][HousePrice]);
                        
HousePurchaseLog(string);
                        
                        print(
query);
                }
            }
        }
    }
    return 
true;

Loading houses from SQL
PHP код:
public OnHouseLoad()
{
    new 
rowsfields;
    
cache_get_data(rowsfieldsmysql);
    if(
rows)
    {
        for(new 
0rows && MAX_HOUSESi++)
        {
            new 
string[128];
            
            
cache_get_field_content(i"HouseName"string);
            
strreplace(string'_'' ');
            
format(HouseInfo[i][HouseName], sizeof(string), string);
            
            
cache_get_field_content(i"Owner"string);
            
format(HouseInfo[i][Owner], sizeof(string), string);
            
            new 
houseid;
            
            
HouseInfo[houseid][HID] = cache_get_field_content_int(i,"ID");
            
HouseInfo[houseid][HousePrice] = cache_get_field_content_int(i,"Price");
            
HouseInfo[houseid][EnterX] = cache_get_field_content_float(i,"EnterX");
            
HouseInfo[houseid][EnterY] = cache_get_field_content_float(i,"EnterY");
            
HouseInfo[houseid][EnterZ] = cache_get_field_content_float(i,"EnterZ");
            
HouseInfo[houseid][ExitX] = cache_get_field_content_float(i,"ExitX");
            
HouseInfo[houseid][ExitY] = cache_get_field_content_float(i,"ExitY");
            
HouseInfo[houseid][ExitZ] = cache_get_field_content_float(i,"ExitZ");
            
HouseInfo[houseid][VirtualWorld] = cache_get_field_content_int(i,"VirtualWorld");
            
HouseInfo[houseid][Interior] = cache_get_field_content_int(i,"InteriorID");
            
HouseInfo[houseid][Owned] = cache_get_field_content_int(i,"Owned");
            
HouseInfo[houseid][Garage] = cache_get_field_content_int(i,"Garage");
            
HouseInfo[houseid][Locked] = cache_get_field_content_int(i,"Locked");
            
HouseInfo[houseid][HouseBank] = cache_get_field_content_int(i,"HouseBank");
            
HouseInfo[houseid][FurnitureToken] = cache_get_field_content_int(i,"FurnitureToken");
            
HouseInfo[houseid][HMasterID] = cache_get_field_content_int(i,"MasterID");
            if(
HouseInfo[houseid][Owned] == 0) {
                
HouseInfo[houseid][HPickup] = CreatePickup(12731HouseInfo[houseid][EnterX], HouseInfo[houseid][EnterY], HouseInfo[houseid][EnterZ]);
                
HousesLoaded++;
                
format(string,sizeof(string),"House Name: %s\nHouse Owner: NO_ONE\nHouse ID: %i\nHouse Price: %i",HouseInfo[houseid][HouseName],HouseInfo[houseid][HID],HouseInfo[houseid][HousePrice]);
                
HouseInfo[houseid][HouseText] = Create3DTextLabel(string0x008080FFHouseInfo[houseid][EnterX], HouseInfo[houseid][EnterY], HouseInfo[houseid][EnterZ], 10.000);
            }
            else if(
HouseInfo[i][Owned] == 1) {
                
HouseInfo[houseid][HPickup] = CreatePickup(12721HouseInfo[houseid][EnterX], HouseInfo[houseid][EnterY], HouseInfo[houseid][EnterZ]);
                
HousesLoaded++;
                
format(string,sizeof(string),"House Name: %s\nHouse Owner: %s\nHouse ID: %i",HouseInfo[houseid][HouseName],HouseInfo[houseid][Owner],HouseInfo[houseid][HID]);
                
HouseInfo[houseid][HouseText] = Create3DTextLabel(string0x008080FFHouseInfo[houseid][EnterX], HouseInfo[houseid][EnterY], HouseInfo[houseid][EnterZ], 10.000);
            }
            
HousesLoaded++;
        }
        
printf("[House System] %i houses were created..."HousesLoaded);
    }
    else print(
"No houses to be loaded..");
    return 
true;

Reply
#2

I have the same problem.. and still noone found a solution D:
Reply
#3

I assume that this HouseInfo[somehouserandomid][HID] should be the house ID in the database, therefore, when you buy you set HouseInfo[somehouserandomid][HID] = somehouserandomid; therefore this house's database ID would become the current in-game ID which would be different from the actual database ID.
Reply
#4

Quote:
Originally Posted by thefirestate
Посмотреть сообщение
I assume that this HouseInfo[somehouserandomid][HID] should be the house ID in the database, therefore, when you buy you set HouseInfo[somehouserandomid][HID] = somehouserandomid; therefore this house's database ID would become the current in-game ID which would be different from the actual database ID.
What?
Reply
#5

In OnHouseLoad,
remove new houseid; and
pawn Код:
change all:
HouseInfo[houseid]

to this:
HouseInfo[i]
Reply
#6

Quote:
Originally Posted by ATGOggy
Посмотреть сообщение
In OnHouseLoad,
remove new houseid; and
pawn Код:
change all:
HouseInfo[houseid]
to this:
HouseInfo[i]
That works in a way, lets say Im loading houses from SQL now, it will load them all properly, except if there are houses that have HOwned they will be set to HID:0 coordinates
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)