The house is already bought but its not!? D:
#3

PHP код:
function CreateHouse(Float:Xen,Float:Yen,Float:Zen,Float:Xex,Float:Yex,Float:Zex,virtualworld,interiorid,price)
{
        static 
hCount;
    new 
hid hCounthCount += 1;
    new 
string[100];
    new 
query[350];
    
hid += 1;
    
HouseInfo[hid][XEnt] = Xen;
    
HouseInfo[hid][YEnt] = Yen;
    
HouseInfo[hid][ZEnt] = Zen;
    
HouseInfo[hid][XExit] = Xex;
    
HouseInfo[hid][YExit] = Yex;
    
HouseInfo[hid][ZExit] = Zex;
    
HouseInfo[hid][HVirtualWorld] = virtualworld;
    
HouseInfo[hid][HInterior] = interiorid;
    
HouseInfo[hid][HPrice] = price;
    
HouseInfo[hid][HOwned] = 0;
    
HouseInfo[hid][HLocked] = 0;
    
HouseInfo[hid][HOwnerID] = -1;
    
format(string,sizeof(string),""COL_GREEN"HouseName"COL_WHITE": No Owner\n"COL_GREEN"Price"COL_WHITE": %d",price);
    
HouseInfo[hid][H3D] = CreateDynamic3DTextLabel(stringCOLOR_YELLOWXen,  Yen,  Zen40.0);
    
mysql_format(mysql,query,sizeof(query), "INSERT INTO `houses` (`Xent`, `Yent`, `Zent`, `XExit`, `YExit`, `ZExit`, `HVirtualWorld`, `HInterior`, `HPrice`,\
    `HOwned`, `HLocked`) VALUES (%f, %f, %f, %f, %f, %f, %d, %d, %d, 0, 0)"
Xen,Yen,Zen,Xex,Yex,Zex,virtualworld,interiorid,price);
       
mysql_tquery(mysqlquery"RegisterHouse","i",hid); 

    return 
1;

LoadHouses function
PHP код:
LoadHouses()
{
    new 
Cache:result,rows;
    new 
label[250];
    
result mysql_query(mysql"SELECT * FROM `houses`");
    if((
rows cache_num_rows()))
    {
        for(new 
i=0rowsi++)
        {
            
HouseInfo[i][XEnt] = cache_get_field_content_float(i"XEnt"); //we're getting a field 4 from row 0. And since it's an integer, we use cache_get_row_int
            
HouseInfo[i][YEnt] = cache_get_field_content_float(i"YEnt"); //Above
            
HouseInfo[i][ZEnt] = cache_get_field_content_float(i"ZEnt");//Above
            
HouseInfo[i][XExit] = cache_get_field_content_float(i"XExit");//Above. Since player's position is a float, we use cache_get_field_content_float
            
HouseInfo[i][YExit] = cache_get_field_content_float(i"YExit");//Above
            
HouseInfo[i][ZExit] = cache_get_field_content_float(i"ZExit");//Above
            
HouseInfo[i][HVirtualWorld] = cache_get_field_content_int(i"HVirtualWorld");
            
HouseInfo[i][HInterior] = cache_get_field_content_int(i"HInterior");
            
HouseInfo[i][HPrice] = cache_get_field_content_int(i"HPrice");
            
HouseInfo[i][HOwnerID] = cache_get_field_content_int(0"HOwnerID");
            
HouseInfo[i][HOwned] = cache_get_field_content_int(i"HOwned");
            
HouseInfo[i][HLocked] = cache_get_field_content_int(i"HLocked");
            
cache_get_field_content(i"HName"HouseInfo[i][HName], 30);
            if(
HouseInfo[i][HOwned] == 1)
        {
                
format(label,sizeof(label),""COL_GREEN"HouseName"COL_WHITE":%s\n"COL_GREEN"",HouseInfo[i][HName]);
                
HouseInfo[i][H3D] = CreateDynamic3DTextLabel(labelCOLOR_YELLOWHouseInfo[i][XEnt],  HouseInfo[i][YEnt], HouseInfo[i][ZEnt], 40.0);
        }
        
        else if(
HouseInfo[i][HOwned] == 0)
        {
            
format(label,sizeof(label),""COL_GREEN"HouseName"COL_WHITE": No Owner\n"COL_GREEN"Price"COL_WHITE": %d",HouseInfo[i][HPrice]);
            
HouseInfo[i][H3D] = CreateDynamic3DTextLabel(labelCOLOR_YELLOWHouseInfo[i][XEnt],  HouseInfo[i][YEnt], HouseInfo[i][ZEnt], 40.0);

        }
        }
        
printf("Successfully Loaded All Houses! ( %d )",rows);
    }
    else
    {
        print(
"There are no houses to load!");
    }
        
cache_delete(result);

Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)