HouseID issue
#1

The problem is simple, when you create a house, house ID wont be correct. You will have to restart the server in order for the ID to become the right one.
This causes problems such as reloading houses in game without restart so those fresh created houses will be set as Owned 1 since it will read anothers house ID.

PHP код:
CMD:buyhouse(playerid,params[]) {
    
#pragma unused params
    
new Float:MyPos[3],string[128], query[512];
    
GetPlayerPos(playerid,MyPos[0],MyPos[1],MyPos[2]);
    for(new 
0MAX_HOUSES;x++) {
        if(
IsPlayerInRangeOfPoint(playerid,10,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 `HouseName`='%e', `Price`=%i, `EnterX`=%f, `EnterY`=%f, `EnterZ`=%f, `ExitX`= %f, `ExitY`=%f, `ExitZ`=%f, `VirtualWorld`=%i, `InteriorID`=%i,`Owned`=%i, `Garage`=%i, `Locked`=%i, `HouseBank`=%i,`Owner`='%e',`FurnitureToken`=%i,`MasterID`=%i WHERE `ID`=%d"HouseInfo[x][HouseName],HouseInfo[x][HousePrice],
                        
HouseInfo[x][EnterX],HouseInfo[x][EnterY],HouseInfo[x][EnterZ], HouseInfo[x][ExitX],HouseInfo[x][ExitY],HouseInfo[x][ExitZ], HouseInfo[x][VirtualWorld], HouseInfo[x][Interior],HouseInfo[x][Owned],HouseInfo[x][Garage],HouseInfo[x][Locked], HouseInfo[x][HouseBank],Name[playerid],HouseInfo[x][FurnitureToken],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);
                }
            }
        }
    }
    return 
true;

Reply
#2

Mind putting the createhouse command as the problem might be there or something in loading/saving function if you have one.
Reply
#3

Quote:
Originally Posted by Stanford
Посмотреть сообщение
Mind putting the createhouse command as the problem might be there or something in loading/saving function if you have one.
Well to be quite honest the only thing that could cause the problem is this
This is being called when they create the house. Loading isnt the problem as it loads properly from selected ID.
PHP код:
public OnHouseCreation() {
    
HouseInfo[houseid][HID] = cache_insert_id();
    return 
1;

Reply
#4

To all people having issue with similiar problem.

PHP код:
HouseInfo[houseid][HID] = cache_insert_id(CONNECTION HANDLER); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)