Creepy house system bug
#2

made a example of a dynamic house system
PHP Code:
#define max_houses 100
new Iterator:fHouses<max_houses>;
CMD:createhouse(playeridparams[])
{
    new 
prices[300];
    if(
PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playeridCOLOR_GREY"Not authorized!");
    if(
sscanf(params"d"price)) return SendClientMessage(playeridCOLOR_GREY"Usage:{FFFFFF} /createhouse [price]");
    
//gets free slot in array
    
new id=Iter_Free(fHouses);
    if(
id==INVALID_ITERATOR_SLOT)return SendClientMessage(playeridCOLOR_GREY"No valid house slot!");
    
//signs slot id
    
Iter_Add(fHouses,id);
    
GetPlayerPos(playeridHouseInfo[id][hOutPos][0], HouseInfo[id][hOutPos][1], HouseInfo[id][hOutPos][2]);
    
HouseInfo[id][hOutInterior] = GetPlayerInterior(playerid);
    
HouseInfo[id][hOutWorld] = GetPlayerVirtualWorld(playerid);
    
HouseInfo[id][hPrice] = price;
    
CreateHouse(i);
    
format(ssizeof(s), "INSERT INTO `houses` (`Out_X`, `Out_Y`, `Out_Z`, `OutInt`, `OutWorld`, `Price`) VALUES ('%f', '%f', '%f', '%i', '%i', '%i')"
    
HouseInfo[id][hOutPos][0], HouseInfo[id][hOutPos][1], HouseInfo[id][hOutPos][2], HouseInfo[id][hOutInterior], HouseInfo[id][hOutWorld], HouseInfo[id][hPrice]);
    new 
Cache:cq=mysql_query(dbhandle,s);
    
//gets auto increment id from db
    
HouseInfo[id][hID]=cache_inser_id();
    
cache_delete(cq);
    
//mysql_tquery(dbhandle,s);
    //dont use this old thing
    //mysql_function_query(dbhandle, query, true, "", "");    
    
format(ssizeof(s), "You created a house at X: %f, Y: %f, Z: %f, for price of: %d: %d"xyzprice);
    
SendClientMessage(playeridCOLOR_GREYs);
    
HouseInfo[id][hForSell] = 1;
    return 
1;
}
forward LoadHouses();
public 
LoadHouses()
{
    new 
rows cache_get_row_count(dbhandle);
    
printf("====================LOADING HOUSES====================");
    for(new 
1rows && MAX_HOUSES++)
    {
        
cache_get_field_content(i"Owner"HouseInfo[i][hOwner], dbhandleMAX_PLAYER_NAME);
        
//add auto increment to ID
        
HouseInfo[i][hID]               = cache_get_field_content_int(i"ID");
        
HouseInfo[i][hOutPos][0]      = cache_get_field_content_float(i"Out_X");
        
HouseInfo[i][hOutPos][1]      = cache_get_field_content_float(i"Out_Y");
        
HouseInfo[i][hOutPos][2]      = cache_get_field_content_float(i"Out_Z");
        
HouseInfo[i][hIntPos][0]      = cache_get_field_content_float(i"Int_X");
        
HouseInfo[i][hIntPos][1]      = cache_get_field_content_float(i"Int_Y");
        
HouseInfo[i][hIntPos][2]      = cache_get_field_content_float(i"Int_Z");
        
HouseInfo[i][hOutInterior]    = cache_get_field_content_int(i"OutInt");
        
HouseInfo[i][hOutWorld]       = cache_get_field_content_int(i"OutWorld");
        
HouseInfo[i][hInsideInterior] = cache_get_field_content_int(i"InsideInt");
        
HouseInfo[i][hInsideWorld]    = cache_get_field_content_int(i"InsideWorld");
        
HouseInfo[i][hLocked]         = cache_get_field_content_int(i"Locked");
        
HouseInfo[i][hForSell]         = cache_get_field_content_int(i"ForSell");
        
HouseInfo[i][hPrice]               = cache_get_field_content_int(i"Price");
        if(
cache_get_field_content_int(i"ForSell") == 0)HouseInfo[i][hForSell] = 0;
        if(
cache_get_field_content_int(i"Locked") == 1)HouseInfo[i][hForSell] = 1;
        
Iter_Add(fHouses,i);
        
CreateHouse(i);
    }
    
printf("====================LOADED: %d HOUSES================="rows);
    return 
1;
}
CreateHouse(i){
    new 
s[300];
    if(
HouseInfo[i][hForSell] == 1){
        
format(ssizeof(s), "This house is for sell!\nPrice: %d\nType /buyhouse to buy it.\nType /enter to go inside."HouseInfo[i][hPrice]);
    }else{
        
format(ssizeof(s), "House\nOwner: %s\nTo enter inside type /enter."HouseInfo[i][hOwner]);
    }
    
HouseInfo[i][hPickup] = CreatePickup(127323HouseInfo[i][hOutPos][0], HouseInfo[i][hOutPos][1], HouseInfo[i][hOutPos][2], -1);
    
HouseInfo[i][hLabel] = CreateDynamic3DTextLabel(,COLOR_ORANGEHouseInfo[i][hOutPos][0], HouseInfo[i][hOutPos][1], HouseInfo[i][hOutPos][2],30.0INVALID_PLAYER_IDINVALID_VEHICLE_ID0, -1, -1, -17.0);
    return 
1;

Reply


Messages In This Thread
Creepy house system bug - by ShadowMortar - 23.01.2019, 19:10
Re: Creepy house system bug - by codExpert - 23.01.2019, 20:38
Re: Creepy house system bug - by ShadowMortar - 24.01.2019, 06:40
Re: Creepy house system bug - by Kane - 24.01.2019, 07:13
Re: Creepy house system bug - by ShadowMortar - 24.01.2019, 07:37
Re: Creepy house system bug - by Kane - 24.01.2019, 07:46
Re: Creepy house system bug - by Logic_ - 24.01.2019, 07:48
Re: Creepy house system bug - by fiki574 - 24.01.2019, 09:31
Re: Creepy house system bug - by ShadowMortar - 24.01.2019, 12:07

Forum Jump:


Users browsing this thread: 1 Guest(s)