• Уважаемый Гость.
    - Прежде чем создать свою тему, пожалуйста, попробуй воспользоваться этим -> ПОИСКОМ !!!
    - После решения Вашего вопроса (проблемы) - нажмите "Лучший ответ", на сообщении, которое его решило. За игнорирование этого действия - Вы получите соответствующее предупреждение. Мы - стараемся Вам помочь. Уделите 10 секунд - чтобы нажать кнопку. (Если у Вас нет такой возможности - укажите в последнем своем сообщении какой ответ Вы считаете лучшим. Наши модераторы сделают это за Вас)
    ЗАПРЕЩЕНО:
    - Cоздавать темы с названиями "Помогите", "Плиз", "Ошибка", "Не могу найти", "Хелп" и тому подобное;
    - Cоздавать темы без детального описания того, что нужно исправить.
    - Cоздавать темы из одного скриншота.
    За игнор правил форума - Ваша тема будет удалена, а Вы получите системное предупреждение.

Пропадает владелец дома/бизнеса при рестарте сервера

KMIKHAILIN

Дебютант
Код сохранения/загрузки домов:


Код:
stock SaveHouse(houseid)
{
    new string[1200], str[256];
    format(str, sizeof(str), "UPDATE `houses` SET");
    strcat(string, str);
    format(str, sizeof(str), "`Enter_X` = '%.4f',`Enter_Y` = '%.4f',`Enter_Z` = '%.4f', ",
        HouseInfo[houseid][hEnter_X],
        HouseInfo[houseid][hEnter_Y],
        HouseInfo[houseid][hEnter_Z]);
    strcat(string, str);

    format(str, sizeof(str), "`Exit_X` = '%.4f', `Exit_Y` = '%.4f', `Exit_Z` = '%.4f', ",
         HouseInfo[houseid][hExit_X],
        HouseInfo[houseid][hExit_Y],
        HouseInfo[houseid][hExit_Z]);
    strcat(string, str);

    format(str, sizeof(str), "`Owner` = '%s', `Room_Owner_0` = '%s',`Room_Owner_1` = '%s', ",
        HouseInfo[houseid][hOwner],
        HRoomOwner[houseid][0],
        HRoomOwner[houseid][1]);
    strcat(string, str);

    format(str, sizeof(str), "`Room_Owner_2` = '%s', `Room_Owner_3` = '%s', `Room_Owner_4` = '%s', ",
        HRoomOwner[houseid][2],
        HRoomOwner[houseid][3],
        HRoomOwner[houseid][4]);
    strcat(string, str);

    format(str, sizeof(str), "`Level` = '%d', `Cost` = '%d', `Lock` = '%d', `Rent` = '%d', ",
        HouseInfo[houseid][hLevel],
        HouseInfo[houseid][hCost],
        HouseInfo[houseid][hLock],
        HouseInfo[houseid][hRent]);
    strcat(string, str);

    format(str, sizeof(str), "`Interior` = '%d', `Money` = '%d', `Drugs` = '%d', `Mats` = '%d', ",
        HouseInfo[houseid][hInt],
        HouseInfo[houseid][hMoney],
        HouseInfo[houseid][hDrugs],
        HouseInfo[houseid][hMats]);
    strcat(string, str);

    format(str, sizeof(str), "`Bar` = '%d', `Podval` = '%d', `Skin_1` = '%d', `Skin_2` = '%d', ",
        HouseInfo[houseid][hBar],
        HouseInfo[houseid][hPodval],
        HouseInfo[houseid][hSkin][0],
        HouseInfo[houseid][hSkin][1]);
    strcat(string, str);

    format(str, sizeof(str), "`Skin_3` = '%d', `Skin_4` = '%d', `Skin_5` = '%d', `NoOwner` = '%d', `Nalog` = '%d', `Klass` = '%d', `Med` = '%d', ",
        HouseInfo[houseid][hSkin][2],
        HouseInfo[houseid][hSkin][3],
        HouseInfo[houseid][hSkin][4],
        HouseInfo[houseid][hNoOwner],
        HouseInfo[houseid][hNalog],
        HouseInfo[houseid][hKlass],
        HouseInfo[houseid][hMed]);
    strcat(string, str);

    format(str, sizeof(str), "`Garage`='%i', `Garage_X`='%.4f', `Garage_Y`='%.4f', `Garage_Z`='%.4f' WHERE `ID` = '%i'",
        HouseInfo[houseid][hGarage],
        HouseInfo[houseid][hGarage_X],
        HouseInfo[houseid][hGarage_Y],
        HouseInfo[houseid][hGarage_Z],
        HouseInfo[houseid][hOpis],
        houseid);
    strcat(string, str);
    mysql_query(mysql, string, false);
    return 1;
}


Код:
stock LoadHouses()
{
    for(new i = -1; ++i < MAX_HOUSES;) SetString(HouseInfo[i][hOwner], "The State");
    new Cache:result = mysql_query(mysql, "SELECT * FROM `houses`");
    OWNABLEHOUSES = cache_get_row_count(mysql);
    for (new i = -1; ++i < OWNABLEHOUSES;)
    {
        HouseInfo[i+1][hID] = cache_get_row_int(i, 0, mysql);
        HouseInfo[i+1][hEnter_X] = cache_get_row_float(i, 1, mysql);
        HouseInfo[i+1][hEnter_Y] = cache_get_row_float(i, 2, mysql);
        HouseInfo[i+1][hEnter_Z] = cache_get_row_float(i, 3, mysql);
        HouseInfo[i+1][hExit_X] = cache_get_row_float(i, 4, mysql);
        HouseInfo[i+1][hExit_Y] = cache_get_row_float(i, 5, mysql);
        HouseInfo[i+1][hExit_Z] = cache_get_row_float(i, 6, mysql);
        cache_get_row(i, 7, HouseInfo[i+1][hOwner], mysql, 24);
        cache_get_row(i, 8, HRoomOwner[i+1][0], mysql, 24);
        cache_get_row(i, 9, HRoomOwner[i+1][1], mysql, 24);
        cache_get_row(i, 10, HRoomOwner[i+1][2], mysql, 24);
        cache_get_row(i, 11, HRoomOwner[i+1][3], mysql, 24);
        cache_get_row(i, 12, HRoomOwner[i+1][4], mysql, 24);
        HouseInfo[i+1][hLevel] = cache_get_row_int(i, 13, mysql);
        HouseInfo[i+1][hCost] = cache_get_row_int(i, 14, mysql);
        HouseInfo[i+1][hLock] = cache_get_row_int(i, 15, mysql);
        HouseInfo[i+1][hRent] = cache_get_row_int(i, 16, mysql);
        HouseInfo[i+1][hInt] = cache_get_row_int(i, 17, mysql);
        HouseInfo[i+1][hMoney] = cache_get_row_int(i, 18, mysql);
        HouseInfo[i+1][hDrugs] = cache_get_row_int(i, 19, mysql);
        HouseInfo[i+1][hMats] = cache_get_row_int(i, 20, mysql);
        HouseInfo[i+1][hBar] = cache_get_row_int(i, 21, mysql);
        HouseInfo[i+1][hPodval] = cache_get_row_int(i, 22, mysql);
        HouseInfo[i+1][hSkin][0] = cache_get_row_int(i, 23, mysql);
        HouseInfo[i+1][hSkin][1] = cache_get_row_int(i, 24, mysql);
        HouseInfo[i+1][hSkin][2] = cache_get_row_int(i, 25, mysql);
        HouseInfo[i+1][hSkin][3] = cache_get_row_int(i, 26, mysql);
        HouseInfo[i+1][hSkin][4] = cache_get_row_int(i, 27, mysql);
        HouseInfo[i+1][hNoOwner] = cache_get_row_int(i, 28, mysql);
        HouseInfo[i+1][hNalog] = cache_get_row_int(i, 29, mysql);
        HouseInfo[i+1][hKlass] = cache_get_row_int(i, 30, mysql);
        HouseInfo[i+1][hMed] = cache_get_row_int(i, 31, mysql);

        HouseInfo[i+1][hGarage] = cache_get_row_int(i, 32, mysql);
        HouseInfo[i+1][hGarage_X] = cache_get_row_float(i, 33, mysql);
        HouseInfo[i+1][hGarage_Y] = cache_get_row_float(i, 34, mysql);
        HouseInfo[i+1][hGarage_Z] = cache_get_row_float(i, 35, mysql);
        cache_get_row(0, 36, HouseInfo[i+1][hOpis],mysql, 32);
    }
    cache_delete(result, mysql);
    return 1;
}


База данных (houses):

Чтобы видеть скрытое содержание Зарегистрируйтесь на форуме!



Код сохранения/загрузки бизнесов:


Код:
stock SaveBiz(bizid)
{
    new string[1200];
    format(string, sizeof(string), "UPDATE `businesses` SET \
    `State` = '%d', `Name` = '%s', `Owner` = '%s', `Enter_X` = '%f', `Enter_Y` = '%f', `Enter_Z` = '%f', \
    `Exit_X` = '%f', `Exit_Y` = '%f', `Exit_Z` = '%f', `Cost` = '%d', `Level` = '%d', \
    `Interior` = '%d', `Lock` = '%d', `Money` = '%d', `EnterPrice` = '%.4f', `Products` = '%d', \
    `ProdPrice` = '%.4f', `Krasher`='%d', `BuyCost`='%d', `NeedItem`='%d',`Item0`='%d',`Item2`='%d', \
    `Item3`='%d',`Item4`='%d',`Item5`='%d',`Item6`='%d', `Item7`='%d',`Item8`='%d',`Item9`='%d',\
    `Item10`='%d',`Item11`='%d',`Item12`='%d',`Item13`='%d',`Item14`='%d',`Item15`='%d',\
    `Item16`='%d',`Item17`='%d',`Item18`='%d',`Item19`='%d',`DayOfWeak0`='%d',\
    `DayOfWeak1`='%d',`DayOfWeak2`='%d',`DayOfWeak3`='%d',`DayOfWeak4`='%d',`DayOfWeak5`='%d',`DayOfWeak6`='%d',`Zam` ='%s' WHERE `ID` = '%i'",
    BizInfo[bizid][bState],
    BizInfo[bizid][bName],
    BizInfo[bizid][bOwner],
     BizInfo[bizid][bEnter_X],
    BizInfo[bizid][bEnter_Y],
    BizInfo[bizid][bEnter_Z],
    BizInfo[bizid][bExit_X],
    BizInfo[bizid][bExit_Y],
    BizInfo[bizid][bExit_Z],
    BizInfo[bizid][bCost],
    BizInfo[bizid][bLevel],
    BizInfo[bizid][bInt],
    BizInfo[bizid][bLock],
    BizInfo[bizid][bMoney],
    BizInfo[bizid][bEnterPrice],
    BizInfo[bizid][bProducts],
    BizInfo[bizid][bProdPrice],
    BizInfo[bizid][bKrasher],
    BizInfo[bizid][bBuyCost],
    BizInfo[bizid][bNeedItem],
    BizInfo[bizid][bItem0],
    BizInfo[bizid][bItem2],
    BizInfo[bizid][bItem3],
    BizInfo[bizid][bItem4],
    BizInfo[bizid][bItem5],
    BizInfo[bizid][bItem6],
    BizInfo[bizid][bItem7],
    BizInfo[bizid][bItem8],
    BizInfo[bizid][bItem9],
    BizInfo[bizid][bItem10],
    BizInfo[bizid][bItem11],
    BizInfo[bizid][bItem12],
    BizInfo[bizid][bItem13],
    BizInfo[bizid][bItem14],
    BizInfo[bizid][bItem15],
    BizInfo[bizid][bItem16],
    BizInfo[bizid][bItem17],
    BizInfo[bizid][bItem18],
    BizInfo[bizid][bItem19],
    BizInfo[bizid][bDayOfWeak0],
    BizInfo[bizid][bDayOfWeak1],
    BizInfo[bizid][bDayOfWeak2],
    BizInfo[bizid][bDayOfWeak3],
    BizInfo[bizid][bDayOfWeak4],
    BizInfo[bizid][bDayOfWeak5],
    BizInfo[bizid][bDayOfWeak6],
    BizInfo[bizid][bZam],
    BizInfo[bizid][bOpisanie],
    BizInfo[bizid][bID]);
    
    mysql_tquery(mysql, string);
    return 1;
}



Код:
stock LoadBiz()
{
    new Cache:result = mysql_query(mysql, "SELECT * FROM `businesses`");
    OWNABLEBIZES = cache_get_row_count(mysql);
    for(new idx = 0;idx < OWNABLEBIZES; idx++)
    {
        BizInfo[idx][bID] = cache_get_row_int(idx, 0, mysql);
        BizInfo[idx][bState] = cache_get_row_int(idx, 1, mysql);
        cache_get_row(idx, 2, BizInfo[idx][bName], mysql, 64);
         cache_get_row(idx, 3, BizInfo[idx][bOwner], mysql, 24);
        BizInfo[idx][bEnter_X] = cache_get_row_float(idx, 4, mysql);
        BizInfo[idx][bEnter_Y] = cache_get_row_float(idx, 5, mysql);
         BizInfo[idx][bEnter_Z] = cache_get_row_float(idx, 6, mysql);
         BizInfo[idx][bExit_X] = cache_get_row_float(idx, 7, mysql);
         BizInfo[idx][bExit_Y] = cache_get_row_float(idx, 8, mysql);
         BizInfo[idx][bExit_Z] = cache_get_row_float(idx, 9, mysql);
         BizInfo[idx][bCost] = cache_get_row_int(idx, 10, mysql);
         BizInfo[idx][bLevel] = cache_get_row_int(idx, 11, mysql);
         BizInfo[idx][bInt] = cache_get_row_int(idx, 12, mysql);
         BizInfo[idx][bLock] = cache_get_row_int(idx, 13, mysql);
         BizInfo[idx][bMoney] = cache_get_row_int(idx, 14, mysql);
         BizInfo[idx][bEnterPrice] = cache_get_row_int(idx, 15, mysql);
        BizInfo[idx][bProducts] = cache_get_row_int(idx, 16, mysql);
         BizInfo[idx][bProdPrice] = cache_get_row_int(idx, 17, mysql);
         BizInfo[idx][bKrasher] = cache_get_row_int(idx, 18, mysql);
         BizInfo[idx][bBuyCost] = cache_get_row_int(idx, 19, mysql);
         BizInfo[idx][bNeedItem] = cache_get_row_int(idx, 20, mysql);
         BizInfo[idx][bItem0] = cache_get_row_int(idx, 21, mysql);
        BizInfo[idx][bItem2] = cache_get_row_int(idx, 22, mysql);
        BizInfo[idx][bItem3] = cache_get_row_int(idx, 23, mysql);
        BizInfo[idx][bItem4] = cache_get_row_int(idx, 24, mysql);
        BizInfo[idx][bItem5] = cache_get_row_int(idx, 25, mysql);
        BizInfo[idx][bItem6] = cache_get_row_int(idx, 26, mysql);
        BizInfo[idx][bItem7] = cache_get_row_int(idx, 27, mysql);
        BizInfo[idx][bItem8] = cache_get_row_int(idx, 28, mysql);
        BizInfo[idx][bItem9] = cache_get_row_int(idx, 29, mysql);
        BizInfo[idx][bItem10] = cache_get_row_int(idx, 30, mysql);
        BizInfo[idx][bItem11] = cache_get_row_int(idx, 31, mysql);
        BizInfo[idx][bItem12] = cache_get_row_int(idx, 32, mysql);
        BizInfo[idx][bItem13] = cache_get_row_int(idx, 33, mysql);
        BizInfo[idx][bItem14] = cache_get_row_int(idx, 34, mysql);
        BizInfo[idx][bItem15] = cache_get_row_int(idx, 35, mysql);
        BizInfo[idx][bItem16] = cache_get_row_int(idx, 36, mysql);
        BizInfo[idx][bItem17] = cache_get_row_int(idx, 37, mysql);
        BizInfo[idx][bItem18] = cache_get_row_int(idx, 38, mysql);
        BizInfo[idx][bItem19] = cache_get_row_int(idx, 39, mysql);
        BizInfo[idx][bDayOfWeak0] = cache_get_row_int(idx, 40, mysql);
        BizInfo[idx][bDayOfWeak1] = cache_get_row_int(idx, 41, mysql);
        BizInfo[idx][bDayOfWeak2] = cache_get_row_int(idx, 42, mysql);
        BizInfo[idx][bDayOfWeak3] = cache_get_row_int(idx, 43, mysql);
        BizInfo[idx][bDayOfWeak4] = cache_get_row_int(idx, 44, mysql);
        BizInfo[idx][bDayOfWeak5] = cache_get_row_int(idx, 45, mysql);
        BizInfo[idx][bDayOfWeak6] = cache_get_row_int(idx, 46, mysql);
        cache_get_row(idx, 47, BizInfo[idx][bZam], mysql, 24);
        cache_get_row(idx, 48, BizInfo[idx][bOpisanie], mysql, 32);
    }
    cache_delete(result, mysql);
    return 1;
}


База данных (businesses):

Чтобы видеть скрытое содержание Зарегистрируйтесь на форуме!
 
Сверху Снизу