buy house problem [mysql r33]
#1

Hey,

i got some problem with my script, so basically everything works good on this house script, when im creating house im buying and House Owner and house owned columns isnt changing and so basically i just need ur help guys,

there is a code

PHP Code:
forward LoadHouse();
public 
LoadHouse()
{
mysql_tquery(MySQLCon"SELECT * FROM "HOUSES_TABLE" ORDER BY `ID` ASC""OnHouseLoad"""); 
}

PHP Code:
forward OnHouseLoad();
public 
OnHouseLoad() {
    new 
rowsfieldshouseLoadTime;
    
cache_get_data(rowsfields);
    if(!
rows)
        return 
printf("[House] No houses to load.");
    if(
rows) {
        
houseLoadTime GetTickCount();
        for(new 
0rowsi++) {
            
HouseInfo[houses][hID] = cache_get_row_int(i0MySQLCon);
            
HouseInfo[houses][hExt][0] = cache_get_row_float(i1MySQLCon);
            
HouseInfo[houses][hExt][1] = cache_get_row_float(i2MySQLCon);
            
HouseInfo[houses][hExt][2] = cache_get_row_float(i3MySQLCon);
            
HouseInfo[houses][hInt][0] = cache_get_row_float(i4MySQLCon);
            
HouseInfo[houses][hInt][1] = cache_get_row_float(i5MySQLCon);
            
HouseInfo[houses][hInt][2] = cache_get_row_float(i6MySQLCon);
            
HouseInfo[houses][hInterior] = cache_get_row_int(i7MySQLCon);
            
cache_get_row(i8HouseInfo[houses][hOwner], MySQLConMAX_PLAYER_NAME);
            
HouseInfo[houses][hPrice] = cache_get_row_int(i9MySQLCon);
            
HouseInfo[houses][hOwned] = cache_get_row_int(i10MySQLCon);
            
HouseInfo[houses][hType] = cache_get_row_int(i11MySQLCon);
            if(
HouseInfo[houses][hOwned] == 0) {
                
HouseInfo[houses][hPickup] = CreateDynamicPickup(12731HouseInfo[houses][hExt][0], HouseInfo[houses][hExt][1], HouseInfo[houses][hExt][2]);
            }
            else {
                
HouseInfo[houses][hPickup] = CreateDynamicPickup(12391HouseInfo[houses][hExt][0], HouseInfo[houses][hExt][1], HouseInfo[houses][hExt][2]);
            }
            
houses++;
        }
        
printf("Loaded %d houses in %02d ms."housesGetTickCount() - houseLoadTime);
    }
    return 
1;

buyhouse

PHP Code:
CMD:buyhouse(playerid) {
    for(new 
hhousesh++) {
        if(
IsPlayerInRangeOfPoint(playerid1.5HouseInfo[h][hExt][0], HouseInfo[h][hExt][1], HouseInfo[h][hExt][2])) {
            if(!
HouseInfo[h][hOwned]) {
                if(
pInfo[playerid][pMoney] < HouseInfo[h][hPrice])
                    return 
SendClientMessage(playeridCOLOR_RED"ERROR: {FFFFFF}You have insufficient funds to do this action('s).");
                if(
pInfo[playerid][pHouseKey] > 1)
                    return 
SendClientMessage(playeridCOLOR_RED"ERROR: {FFFFFF}You already own a house.");
                
SendClientMessage(playeridCOLOR_WHITE"Property has been {2BFF00}purchased.");
                
pInfo[playerid][pHouseKey] = 1;
                
HouseInfo[h][hOwned] = 1;
                
HouseInfo[h][hOwner] = GetName(playerid);
                
GiveCash(playerid, -HouseInfo[h][hPrice]);
                
DestroyDynamicPickup(HouseInfo[h][hPickup]);
                
HouseInfo[h][hPickup] = CreateDynamicPickup(12391HouseInfo[h][hExt][0], HouseInfo[h][hExt][1], HouseInfo[h][hExt][2]);
            }
        }
    }
    return 
1;

and if u know the solution of this please respond!
Reply
#2

Well, you don't save the new values in buyhouse, so why would they change.
Reply
#3

There's no update query?
Reply
#4

u need to make an update query and when player buys a house it should be updated
Reply
#5

Quote:
Originally Posted by Misiur
View Post
Well, you don't save the new values in buyhouse, so why would they change.
guys i forgot to show u savehouse

PHP Code:
tock SaveHouses() {
    new 
Query[325];
    for(new 
hhousesh++) {
        
format(Querysizeof Query"UPDATE `houses` SET `ExtX`=%0.2f,`ExtY`=%0.2f,`ExtZ`=%0.2f,`IntX`=%0.2f,`IntY`=%0.2f,`IntZ`=%0.2f,`Interior`=%d,`Owner`='%s',`Price`=%d,`Owned`=%d,`Type`=%d WHERE `ID`=%d",
        
HouseInfo[h][hExt][0],
        
HouseInfo[h][hExt][1],
        
HouseInfo[h][hExt][2],
        
HouseInfo[h][hInt][0],
        
HouseInfo[h][hInt][1],
        
HouseInfo[h][hInt][2],
        
HouseInfo[h][hInterior],
        
HouseInfo[h][hOwner],
        
HouseInfo[h][hPrice],
        
HouseInfo[h][hOwned],
        
HouseInfo[h][hType],
        
HouseInfo[h][hID]);
        
mysql_tquery(MySQLConQuery"""");
    }
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)