House Purchase problem
#1

Alright so now the only problem is left for me to solve is purchasing houses.
Lets say you are standing at house ID:14, you purchase it, it will purchase ID before it. Aka it will purchase house ID 13 instead

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 
1MAX_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;

Reply
#2

Okay so the problem still exist
PHP код:
[17:34:41UPDATE `housesSET `HouseName`='name', `Price`=1000, `EnterX`=132.729, `EnterY`=-1491.53, `EnterZ`=18.766, `ExitX`= 0.0, `ExitY`=0.0, `ExitZ`=0.0, `VirtualWorld`=8826, `InteriorID`=1,`Owned`=1, `Garage`=0, `Locked`=0, `HouseBank`=0,`Owner`='Test_Account',`FurnitureToken`=0,`MasterID`=1 WHERE `ID`=
It inserts everything correctly besides WHERE ID

If I print out the houseid like this
PHP код:
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); 
it will give you the correct House ID, but inserting into SQL gives different results
Reply
#3

Tell me what is this and what it should store:

HouseInfo[x][HID] = x;
Reply
#4

Quote:
Originally Posted by thefirestate
Посмотреть сообщение
Tell me what is this and what it should store:

HouseInfo[x][HID] = x;
It should store nearest house ID into House ID


EDIT: Haha that resolves it entirely! Thanks mate! I havent even noticed I had that dumb stuff inside... hahaha
Reply
#5

That's what I was trying to tell you before but you quoted me with "What?"
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)