В теме 6 сообщений

Гость
Новичок

Система написана на MySQL R7, динамическое создание группировок.
Функционал:

- создание банды из игры.
- смена спавна банды
- смена имени банды
- смена скина


 

Спойлер

enum // Dialog's
{
        d_creategangname,
        d_gangname,
        d_ganginfo,
        d_gangskin,
        d_gangstats
};
#define MAX_CLAN 200
enum cInfo
{
        id,
        Name[MAX_PLAYER_NAME],
        Level,
        Driftscore,
        Money,
        Maxplayer,
        Skin,
        Float:  SpawnX,
        Float:  SpawnY,
        Float:  SpawnZ,
        Float:  SpawnA,
};
new CInfo[MAX_CLAN][cInfo];
new TOTALCLAN;

 

Спойлер

#define PlayerName(%0)  PlayerInfo[%0][Name]
#define TABLE_CLAN              "clan"
#define f(%1,                   format(%1,sizeof(%1),
#define publics:%0(%1)  forward %0(%1); public %0(%1)

 

Спойлер

    if(GetPVarInt(playerid, "ClanMember") == 0) SetPlayerSkin(playerid, GetPVarInt(playerid, "Skin"));
    else SetPlayerSkin(playerid, CInfo[GetPVarInt(playerid, "ClanMember")][Skin]);
    if(GetPVarInt(playerid, "ClanMember") != 0)
    {
                SetPlayerPos(playerid,CInfo[GetPVarInt(playerid, "ClanMember")][SpawnX],CInfo[GetPVarInt(playerid, "ClanMember")][SpawnY],CInfo[GetPVarInt(playerid, "ClanMember")][SpawnZ]);
                SetPlayerFacingAngle(playerid, CInfo[GetPVarInt(playerid, "ClanMember")][SpawnA]);
                SetPlayerInterior(playerid,0);
                SetPlayerVirtualWorld(playerid, 0);
                return 1;
    }

 

Спойлер

                case d_gangstats:
        {
            switch(listitem)
            {
                case 0:
                                {
                                        if(GetPVarInt(playerid, "ClanLeader") != 0) return SendMes(playerid, color_red, "Ты и так управляющий %s",CInfo[GetPVarInt(playerid, "ClanLeader")][Name]);
                                        if(GetPVarInt(playerid, "ClanMember") != 0) return SendMes(playerid, color_red, "Ты и так уже в %s",CInfo[GetPVarInt(playerid, "ClanMember")][Name]);
                                        if(GetPVarInt(playerid, "Money") < 200000) return SendClientMessage(playerid, color_grey, "У тебя нету денег для создания банды, нужно $200.000");
                                        if(GetPVarInt(playerid, "Level") < 50) return SendClientMessage(playerid, color_grey, "У тебя не достаточно опыта для реководства бандой, нужен 50лвл.");
                                        ShowPlayerDialog(playerid,d_creategangname,DIALOG_STYLE_INPUT,"{FF0000}Создание банды",
                                        ""W"Тебе доступна функция создания своей группировки.\n\
                                        Для создания группировки необходимо иметь на руках "L"$"R"200"L" 000 и 50 уровень\n\
                                        "W"Если вы не передумали в создании группировки, введите имя вашей будущей банды в поле ниже:\n\n\
                                        "L"Возможности:\n"R"-"W" Смена названия банды, транспорта, места появления, одежды\n\
                                         "R"-"W" Война за территории между кланами и многое другое..","Создать","Отмена");
                                }
                case 1:
                {
                    if(GetPVarInt(playerid, "ClanLeader") != 0)
                                        {
                                                new listitems[] = "Смена spawn'a\nСмена названия\nСмена одежды";
                                                f(stringj,"{FF0000}Редактор %s", CInfo[GetPVarInt(playerid, "ClanLeader")][Name]);
                                                ShowPlayerDialog(playerid, d_ganginfo, DIALOG_STYLE_LIST, stringj, listitems, "Принять", "Отмена");
                                        }
                                        else SendClientMessage(playerid, color_grey, "У тебя нет доступа к этому меню");
                }
                case 2: return 1;
            }
            return 1;
        }
                case d_ganginfo:
                {
                    if(response == 1)
                    {
                            if(listitem == 0)
                            {
                                new str[250];
                                new leader = GetPVarInt(playerid, "ClanLeader");
                                        if(GetPlayerInterior(playerid) != 0) return SendClientMessage(playerid, color_white,"Тут невозможно создать спавн!");
                                        GetPlayerPos(playerid,CInfo[leader][SpawnX],CInfo[leader]
[SpawnY],CInfo[leader][SpawnZ]);
                                        GetPlayerFacingAngle(playerid,CInfo[leader][SpawnA]);
                                        f(str, "UPDATE `"TABLE_CLAN"` SET `SpawnX` = %f, `SpawnY` = %f, `SpawnZ` = %f, `SpawnA` = %f WHERE `id` = '%i'",
                                        CInfo[leader][SpawnX], CInfo[leader][SpawnY], CInfo[leader][SpawnZ], CInfo[leader][SpawnA], leader), mysql_query(str, -1, -1, PAWNO_CODER);
                                        SendMes(playerid, color_red, "Спавн банды %s был изменён",CInfo[leader][Name]);
                                }
                                if(listitem == 1)
                                {
                                ShowPlayerDialog(playerid,d_gangname,DIALOG_STYLE_INPUT,"{FF0000}Смена имени банды","{FFFFFF}Введите имя банды!","Сменить","Отмена");
                                }
                                if(listitem == 2)
                                {
                                ShowPlayerDialog(playerid,d_gangskin,DIALOG_STYLE_INPUT,"{FF0000}Смена скина банды","{FFFFFF}Введите id cкина для банды","Сменить","Отмена");
                                }
                        }
                        return 1;
                }
                case d_gangname:
                {
                    if(response == 1)
                    {
                        strmid(CInfo[GetPVarInt(playerid, "ClanLeader")][Name], inputtext, 0, strlen(inputtext), MAX_PLAYER_NAME);
                        CInfo[GetPVarInt(playerid, "ClanLeader")][Name] = strval(inputtext);
                        format(CInfo[GetPVarInt(playerid, "ClanLeader")][Name],32,inputtext);
                                SetClanStr(GetPVarInt(playerid, "ClanLeader"), "Name", inputtext);
                                SendMes(playerid, color_red, "Новое имя банды : (ID:%d) %s",GetPVarInt(playerid, "ClanLeader"),inputtext);
                        }
                        return 1;
                }
                case d_gangskin:
                {
                    if(response == 1)
                    {
                                new str[250];
                            CInfo[GetPVarInt(playerid, "ClanLeader")][Skin] = strval(inputtext);
                                f(str, "UPDATE `"TABLE_CLAN"` SET `Skin` = %i WHERE `id` = '%i'",
                                CInfo[GetPVarInt(playerid, "ClanLeader")][Skin], GetPVarInt(playerid, "ClanLeader")), mysql_query(str, -1, -1, PAWNO_CODER);
                            SetPlayerSkin(playerid, CInfo[GetPVarInt(playerid, "ClanLeader")][Skin]);
                            SendMes(playerid, color_red, "Вы сменили скин банды на: %i",CInfo[GetPVarInt(playerid, "ClanLeader")][Skin]);
                        }
                        return 1;
                }
                case d_creategangname:
                {
                    if(response == 1)
                    {
                        TOTALCLAN++;
                                static query_mysql[350];
                                CInfo[TOTALCLAN][id] = TOTALCLAN;
                                CInfo[TOTALCLAN][Level] = 0;
                                CInfo[TOTALCLAN][Driftscore] = 0;
                                CInfo[TOTALCLAN][Money] = 0;
                                CInfo[TOTALCLAN][Maxplayer] = 10;
                                CInfo[TOTALCLAN][SpawnX] = 1672.4862;
                                CInfo[TOTALCLAN][SpawnY] = -2275.4907;
                                CInfo[TOTALCLAN][SpawnZ] = -1.2467;
                                CInfo[TOTALCLAN][SpawnA] = 259.1288;
                                SetPVarInt(playerid, "ClanLeader", TOTALCLAN);
                                SetPVarInt(playerid, "ClanMember", TOTALCLAN);
                                strmid(CInfo[TOTALCLAN][Name], inputtext, 0, strlen(inputtext), MAX_PLAYER_NAME);
                                f(query_mysql, "INSERT INTO `"TABLE_CLAN"` (`id`, `Name`, `Level`, `Driftscore`, `Money`, `Maxplayer`, `Skin`, `SpawnX`, `SpawnY`, `SpawnZ`, `SpawnA`) VALUES ('%i', '%s', '0', '0', '0', '10', '%i', '1672.4862', '-2275.4907', '-1.2467', '259.1288')",
                                TOTALCLAN, inputtext, GetPlayerSkin(playerid)), mysql_function_query(PAWNO_CODER, query_mysql, false, "","");
                        SendMes(playerid, color_red, "Ты успешно создал свою группировку! Её номер: "A"%i",TOTALCLAN);
                        SendMes(playerid, color_red, "Название твоей группировки: "A"%s",inputtext);
                        SendMes(playerid, color_red, "Для управления ею используй "A"'Главное меню "L">> "A"Разное "L">> "A"Группировка'");
                        }
                        return 1;
                }

 

Спойлер

forward LoadClanInfo();
public LoadClanInfo()
{
    new time = GetTickCount();
    new temp[32],rows,fields;
    cache_get_data(rows,fields,PAWNO_CODER);
    if(rows)
    {
        for(new idx = 1; idx <= rows; idx++)
        {
            cache_get_field_content(0,"id",temp,PAWNO_CODER), CInfo[idx][id] = strval(temp);
            cache_get_field_content(0,"Name",CInfo[idx][Name],PAWNO_CODER);

                cache_get_field_content(0,"Level",temp,PAWNO_CODER), CInfo[idx][Level] = strval(temp);
            cache_get_field_content(0,"Driftscore",temp,PAWNO_CODER), CInfo[idx][Driftscore] = strval(temp);
            cache_get_field_content(0,"Money",temp,PAWNO_CODER), CInfo[idx][Money] = strval(temp);
            cache_get_field_content(0,"Maxplayer",temp,PAWNO_CODER), CInfo[idx][Maxplayer] = strval(temp);
            cache_get_field_content(0,"Skin",temp,PAWNO_CODER), CInfo[idx][Skin] = strval(temp);
            cache_get_field_content(0,"SpawnX",temp,PAWNO_CODER), CInfo[idx][SpawnX] = floatstr(temp);
            cache_get_field_content(0,"SpawnY",temp,PAWNO_CODER), CInfo[idx][SpawnY] = floatstr(temp);
            cache_get_field_content(0,"SpawnZ",temp,PAWNO_CODER), CInfo[idx][SpawnZ] = floatstr(temp);
                cache_get_field_content(0,"SpawnA",temp,PAWNO_CODER), CInfo[idx][SpawnA] = floatstr(temp);
            TOTALCLAN++;
                }
    }
    printf(" [SMSG]: Успешная загрузка 'LoadClan' - загружено %d за %d м.с", TOTALCLAN,GetTickCount() - time);
}

stock SetClanInt(idx, stolb[], znach)
{
        new query[128];
        f(query, "UPDATE "TABLE_CLAN" SET  %s = '%i' WHERE id = '%i' LIMIT 1", stolb, znach, idx);
        return mysql_query(query, -1, -1, PAWNO_CODER);
}
stock SetClanStr(idx, stolb[], znach[])
{
        new query[128];
        f(query, "UPDATE "TABLE_CLAN" SET  %s = '%s' WHERE id = '%i' LIMIT 1", stolb, znach, idx);
        return mysql_query(query, -1, -1, PAWNO_CODER);
}

 

Спойлер

CREATE TABLE `clan` (
  `id` int(20) NOT NULL auto_increment,
  `Name` varchar(32) character set utf8 NOT NULL default 'None',
  `Level` int(11) NOT NULL default '0',
  `Driftscore` int(11) NOT NULL default '0',
  `Money` int(11) NOT NULL default '0',
  `Maxplayer` int(11) NOT NULL default '10',
  `Skin` int(11) NOT NULL default '0',
  `SpawnX` varchar(32) character set utf8 NOT NULL default '0.0',
  `SpawnY` varchar(32) character set utf8 NOT NULL default '0.0',
  `SpawnZ` varchar(32) character set utf8 NOT NULL default '0.0',
  `SpawnA` varchar(32) character set utf8 NOT NULL default '0.0',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=16 DEFAULT CHARSET=cp1251 COLLATE=cp1251_bin AUTO_INCREMENT=16 ;

 


Автор: JoinT

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


Ссылка на сообщение
Поделиться на другие сайты
LilPokemon
Гуру форума
В 22.11.2017 в 23:58, SCRIPTMAN сказал:

Неплохо, но использовать формат в дефайне - лишнее.

Кому как удобней ) 

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


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

Для публикации сообщений создайте учётную запись или авторизуйтесь

Вы должны быть пользователем, чтобы оставить комментарий

Создать учетную запись

Зарегистрируйте новую учётную запись в нашем сообществе. Это очень просто!


Регистрация нового пользователя

Войти

Уже есть аккаунт? Войти в систему.


Войти

  • Последние посетители   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. Помогите пожалуйста