Вопросы

erg rfbfdh
Новичок
    }
        case dCreatehouse1:
        {
            if(!response) return 1;
            gCreatehouse[playerid][chouseHint] = listitem;
            show_dialog(playerid,dCreatehouse2,1,"Ñîçäàíèå æèëèùà","Óêàæèòå öåíó çà êâàðòèðó/äîì (îò 1 òûñ. äî 15 ìëí.)","Äàëåå","Âûõîä");
        }
        case dCreatehouse2:
        {
            if(!response) return 1;
            new price = strval(inputtext);
            if(!isNumeric(inputtext) || price < 1000 || price > 15000000)
            {
                SendClientMessage(playerid,CRED,"Íåâåðíàÿ öåíà");
                show_dialog(playerid,dCreatehouse2,1,"Ñîçäàíèå æèëèùà","Óêàæèòå öåíó çà êâàðòèðó/äîì (îò 1 òûñ. äî 15 ìëí.)","Äàëåå","Âûõîä");
                return 1;
            }
            gCreatehouse[playerid][chousePrice] = price;
            show_dialog(playerid,dCreatehouse3,2,"Ñîçäàíèå æèëèùà","Ýêîíîì êëàññ\nÑðåäíèé êëàññ\nÝëèòíûé êëàññ\nÎñîáíÿê","Ñîçäàòü","Âûõîä");
        }
        case dCreatehouse3:
        {
            if(!response) return 1;
            new clas=listitem;
            new Float:x, Float:y, Float:z, Float:r;
            GetPlayerPos(playerid,x,y,z);
            GetPlayerFacingAngle(playerid,r);
            
            new f_str[512];
            format(f_str,sizeof(f_str),"INSERT INTO `houses` VALUES('','%d','3','%d','%d','0|0|0|0|0','0|0|0|0|0|0|0|0|0','0|0|0|0','0','0','0','0','0','%f','%f','%f','%f','','','','','','','','','','','','')",clas,gCreatehouse[playerid][chousePrice],gCreatehouse[playerid][chouseHint],x,y,z,r);
            new Cache:result = mysql_query(dbHandle, f_str);
            
            new houseid = cache_insert_id();
            cache_delete(result);
            new i = houseid - 1;
            gHouses[i][houseID] = houseid;
            gHouses[i][houseClass] = clas;
            gHouses[i][housePrice] = gCreatehouse[playerid][chousePrice];
            gHouses[i][houseHint] = gCreatehouse[playerid][chouseHint];
            gHouses[i][houseX] = x;
            gHouses[i][houseY] = y;
            gHouses[i][houseZ] = z;
            gHouses[i][houseR] = r;
            gHouseArea[i] = CreateDynamicSphere(gHouses[i][houseX],gHouses[i][houseY],gHouses[i][houseZ],2.0,0,0,-1);
            gHousePickup[i] = CreateDynamicPickup(1273,1,gHouses[i][houseX],gHouses[i][houseY],gHouses[i][houseZ]);
        }
        case dCreatebiz1:
        {
            if(!response) return 1;
            gCreatebiz[playerid][chouseBint] = listitem + 1;
            show_dialog(playerid,dCreatebiz2,1,"Ñîçäàíèå áèçíåñà","Óêàæèòå öåíó çà áèçíåñ (îò 1 òûñ. äî 10 ìëí.)","Äàëåå","Âûõîä");
        }
        case dCreatebiz2:
        {
            if(!response) return 1;
            new sellprice = strval(inputtext);
            if(!isNumeric(inputtext) || sellprice < 1000 || sellprice > 10000000)
            {
                SendClientMessage(playerid,CRED,"Íåâåðíàÿ öåíà");
                show_dialog(playerid,dCreatebiz2,1,"Ñîçäàíèå áèçíåñà","Óêàæèòå öåíó çà áèçíåñ (îò 1 òûñ. äî 10 ìëí.)","Äàëåå","Âûõîä");
                return 1;
            }
            gCreatebiz[playerid][chouseSellprice] = sellprice;
            show_dialog(playerid,dCreatebiz3,2,"Ñîçäàíèå áèçíåñà","Ïðîä ìàãàçèí\nÇàêóñî÷íàÿ\n24/7\nÁàð\nÊëóá\n24/7(íå ðàáîòàåò)\nÌàãàçèí îäåæäû\nÀâòîìàñòåðñêàÿ(íå ðàáîòàåò)\nÌàãàçèí îðóæèÿ\nÏèðîòåõíèêà\nÐåñòîðàí\nÏåéíòáîë(íå ðàáîòàåò)\nÐèåëòîðêà\nÀâòîñàëîí\nÀêñåñóàðû","Ñîçäàòü","Âûõîä");
        }
        case dCreatebiz3:
        {
            if(!response) return 1;
            new type = listitem++;
            gCreatebiz[playerid][chouseType] = type + 1;
            show_dialog(playerid,dCreatebiz4,1,"Ñîçäàíèå áèçíåñà","Íàçâàíèå áèçíåñà","Äàëåå","Âûõîä");
        }
        case dCreatebiz4:
        {
            if(!response) return 1;
            new name[55];
            format(name ,sizeof(name),"%s",inputtext);
        //  new name[55] = strval(inputtext);
            gCreatebiz[playerid][chouseName] = name;
            new Float:x, Float:y, Float:z, Float:r;
            GetPlayerPos(playerid,x,y,z);
            GetPlayerFacingAngle(playerid,r);
            //total_biz
            //format(f_str,sizeof(f_str),"INSERT INTO `business` VALUES('','%s','%d','%d','0','%d','0','0','0','1','%f','%f','%f','%f','','')",name,type,bint,price,x,y,z,r);
            new f_str[612];
            format(f_str,sizeof(f_str),"INSERT INTO `business` VALUES('','%s','%d','%d','0','%d','0','0','0','1','%f','%f','%f','%f','0','0','0','0','0','0')",gCreatebiz[playerid][chouseName],gCreatebiz[playerid][chouseType],gCreatebiz[playerid][chouseBint],gCreatebiz[playerid][chouseSellprice] ,x,y,z,r);
            new Cache:result = mysql_query(dbHandle, f_str);
            new businessid = cache_insert_id();
            //new businessid = total_biz + 1;
            cache_delete(result);
            new i = businessid - 1;
            b_info[i][busiName] = gCreatebiz[playerid][chouseName];
            b_info[i][busiID] = businessid;
            b_info[i][busiType] = gCreatebiz[playerid][chouseType];
            b_info[i][busiSellPrice] = gCreatebiz[playerid][chouseSellprice];
            b_info[i][busiBint] = gCreatebiz[playerid][chouseBint];
            b_info[i][busiX] = x;
            b_info[i][busiY] = y;
            b_info[i][busiZ] = z;
            b_info[i][busiR] = r;
            //gHouseArea[i] = CreateDynamicSphere(gHouses[i][houseX],gHouses[i][houseY],gHouses[i][houseZ],2.0,0,0,-1);
            //gHousePickup[i] = CreateDynamicPickup(1273,1,gHouses[i][houseX],gHouses[i][houseY],gHouses[i][houseZ]);
        }

помогите создать команду для создание бизнеса и дома

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

6 ответов на этот вопрос

  • 0
sinvays
Гуру форума
CMD:createhouse(playerid, params[])
{
    show_dialog(playerid, dCreatehouse1, 2, "Создание жилья", "Выберите тип жилья", "Далее", "Выход");
    return 1;
}

CMD:createbiz(playerid, params[])
{
    show_dialog(playerid, dCreatebiz1, 2, "Создание бизнеса", "Выберите интерьер бизнеса", "Далее", "Выход");
    return 1;
}

 

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты
  • 0
RayanBueno
Освоившийся

полностью аккуратно переписанный create house / create biz, без багов со строками, listitem++, с проверками и безопасным SQL.

 

1. Структуры данных

 

// ===== CREATE HOUSE =====
enum eCreateHouse
{
    chHint,
    chPrice
}
new gCreateHouse[MAX_PLAYERS][eCreateHouse];

// ===== CREATE BIZ =====
enum eCreateBiz
{
    cbBint,
    cbSellPrice,
    cbType,
    cbName[55]
}
new gCreateBiz[MAX_PLAYERS][eCreateBiz];

// ===== CREATE HOUSE =====
enum eCreateHouse
{
    chHint,
    chPrice
}
new gCreateHouse[MAX_PLAYERS][eCreateHouse];

// ===== CREATE BIZ =====
enum eCreateBiz
{
    cbBint,
    cbSellPrice,
    cbType,
    cbName[55]
}
new gCreateBiz[MAX_PLAYERS][eCreateBiz];

 

2. CREATE HOUSE (чисто и стабильно)

dCreatehouse1 — подсказка

case dCreatehouse1:
{
    if(!response) return 1;
    gCreateHouse[playerid][chHint] = listitem;

    show_dialog(playerid, dCreatehouse2, 1,
        "Создание жилья",
        "Укажите цену (1 000 – 15 000 000)",
        "Далее", "Выход"
    );
}

 

dCreatehouse2 — цена

case dCreatehouse2:
{
    if(!response) return 1;

    if(!isNumeric(inputtext))
        return SendClientMessage(playerid, CRED, "Введите число");

    new price = strval(inputtext);
    if(price < 1000 || price > 15000000)
        return SendClientMessage(playerid, CRED, "Цена от 1 000 до 15 000 000");

    gCreateHouse[playerid][chPrice] = price;

    show_dialog(playerid, dCreatehouse3, 2,
        "Создание жилья",
        "Эконом\nСредний\nЭлитный\nОсобняк",
        "Создать", "Выход"
    );
}

dCreatehouse3 — создание

case dCreatehouse3:
{
    if(!response) return 1;

    new Float:x, Float:y, Float:z, Float:r;
    GetPlayerPos(playerid, x, y, z);
    GetPlayerFacingAngle(playerid, r);

    new class = listitem;

    new query[512];
    format(query, sizeof(query),
        "INSERT INTO houses "
        "(class, price, hint, x, y, z, r) "
        "VALUES (%d, %d, %d, %f, %f, %f, %f)",
        class,
        gCreateHouse[playerid][chPrice],
        gCreateHouse[playerid][chHint],
        x, y, z, r
    );

    mysql_query(dbHandle, query);
    new houseid = cache_insert_id();

    new i = houseid - 1;
    gHouses[i][houseID]    = houseid;
    gHouses[i][houseClass] = class;
    gHouses[i][housePrice] = gCreateHouse[playerid][chPrice];
    gHouses[i][houseHint]  = gCreateHouse[playerid][chHint];
    gHouses[i][houseX] = x;
    gHouses[i][houseY] = y;
    gHouses[i][houseZ] = z;
    gHouses[i][houseR] = r;

    gHouseArea[i]   = CreateDynamicSphere(x, y, z, 2.0);
    gHousePickup[i] = CreateDynamicPickup(1273, 1, x, y, z);

    SendClientMessage(playerid, CGREEN, "Дом успешно создан");
}

3. CREATE BUSINESS (правильно и безопасно)

dCreatebiz1 — интерьер

case dCreatebiz1:
{
    if(!response) return 1;
    gCreateBiz[playerid][cbBint] = listitem + 1;

    show_dialog(playerid, dCreatebiz2, 1,
        "Создание бизнеса",
        "Цена бизнеса (1 000 – 10 000 000)",
        "Далее", "Выход"
    );
}

dCreatebiz2 — цена

case dCreatebiz2:
{
    if(!response) return 1;

    if(!isNumeric(inputtext))
        return SendClientMessage(playerid, CRED, "Введите число");

    new price = strval(inputtext);
    if(price < 1000 || price > 10000000)
        return SendClientMessage(playerid, CRED, "Цена от 1 000 до 10 000 000");

    gCreateBiz[playerid][cbSellPrice] = price;

    show_dialog(playerid, dCreatebiz3, 2,
        "Создание бизнеса",
        "Продукты\nЗакусочная\n24/7\nБар\nКлуб\nОдежда\nСТО\nОружие\nРесторан",
        "Далее", "Выход"
    );
}

dCreatebiz3 — тип

case dCreatebiz3:
{
    if(!response) return 1;
    gCreateBiz[playerid][cbType] = listitem + 1;

    show_dialog(playerid, dCreatebiz4, 1,
        "Создание бизнеса",
        "Введите название бизнеса",
        "Создать", "Выход"
    );
}

dCreatebiz4 — создание

case dCreatebiz4:
{
    if(!response) return 1;

    if(strlen(inputtext) < 3 || strlen(inputtext) > 50)
        return SendClientMessage(playerid, CRED, "Название от 3 до 50 символов");

    format(gCreateBiz[playerid][cbName], 55, "%s", inputtext);

    new name_esc[110];
    mysql_escape_string(gCreateBiz[playerid][cbName], name_esc);

    new Float:x, Float:y, Float:z, Float:r;
    GetPlayerPos(playerid, x, y, z);
    GetPlayerFacingAngle(playerid, r);

    new query[512];
    format(query, sizeof(query),
        "INSERT INTO business "
        "(name, type, bint, price, x, y, z, r) "
        "VALUES ('%s', %d, %d, %d, %f, %f, %f, %f)",
        name_esc,
        gCreateBiz[playerid][cbType],
        gCreateBiz[playerid][cbBint],
        gCreateBiz[playerid][cbSellPrice],
        x, y, z, r
    );

    mysql_query(dbHandle, query);
    new bizid = cache_insert_id();

    new i = bizid - 1;
    b_info[i][busiID] = bizid;
    format(b_info[i][busiName], 55, "%s", gCreateBiz[playerid][cbName]);
    b_info[i][busiType] = gCreateBiz[playerid][cbType];
    b_info[i][busiBint] = gCreateBiz[playerid][cbBint];
    b_info[i][busiSellPrice] = gCreateBiz[playerid][cbSellPrice];
    b_info[i][busiX] = x;
    b_info[i][busiY] = y;
    b_info[i][busiZ] = z;
    b_info[i][busiR] = r;

    SendClientMessage(playerid, CGREEN, "Бизнес успешно создан");
}

 

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты
Гость
Эта тема закрыта для публикации ответов.

  • Последние посетители   0 пользователей онлайн

    Ни одного зарегистрированного пользователя не просматривает данную страницу

  • Похожий контент

    • patrickk
      От patrickk
      Всем привет, решил написать dm сервер и довольно хорошим получился, даже на голову выше Goat dm. Оставил не решенную проблему тем что  у меня есть 4 локации с rp run и cj run ну а как добавить cj бег на те локации не знаю и как эта система работает. Надеюсь мне помогут знающие люди
    • Samolet
      От Samolet
      Здраствуйте, cоздаю копию Arizona на ОМП, опен мультиплеер, загрузил и подключил бд, но сервер не хочет вот лог :[2026-10-20T21:03:32+0300] [Info] Log file reloaded. Starting open.mp server (1.5.8.3079) from commit c6759bd8d265171ae3d86598895a23d5a8d92a3b Loading component $CAPI.so Successfully loaded component C-API (1.5.8.3079) with UID 10467dd8d4c56fc6 Loading component LegacyConfig.so Successfully loaded component LegacyConfig (1.5.8.3079) with UID 24ef6216838f9ffc Loading component NPCs.so Successfully loaded component NPCs (1.5.8.3079) with UID 3d0e59e87f4e90bc Loading component Recordings.so Successfully loaded component Recordings (1.5.8.3079) with UID 871144d399f5f613 Loading component Checkpoints.so Successfully loaded component Checkpoints (1.5.8.3079) with UID 44a937350d611dde Loading component TextDraws.so Successfully loaded component TextDraws (1.5.8.3079) with UID 9b5dc2b1d15c992a Loading component Pawn.so Successfully loaded component Pawn (1.5.8.3079) with UID 78906cd9f19c36a6 Loading component GangZones.so Successfully loaded component GangZones (1.5.8.3079) with UID b3351d11ee8d8056 Loading component Actors.so Successfully loaded component Actors (1.5.8.3079) with UID c81ca021eae2ad5c Loading component Pickups.so Successfully loaded component Pickups (1.5.8.3079) with UID cf304faa363dd971 Loading component Dialogs.so Successfully loaded component Dialogs (1.5.8.3079) with UID 44a111350d611dde Loading component Objects.so Successfully loaded component Objects (1.5.8.3079) with UID 59f8415f72da6160 Loading component Console.so Successfully loaded component Console (1.5.8.3079) with UID bfa24e49d0c95ee4 Loading component TextLabels.so Successfully loaded component TextLabels (1.5.8.3079) with UID a0c57ea80a009742 Loading component Variables.so Successfully loaded component Variables (1.5.8.3079) with UID 75e121848bc01fa2 Loading component Databases.so Successfully loaded component Databases (1.5.8.3079) with UID 80092e7eb5821a96 Loading component LegacyNetwork.so Successfully loaded component RakNetLegacyNetwork (1.5.8.3079) with UID ea9799fd79cf8442 Loading component CustomModels.so Successfully loaded component CustomModels (1.5.8.3079) with UID 15e3cb1e7c77ffff Loading component Menus.so Successfully loaded component Menus (1.5.8.3079) with UID 621e219eb97ee0b2 Loading component Vehicles.so Successfully loaded component Vehicles (1.5.8.3079) with UID 3f1f62ee9e22ab19 Loading component Classes.so Successfully loaded component Classes (1.5.8.3079) with UID 8cfb3183976da208 Loading component Timers.so Successfully loaded component Timers (1.5.8.3079) with UID 2ad8124c5ea257a3 Loaded 22 component(s) from /home/gs113492/components Executing Server Config... [2026-10-20T21:03:33+0300] [Info] Loading plugin: crashdetect.so [2026-10-20T21:03:33+0300] [Info] CrashDetect plugin 4.19 [2026-10-20T21:03:33+0300] [Info] Loading plugin: mapandreas.so [2026-10-20T21:03:33+0300] [Info] Loading plugin: streamer.so [2026-10-20T21:03:33+0300] [Info] *** Streamer Plugin v2.9.4 by Incognito loaded *** [2026-10-20T21:03:33+0300] [Info] Loading plugin: sscanf.so [2026-10-20T21:03:33+0300] [Info] [2026-10-20T21:03:33+0300] [Info] =============================== [2026-10-20T21:03:33+0300] [Info] sscanf plugin loaded. [2026-10-20T21:03:33+0300] [Info] Version: 2.8.3 [2026-10-20T21:03:33+0300] [Info] (c) 2018 Alex "Y_Less" Cole [2026-10-20T21:03:33+0300] [Info] =============================== [2026-10-20T21:03:33+0300] [Info] Loading plugin: TOTP.so [2026-10-20T21:03:33+0300] [Info] TOTP plugin v1.0.1 by Games loaded. [2026-10-20T21:03:33+0300] [Info] Loading plugin: mysql_static.so [2026-10-20T21:03:33+0300] [Info] >> plugin.mysql: R39-6 successfully loaded. [2026-10-20T21:03:33+0300] [Info] Loading plugin: libpawn_json.so [2026-10-20T21:03:34+0300] [Error] Function not registered: YSF_SetTickRate [2026-10-20T21:03:34+0300] [Error] Function not registered: PC_Init [2026-10-20T21:03:34+0300] [Info] [debug] Run time error 19: "File or function is not found" [2026-10-20T21:03:34+0300] [Info] [debug] PC_Init [2026-10-20T21:03:34+0300] [Info] [debug] YSF_SetTickRate [2026-10-20T21:03:34+0300] [Error] File or function is not found [2026-10-20T21:03:34+0300] [Error] Function not registered: PC_RegAlias [2026-10-20T21:03:34+0300] [Error] Function not registered: BS_GetWriteOffset [2026-10-20T21:03:34+0300] [Error] Function not registered: BS_Reset [2026-10-20T21:03:34+0300] [Error] Function not registered: PR_RegHandler [2026-10-20T21:03:34+0300] [Error] Function not registered: BS_Delete [2026-10-20T21:03:34+0300] [Error] Function not registered: BS_New [2026-10-20T21:03:34+0300] [Error] Function not registered: BS_ResetReadPointer [2026-10-20T21:03:34+0300] [Error] Function not registered: BS_SetWriteOffset [2026-10-20T21:03:34+0300] [Error] Function not registered: BS_IgnoreBits [2026-10-20T21:03:34+0300] [Error] Function not registered: PR_Init [2026-10-20T21:03:34+0300] [Error] Function not registered: PR_SendRPC [2026-10-20T21:03:34+0300] [Error] Function not registered: PR_SendPacket [2026-10-20T21:03:34+0300] [Error] Function not registered: BS_WriteValue [2026-10-20T21:03:34+0300] [Error] Function not registered: BS_GetNumberOfBytesUsed [2026-10-20T21:03:34+0300] [Error] Function not registered: BS_ReadValue [2026-10-20T21:03:34+0300] [Error] Function not registered: PC_Init [2026-10-20T21:03:34+0300] [Info] [debug] Run time error 19: "File or function is not found" [2026-10-20T21:03:34+0300] [Info] [debug] PC_Init [2026-10-20T21:03:34+0300] [Info] [debug] BS_ReadValue [2026-10-20T21:03:34+0300] [Info] [debug] BS_GetNumberOfBytesUsed [2026-10-20T21:03:34+0300] [Info] [debug] BS_WriteValue [2026-10-20T21:03:34+0300] [Info] [debug] PR_SendPacket [2026-10-20T21:03:34+0300] [Info] [debug] PR_SendRPC [2026-10-20T21:03:34+0300] [Info] [debug] PR_Init [2026-10-20T21:03:34+0300] [Info] [debug] BS_IgnoreBits [2026-10-20T21:03:34+0300] [Info] [debug] BS_SetWriteOffset [2026-10-20T21:03:34+0300] [Info] [debug] BS_ResetReadPointer [2026-10-20T21:03:34+0300] [Info] [debug] BS_New [2026-10-20T21:03:34+0300] [Info] [debug] BS_Delete [2026-10-20T21:03:34+0300] [Info] [debug] PR_RegHandler [2026-10-20T21:03:34+0300] [Info] [debug] BS_Reset [2026-10-20T21:03:34+0300] [Info] [debug] BS_GetWriteOffset [2026-10-20T21:03:34+0300] [Info] [debug] PC_RegAlias [2026-10-20T21:03:34+0300] [Error] File or function is not found [2026-10-20T21:03:34+0300] [Info] [debug] Run time error 19: "File or function is not found" [2026-10-20T21:03:34+0300] [Info] [debug] PC_Init [2026-10-20T21:03:34+0300] [Info] [debug] YSF_SetTickRate [2026-10-20T21:03:34+0300] [Error] File or function is not found [2026-10-20T21:03:34+0300] [Info] [debug] Run time error 19: "File or function is not found" [2026-10-20T21:03:34+0300] [Info] [debug] PC_Init [2026-10-20T21:03:34+0300] [Info] [debug] BS_ReadValue [2026-10-20T21:03:34+0300] [Info] [debug] BS_GetNumberOfBytesUsed [2026-10-20T21:03:34+0300] [Info] [debug] BS_WriteValue [2026-10-20T21:03:34+0300] [Info] [debug] PR_SendPacket [2026-10-20T21:03:34+0300] [Info] [debug] PR_SendRPC [2026-10-20T21:03:34+0300] [Info] [debug] PR_Init [2026-10-20T21:03:34+0300] [Info] [debug] BS_IgnoreBits [2026-10-20T21:03:34+0300] [Info] [debug] BS_SetWriteOffset [2026-10-20T21:03:34+0300] [Info] [debug] BS_ResetReadPointer [2026-10-20T21:03:34+0300] [Info] [debug] BS_New [2026-10-20T21:03:34+0300] [Info] [debug] BS_Delete [2026-10-20T21:03:34+0300] [Info] [debug] PR_RegHandler [2026-10-20T21:03:34+0300] [Info] [debug] BS_Reset [2026-10-20T21:03:34+0300] [Info] [debug] BS_GetWriteOffset [2026-10-20T21:03:34+0300] [Info] [debug] PC_RegAlias [2026-10-20T21:03:34+0300] [Info] Legacy Network started on ***.**.**.***:2717. Помогите пожалуйста