В теме 3 сообщения

Дорогие пользователи портала PAWNO-RUS.RU

 

Nемного о системе:

Радары можно будет добавлять прямо из игры

Далее они будут сохраняться в базу данных

Ну и так же после рестарта они не удаляться!

Но удалять придется их через саму БД

 

И так начнем:

 

1) Нам понадобятся плагины такие как mysql r-38,scanff,streamer и сам командный процессор

 Теперь начинаем в начало мода вставляем следующее

Спойлер

#define MAX_RADARS                              50
#define publics:%0(%1) forward %0(%1); public %0(%1)
#define SFCM(%0,%1,%2) do{ new msg[141]; format(msg,141,%2); SendClientMessage(%0,%1,msg); } while(FALSE)
#define SCM SendClientMessage
#define TOTAL_RADAR             "`radar`"
new RadarIterator[MAX_RADARS];
new radariter;
#define foreachRadar(%0) for(new _i, %0=RadarIterator[_i]; _i <radariter; %0=RadarIterator[++_i])  

enum rInfo{
        rid,
Float:rX,
Float:rY,
Float:rZ,
Float:rRZ,
Float:rR,
        rSpeed,
        rObj
};
new RadarInfo[MAX_RADARS][rInfo];
new TOTALRADAR;
new RadarTimer[MAX_PLAYERS];
new RadarShtraf[MAX_PLAYERS];
new RadarMaxSpeed[MAX_RADARS];

 

В Public OnPlayerDisconnect 

Спойлер

if(RadarTimer[playerid]!=0){
    RadarShtraf[playerid] = 0;
    KillTimer(RadarTimer[playerid]);
}

 

Теперь загрузку радаров

Спойлер

publics: OnLoadRadarCallback()
{
        new time = GetTickCount();
        new r, f;
        cache_get_data(r, f);
        for(new i = 0; i < r; i++)
        {
                RadarInfo[i][rid] = cache_get_field_content_int(i, "id", mysql);
                RadarInfo[i][rX]  = cache_get_field_content_float(i, "x", mysql);
                RadarInfo[i][rY]  = cache_get_field_content_float(i, "y", mysql);
                RadarInfo[i][rZ]  = cache_get_field_content_float(i, "z", mysql);
                RadarInfo[i][rRZ] = cache_get_field_content_float(i, "rz", mysql);
                RadarInfo[i][rR] = cache_get_field_content_float(i, "rad", mysql);
                RadarInfo[i][rSpeed] = cache_get_field_content_int(i, "speed", mysql);
                RadarInfo[i][rObj] = CreateObject(18880, RadarInfo[i][rX], RadarInfo[i][rY], RadarInfo[i][rZ], 0.0, 0.0, RadarInfo[i][rRZ]);
                new int = CreateDynamicSphere(RadarInfo[i][rX], RadarInfo[i][rY], RadarInfo[i][rZ], RadarInfo[i][rR], 0, 0, -1);
                //Iter_Add(RadarIterator, int);
                RadarIterator[radariter++]=int;
                RadarMaxSpeed[int]=RadarInfo[i][rSpeed];
                TOTALRADAR++;
        }
        printf("[Загрузка: %d радаров, потрачено %d (ms)", TOTALRADAR,GetTickCount() - time);
        return 1;
}

 

Если у вас есть данные коллбеки то просто добавьте содержимое,ну а если нет то добавляем данные строки

Спойлер

public OnPlayerEnterDynamicArea(playerid, areaid)
{
        foreachRadar(i)
        {
                if(areaid == i)
                {
                        if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == 2) 
                        {
                                //if(IsAPlane(GetPlayerVehicleID(playerid)) || IsABoat(GetPlayerVehicleID(playerid)) || IsABike(GetPlayerVehicleID(playerid))) break; // это условие проверяет не сидите ли вы в самолете, лодке или велике!!!
                                RadarTimer[playerid] = SetTimerEx("CallBackRadar",500,true,"ii",playerid,areaid);
                        }
                        break;
                }
        }
        return true;
}
public OnPlayerLeaveDynamicArea(playerid, areaid)
{
        foreachRadar(i){
                if(areaid == i){
                        RadarShtraf[playerid] = 0;
                        KillTimer(RadarTimer[playerid]);
                        break;
                }
        }
        return true;
}

 

В OnPlayerEditObject:
 

Спойлер

if(response == EDIT_RESPONSE_FINAL){// player clicked on savе
                if(GetPVarInt(playerid, "addrad") == 1){
                        RadarInfo[TOTALRADAR][rid] = TOTALRADAR;
                        RadarInfo[TOTALRADAR][rX] = fX;
                        RadarInfo[TOTALRADAR][rY] = fY;
                        RadarInfo[TOTALRADAR][rZ] = fZ;
                        RadarInfo[TOTALRADAR][rRZ] = fRotZ;
                        RadarInfo[TOTALRADAR][rSpeed] = GetPVarInt(playerid, "speed");
                        mysql_format(mysql, MySqlStr, sizeof(MySqlStr), "INSERT INTO "TOTAL_RADAR" (`x`, `y`, `z`, `rz`, `speed`) VALUES ('%f', '%f', '%f', '%f', '%i')",fX,fY,fZ,fRotZ,RadarInfo[TOTALRADAR][rSpeed]);
                        mysql_function_query(mysql, MySqlStr, true, "", "");
                        new int = CreateDynamicSphere(fX,fY,fZ, 100, 0, 0, -1);
                        //Iter_Add(RadarIterator, int);
                        RadarIterator[radariter++]=int;
                        RadarMaxSpeed[int] = RadarInfo[TOTALRADAR][rSpeed];
                        DeletePVar(playerid, "addrad");
                        DeletePVar(playerid, "speed");
                }
        }
        else if(response == EDIT_RESPONSE_CANCEL){// player cancelled (ESC)
                DestroyObject(objectid);
                if(GetPVarInt(playerid, "addrad")==1) {
                        TOTALRADAR--;
                        DeletePVar(playerid, "addrad");
                        DeletePVar(playerid, "speed");
                }
        }
        else if(response == EDIT_RESPONSE_UPDATE){// player moved the object (edition did not stop at all)
                SetObjectPos(objectid, fX, fY, fZ);
                SetObjectRot(objectid, fRotX, fRotY, fRotZ);
        }

 

Данный коллбек отвечает за сами штрафы,его добавим в самый конец вашего мода

Спойлер

publics: CallBackRadar(playerid,area){
        if(RadarShtraf[playerid] == 0){
                if(IsACop(playerid) && PlayerInfo[playerid][pMember] == 4) return true;
                new speed = SpeedVehicle(playerid);
                if(speed >= RadarMaxSpeed[area]+10){>
                        new shtraf;
                        shtraf=(speed-RadarMaxSpeed[area])*RadarMaxSpeed[area];
                        PlayerInfo[playerid][pCash] -= shtraf;
                        RadarShtraf[playerid] = 1;
                        SFCM(playerid,COLOR_LIGHTRED,"[ДПС] Вы нарушили скоростной режим на %d м/ч. Штраф: %d!",speed-RadarMaxSpeed[area],shtraf);
                }
        }
        return true;
}

 

Ну и самое последнее это сама команда для добавление радаров

Спойлер

CMD:addradar(playerid, params[]){
        if(AdLevel[playerid] < 1) return true; //уровень админа
        if(sscanf(params, "i", params[0])) return SCM(playerid, COLOR_GREY, "{F74848}» Введите{FFFFFF}: /addradar [скорость]");
        new Float:X, Float:Y, Float:Z;
        SetPVarInt(playerid, "addrad", 1);
        SetPVarInt(playerid, "speed", params[0]);
        GetPlayerPos(playerid, X, Y, Z);
        TOTALRADAR++;
        RadarInfo[TOTALRADAR][rObj] = CreateObject(18880, X+1, Y+1, Z+1, 0.0,0.0,0.0);
        EditObject(playerid, RadarInfo[TOTALRADAR][rObj]);
        return true;
}

 

Ну вот и все,вот такая маленькая система! На mnINI можете переведу,но советую на БД ставить,что бы не произошло с ними ни что!

 

Спасибо за внимание! Удачного использования!

Автор: неизвестен.

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


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

@Vadim_Lvov у меня ее нет, автор системы не я. 

Можно восстановить примерную структуру таблицы по RadarInfo, это по сути то, что должно сохраняться в БД. 

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


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

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

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

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

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


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

Войти

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


Войти

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

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

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

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