Help +rep LoadHouse / LoadBizz
#1

Hello i use this gamemode; https://sampforum.blast.hk/showthread.php?tid=538107
When i create house or bizz , they save into mysql , but when i restart the server ,In game i doesent see anything and the id of my house don't existe (but in mysql table,is already )


ON GameModeInit
PHP код:
    mysql_function_query(g_iHandle"SELECT * FROM `houses`"true"House_Load"""); 
House Load
PHP код:
public House_Load()
{
    static
        
rows,
        
fields,
        
str[128];
    
cache_get_data(rowsfieldsg_iHandle);
    for (new 
0rows++) if (MAX_HOUSES)
    {
        
HouseData[i][houseExists] = true;
        
HouseData[i][houseLights] = false;
        
HouseData[i][houseID] = cache_get_field_int(i"houseID");
        
HouseData[i][houseOwner] = cache_get_field_int(i"houseOwner");
        
HouseData[i][housePrice] = cache_get_field_int(i"housePrice");
        
cache_get_field_content(i"houseAddress"HouseData[i][houseAddress], g_iHandle);
        
HouseData[i][housePos][0] = cache_get_field_float(i"housePosX");
        
HouseData[i][housePos][1] = cache_get_field_float(i"housePosY");
        
HouseData[i][housePos][2] = cache_get_field_float(i"housePosZ");
        
HouseData[i][housePos][3] = cache_get_field_float(i"housePosA");
        
HouseData[i][houseInt][0] = cache_get_field_float(i"houseIntX");
        
HouseData[i][houseInt][1] = cache_get_field_float(i"houseIntY");
        
HouseData[i][houseInt][2] = cache_get_field_float(i"houseIntZ");
        
HouseData[i][houseInt][3] = cache_get_field_float(i"houseIntA");
        
HouseData[i][houseInterior] = cache_get_field_int(i"houseInterior");
        
HouseData[i][houseExterior] = cache_get_field_int(i"houseExterior");
        
HouseData[i][houseExteriorVW] = cache_get_field_int(i"houseExteriorVW");
        
HouseData[i][houseLocked] = cache_get_field_int(i"houseLocked");
        
HouseData[i][houseMoney] = cache_get_field_int(i"houseMoney");
        for (new 
010++)
        {
            
format(str24"houseWeapon%d"1);
            
HouseData[i][houseWeapons][j] = cache_get_field_int(istr);
            
format(str24"houseAmmo%d"1);
            
HouseData[i][houseAmmo][j] = cache_get_field_int(istr);
        }
        
House_Refresh(i);
    }
    for (new 
0MAX_HOUSES++) if (HouseData[i][houseExists]) {
        
format(strsizeof(str), "SELECT * FROM `housestorage` WHERE `ID` = '%d'"HouseData[i][houseID]);
        
mysql_function_query(g_iHandlestrtrue"OnLoadStorage""d"i);
        
format(strsizeof(str), "SELECT * FROM `furniture` WHERE `ID` = '%d'"HouseData[i][houseID]);
        
mysql_function_query(g_iHandlestrtrue"OnLoadFurniture""d"i);
    }
    return 
1;

House_Refresh

PHP код:
House_Refresh(houseid)
{
    if (
houseid != -&& HouseData[houseid][houseExists])
    {
        if (
IsValidDynamic3DTextLabel(HouseData[houseid][houseText3D]))
            
DestroyDynamic3DTextLabel(HouseData[houseid][houseText3D]);
        if (
IsValidDynamicPickup(HouseData[houseid][housePickup]))
            
DestroyDynamicPickup(HouseData[houseid][housePickup]);
        if (
IsValidDynamicMapIcon(HouseData[houseid][houseMapIcon]))
            
DestroyDynamicMapIcon(HouseData[houseid][houseMapIcon]);
        static
            
string[128];
        if (!
HouseData[houseid][houseOwner]) {
            
format(stringsizeof(string), "[%s]\n%s"FormatNumber(HouseData[houseid][housePrice]), HouseData[houseid][houseAddress]);
            
HouseData[houseid][houseText3D] = CreateDynamic3DTextLabel(string0x33AA33FFHouseData[houseid][housePos][0], HouseData[houseid][housePos][1], HouseData[houseid][housePos][2], 15.0INVALID_PLAYER_IDINVALID_VEHICLE_ID0HouseData[houseid][houseExteriorVW], HouseData[houseid][houseExterior]);
        }
        else {
            
format(stringsizeof(string), "%s"HouseData[houseid][houseAddress]);
            
HouseData[houseid][houseText3D] = CreateDynamic3DTextLabel(stringCOLOR_WHITEHouseData[houseid][housePos][0], HouseData[houseid][housePos][1], HouseData[houseid][housePos][2], 15.0INVALID_PLAYER_IDINVALID_VEHICLE_ID0HouseData[houseid][houseExteriorVW], HouseData[houseid][houseExterior]);
        }
        
HouseData[houseid][housePickup] = CreateDynamicPickup(194701HouseData[houseid][housePos][0], HouseData[houseid][housePos][1], HouseData[houseid][housePos][2], HouseData[houseid][houseExteriorVW], HouseData[houseid][houseExterior]);
        
HouseData[houseid][houseMapIcon] = CreateDynamicMapIcon(HouseData[houseid][housePos][0], HouseData[houseid][housePos][1], HouseData[houseid][housePos][2], (HouseData[houseid][houseOwner] != 0) ? (32) : (31), 0HouseData[houseid][houseExteriorVW], HouseData[houseid][houseExterior]);
    }
    return 
1;

Thks for help +rep
Reply
#2

I edit my post for more help
Reply
#3

Use something that:

Код:
public OnGameModeInit()
{
     for(new i = 0; i < MAX_HOUSES; i++)
     {
          new str[32];
          format(str, 32, "SELECT * FROM `houses` WHERE `houseID` = '%d'", i);
          mysql_function_query(g_iHandle, str, true, "House_Load", "i", i);
     }
     return 1;
}
Код:
forward House_load(i);
public House_Load(i) 
{ 
    static 
        rows, 
        fields, 
        str[128]; 

    cache_get_data(rows, fields, g_iHandle); 

    if(rows)
    { 
        HouseData[i][houseExists] = true; 
        HouseData[i][houseLights] = false; 

        HouseData[i][houseID] = cache_get_field_int(i, "houseID"); 
        HouseData[i][houseOwner] = cache_get_field_int(i, "houseOwner"); 
        HouseData[i][housePrice] = cache_get_field_int(i, "housePrice"); 

        cache_get_field_content(i, "houseAddress", HouseData[i][houseAddress], g_iHandle); 

        HouseData[i][housePos][0] = cache_get_field_float(i, "housePosX"); 
        HouseData[i][housePos][1] = cache_get_field_float(i, "housePosY"); 
        HouseData[i][housePos][2] = cache_get_field_float(i, "housePosZ"); 
        HouseData[i][housePos][3] = cache_get_field_float(i, "housePosA"); 
        HouseData[i][houseInt][0] = cache_get_field_float(i, "houseIntX"); 
        HouseData[i][houseInt][1] = cache_get_field_float(i, "houseIntY"); 
        HouseData[i][houseInt][2] = cache_get_field_float(i, "houseIntZ"); 
        HouseData[i][houseInt][3] = cache_get_field_float(i, "houseIntA"); 
        HouseData[i][houseInterior] = cache_get_field_int(i, "houseInterior"); 
        HouseData[i][houseExterior] = cache_get_field_int(i, "houseExterior"); 
        HouseData[i][houseExteriorVW] = cache_get_field_int(i, "houseExteriorVW"); 
        HouseData[i][houseLocked] = cache_get_field_int(i, "houseLocked"); 
        HouseData[i][houseMoney] = cache_get_field_int(i, "houseMoney"); 
        for (new j = 0; j < 10; j ++) 
        { 
            format(str, 24, "houseWeapon%d", j + 1); 
            HouseData[i][houseWeapons][j] = cache_get_field_int(i, str); 

            format(str, 24, "houseAmmo%d", j + 1); 
            HouseData[i][houseAmmo][j] = cache_get_field_int(i, str); 
        } 
        House_Refresh(i); 
    } 
    if(HouseData[i][houseExists])
	{ 
        format(str, sizeof(str), "SELECT * FROM `housestorage` WHERE `ID` = '%d'", HouseData[i][houseID]); 

        mysql_function_query(g_iHandle, str, true, "OnLoadStorage", "d", i); 

        format(str, sizeof(str), "SELECT * FROM `furniture` WHERE `ID` = '%d'", HouseData[i][houseID]); 

        mysql_function_query(g_iHandle, str, true, "OnLoadFurniture", "d", i); 
    } 
    return 1; 
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)