Другое С/С++ Вопрос - Ответ

mac

HEY DARLING
1,317
911
C++:
#include "script.h"
#include <string>
#include <ctime>

Vehicle fbiVeh1, fbiVeh2, fbiVeh3, fbiVeh4, fbiVeh5, // Машины в ФБР
fbi2Veh1, fbi2Veh2, fbi2Veh3, fbi2Veh4, fbi2Veh5,
riotVeh1, riotVeh2,
pcjVeh1, pcjVeh2,
froggerVeh1, froggerVeh2,
police4Veh1, police4Veh2, police4Veh3;

int fbiSpawned = 0, // Количество заспавненных машин
fbi2Spawned = 0,
riotSpawned = 0,
pcjSpawned = 0,
froggerSpawned = 0,
police4Spawned = 0;

int fbiSpawnDistance = 0, // Дальность спауна машины от игрока
fbi2SpawnDistance = 0,
riotSpawnDistance = 0,
pcjSpawnDistance = 0,
froggerSpawnDistance = 0,
police4SpawnDistance = 0;

void fbicars()
{
    Ped playerPed = PLAYER::PLAYER_PED_ID();
    Vehicle veh = PED::GET_VEHICLE_PED_IS_USING(playerPed);
    Vector3 position = ENTITY::GET_ENTITY_COORDS(playerPed, 1);

    DWORD fbi = GAMEPLAY::GET_HASH_KEY("fbi"); // FBI Buffalo
    int fbiSpawnDistance = GAMEPLAY::GET_DISTANCE_BETWEEN_COORDS(140.914, -744.040, 32.779, position.x, position.y, position.z, 0);

    if (fbiSpawnDistance < 100)
    {
        if (fbiSpawned == 0)
        {
            STREAMING::REQUEST_MODEL(fbi);
            while (!STREAMING::HAS_MODEL_LOADED(fbi))
                WAIT(0);
            fbiVeh1 = VEHICLE::CREATE_VEHICLE(fbi, 133.274, -741.387, 32.781, 0.0, 1, 1);
            ENTITY::SET_ENTITY_HEADING(fbiVeh1, 340.0);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(fbiVeh1);
            fbiSpawned += 1;
            fbiVeh2 = VEHICLE::CREATE_VEHICLE(fbi, 137.026, -742.728, 32.779, 0.0, 1, 1);
            ENTITY::SET_ENTITY_HEADING(fbiVeh2, 340.0);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(fbiVeh2);
            fbiSpawned += 1;
            fbiVeh3 = VEHICLE::CREATE_VEHICLE(fbi, 140.914, -744.040, 32.779, 0.0, 1, 1);
            ENTITY::SET_ENTITY_HEADING(fbiVeh3, 340.0);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(fbiVeh3);
            fbiSpawned += 1;
            fbiVeh4 = VEHICLE::CREATE_VEHICLE(fbi, 147.477, -746.371, 32.779, 0.0, 1, 1);
            ENTITY::SET_ENTITY_HEADING(fbiVeh4, 340.0);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(fbiVeh4);
            fbiSpawned += 1;
            fbiVeh5 = VEHICLE::CREATE_VEHICLE(fbi, 151.132, -747.872, 32.779, 0.0, 1, 1);
            ENTITY::SET_ENTITY_HEADING(fbiVeh5, 340.0);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(fbiVeh5);
            fbiSpawned += 1;
        }
    }

    Vector3 fbiVehPosition = ENTITY::GET_ENTITY_COORDS(fbiVeh3, 1);
    int fbiVehDistance = GAMEPLAY::GET_DISTANCE_BETWEEN_COORDS(fbiVehPosition.x, fbiVehPosition.y, fbiVehPosition.z, position.x, position.y, position.z, 0);

    if (fbiSpawnDistance > 100 && fbiVehDistance > 100)
    {
        if (fbiSpawned == 5)
        {
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&fbiVeh1);
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&fbiVeh2);
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&fbiVeh3);
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&fbiVeh4);
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&fbiVeh5);
            fbiSpawned -= 5;
        }
    }

    DWORD fbi2 = GAMEPLAY::GET_HASH_KEY("fbi2"); // FBI Granger
    int fbi2SpawnDistance = GAMEPLAY::GET_DISTANCE_BETWEEN_COORDS(104.097, -730.600, 32.756, position.x, position.y, position.z, 0);

    if (fbi2SpawnDistance < 100)
    {
        if (fbi2Spawned == 0)
        {
            STREAMING::REQUEST_MODEL(fbi2);
            while (!STREAMING::HAS_MODEL_LOADED(fbi2))
                WAIT(0);
            fbi2Veh1 = VEHICLE::CREATE_VEHICLE(fbi2, 115.290, -734.525, 32.756, 0.0, 1, 1);
            ENTITY::SET_ENTITY_HEADING(fbi2Veh1, 340.0);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(fbi2Veh1);
            fbi2Spawned += 1;
            fbi2Veh2 = VEHICLE::CREATE_VEHICLE(fbi2, 118.986, -735.744, 32.756, 0.0, 1, 1);
            ENTITY::SET_ENTITY_HEADING(fbi2Veh2, 340.0);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(fbi2Veh2);
            fbi2Spawned += 1;
            fbi2Veh3 = VEHICLE::CREATE_VEHICLE(fbi2, 104.097, -730.600, 32.756, 0.0, 1, 1);
            ENTITY::SET_ENTITY_HEADING(fbi2Veh3, 340.0);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(fbi2Veh3);
            fbi2Spawned += 1;
            fbi2Veh4 = VEHICLE::CREATE_VEHICLE(fbi2, 100.164, -729.019, 32.755, 0.0, 1, 1);
            ENTITY::SET_ENTITY_HEADING(fbi2Veh4, 340.0);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(fbi2Veh4);
            fbi2Spawned += 1;
            fbi2Veh5 = VEHICLE::CREATE_VEHICLE(fbi2, 110.952, -735.907, 32.756, 0.0, 1, 1);
            ENTITY::SET_ENTITY_HEADING(fbi2Veh5, 340.0);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(fbi2Veh5);
            fbi2Spawned += 1;
        }
    }

    Vector3 fbi2VehPosition = ENTITY::GET_ENTITY_COORDS(fbi2Veh3, 1);
    int fbi2VehDistance = GAMEPLAY::GET_DISTANCE_BETWEEN_COORDS(fbi2VehPosition.x, fbi2VehPosition.y, fbi2VehPosition.z, position.x, position.y, position.z, 0);

    if (fbi2SpawnDistance > 100 && fbi2VehDistance > 100)
    {
        if (fbi2Spawned == 5)
        {
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&fbi2Veh1);
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&fbi2Veh2);
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&fbi2Veh3);
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&fbi2Veh4);
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&fbi2Veh5);
            fbi2Spawned -= 5;
        }
    }

    DWORD riot = GAMEPLAY::GET_HASH_KEY("riot"); // Riot
    int riotSpawnDistance = GAMEPLAY::GET_DISTANCE_BETWEEN_COORDS(93.386, -720.295, 32.786, position.x, position.y, position.z, 0);

    if (riotSpawnDistance < 100)
    {
        if (riotSpawned == 0)
        {
            STREAMING::REQUEST_MODEL(riot);
            while (!STREAMING::HAS_MODEL_LOADED(riot))
                WAIT(0);
            riotVeh1 = VEHICLE::CREATE_VEHICLE(riot, 93.386, -720.295, 32.786, 0.0, 1, 1);
            ENTITY::SET_ENTITY_HEADING(riotVeh1, 252.440);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(riotVeh1);
            riotSpawned += 1;
            riotVeh2 = VEHICLE::CREATE_VEHICLE(riot, 95.960, -712.938, 32.787, 0.0, 1, 1);
            ENTITY::SET_ENTITY_HEADING(riotVeh2, 252.440);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(riotVeh2);
            riotSpawned += 1;
        }
    }

    Vector3 riotVehPosition = ENTITY::GET_ENTITY_COORDS(riotVeh1, 1);
    int riotVehDistance = GAMEPLAY::GET_DISTANCE_BETWEEN_COORDS(riotVehPosition.x, riotVehPosition.y, riotVehPosition.z, position.x, position.y, position.z, 0);

    if (riotSpawnDistance > 100 && riotVehDistance > 100)
    {
        if (riotSpawned == 2)
        {
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&riotVeh1);
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&riotVeh2);
            riotSpawned -= 2;
        }
    }

    DWORD police4 = GAMEPLAY::GET_HASH_KEY("police4"); // Interceptor
    int police4SpawnDistance = GAMEPLAY::GET_DISTANCE_BETWEEN_COORDS(163.070, -741.207, 32.739, position.x, position.y, position.z, 0);

    if (police4SpawnDistance < 100)
    {
        if (police4Spawned == 0)
        {
            STREAMING::REQUEST_MODEL(police4);
            while (!STREAMING::HAS_MODEL_LOADED(police4))
                WAIT(0);
            police4Veh1 = VEHICLE::CREATE_VEHICLE(police4, 163.070, -741.207, 32.739, 0.0, 1, 1);
            ENTITY::SET_ENTITY_HEADING(police4Veh1, 70.780);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(police4Veh1);
            police4Spawned += 1;
            police4Veh2 = VEHICLE::CREATE_VEHICLE(police4, 164.386, -737.460, 32.739, 0.0, 1, 1);
            ENTITY::SET_ENTITY_HEADING(police4Veh2, 70.780);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(police4Veh2);
            police4Spawned += 1;
            police4Veh3 = VEHICLE::CREATE_VEHICLE(police4, 165.798, -733.659, 32.739, 0.0, 1, 1);
            ENTITY::SET_ENTITY_HEADING(police4Veh3, 70.780);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(police4Veh3);
            police4Spawned += 1;
        }
    }

    Vector3 police4VehPosition = ENTITY::GET_ENTITY_COORDS(police4Veh2, 1);
    int police4VehDistance = GAMEPLAY::GET_DISTANCE_BETWEEN_COORDS(police4VehPosition.x, police4VehPosition.y, police4VehPosition.z, position.x, position.y, position.z, 0);

    if (police4SpawnDistance > 100 && police4VehDistance > 100)
    {
        if (police4Spawned == 3)
        {
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&police4Veh1);
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&police4Veh2);
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&police4Veh3);
            police4Spawned -= 3;
        }
    }

    DWORD pcj = GAMEPLAY::GET_HASH_KEY("pcj");  // PC
    int pcjSpawnDistance = GAMEPLAY::GET_DISTANCE_BETWEEN_COORDS(140.914, -744.040, 32.779, position.x, position.y, position.z, 0);

    if (pcjSpawnDistance < 100)
    {
        if (pcjSpawned == 0)
        {
            STREAMING::REQUEST_MODEL(pcj);
            while (!STREAMING::HAS_MODEL_LOADED(pcj))
                WAIT(0);
            pcjVeh1 = VEHICLE::CREATE_VEHICLE(pcj, 93.643, -715.955, 32.635, 0.0, 1, 1);
            ENTITY::SET_ENTITY_HEADING(pcjVeh1, 252.440);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(pcjVeh1);
            pcjSpawned += 1;
            pcjVeh2 = VEHICLE::CREATE_VEHICLE(pcj, 95.951, -708.136, 32.643, 0.0, 1, 1);
            ENTITY::SET_ENTITY_HEADING(pcjVeh2, 252.440);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(pcjVeh2);
            pcjSpawned += 1;
        }
    }

    Vector3 pcjVehPosition = ENTITY::GET_ENTITY_COORDS(pcjVeh1, 1);
    int pcjVehDistance = GAMEPLAY::GET_DISTANCE_BETWEEN_COORDS(pcjVehPosition.x, pcjVehPosition.y, pcjVehPosition.z, position.x, position.y, position.z, 0);

    if (pcjSpawnDistance > 100 && pcjVehDistance > 100)
    {
        if (pcjSpawned == 2)
        {
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&pcjVeh1);
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&pcjVeh2);
            pcjSpawned -= 2;
        }
    }

    DWORD frogger = GAMEPLAY::GET_HASH_KEY("frogger"); // Frogger
    int froggerSpawnDistance = GAMEPLAY::GET_DISTANCE_BETWEEN_COORDS(138.607, -750.402, 262.590, position.x, position.y, position.z, 0);

    if (froggerSpawnDistance < 100)
    {
        if (froggerSpawned == 0)
        {
            STREAMING::REQUEST_MODEL(frogger);
            while (!STREAMING::HAS_MODEL_LOADED(frogger))
                WAIT(0);
            froggerVeh1 = VEHICLE::CREATE_VEHICLE(frogger, 123.158, -743.525, 262.561, 0.0, 1, 1);
            ENTITY::SET_ENTITY_HEADING(froggerVeh1, 252.440);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(froggerVeh1);
            froggerSpawned += 1;
            froggerVeh2 = VEHICLE::CREATE_VEHICLE(frogger, 148.607, -756.402, 262.590, 0.0, 1, 1);
            ENTITY::SET_ENTITY_HEADING(froggerVeh2, 252.440);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(froggerVeh2);
            froggerSpawned += 1;
        }
    }

Vector3 froggerVehPosition = ENTITY::GET_ENTITY_COORDS(froggerVeh1, 1);
int froggerVehDistance = GAMEPLAY::GET_DISTANCE_BETWEEN_COORDS(froggerVehPosition.x, froggerVehPosition.y, froggerVehPosition.z, position.x, position.y, position.z, 0);

if (froggerSpawnDistance > 100 && froggerVehDistance > 100)
{
    if (froggerSpawned == 2)
    {
        ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&froggerVeh1);
        ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&froggerVeh2);
        froggerSpawned -= 2;
    }
}
}
ScriptHookV библиотеки для гта 5. Что не так? Машины не спавнятся
 

mac

HEY DARLING
1,317
911
C++:
void lspd1cars()
{
    Vehicle police3Veh1, police3Veh2, police3Veh3, police3Veh4, police3Veh5, // Машины
        policebVeh1, policebVeh2, policebVeh3,
        policeVeh1, policeVeh2, policeVeh3,
        police2Veh1, police2Veh2,
        polmavVeh1, polmavVeh2,
        policetVeh1, policetVeh2;

    int police3Spawned = 0, // Количество заспавненных машин
        policebSpawned = 0,
        policeSpawned = 0,
        police2Spawned = 0,
        polmavSpawned = 0,
        policetSpawned = 0;

    int police3SpawnDistance = 0, // Дальность спауна от игрока
        policebSpawnDistance = 0,
        policeSpawnDistance = 0,
        police2SpawnDistance = 0,
        polmavSpawnDistance = 0,
        policetSpawnDistance = 0;

    Ped playerPed = PLAYER::PLAYER_PED_ID();
    Vehicle veh = PED::GET_VEHICLE_PED_IS_USING(playerPed);
    Vector3 position = ENTITY::GET_ENTITY_COORDS(playerPed, 1);

    DWORD police3 = GAMEPLAY::GET_HASH_KEY("police3"); // ПД машина
    police3SpawnDistance = GAMEPLAY::GET_DISTANCE_BETWEEN_COORDS(408.203, -988.917, 29.021, position.x, position.y, position.z, 0);

    if (police3SpawnDistance < 750)
    {
        if (police3Spawned == 0)
        {
            STREAMING::REQUEST_MODEL(police3);
            while (!STREAMING::HAS_MODEL_LOADED(police3))
                WAIT(0);
            police3Veh1 = VEHICLE::CREATE_VEHICLE(police3, 408.172, -980.228, 29.023, 230.0, 1, 1);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(police3Veh1);
            police3Spawned += 1;
            police3Veh2 = VEHICLE::CREATE_VEHICLE(police3, 407.991, -984.251, 29.021, 230.0, 1, 1);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(police3Veh2);
            police3Spawned += 1;
            police3Veh3 = VEHICLE::CREATE_VEHICLE(police3, 408.203, -988.917, 29.021, 230.0, 1, 1);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(police3Veh3);
            police3Spawned += 1;
            police3Veh4 = VEHICLE::CREATE_VEHICLE(police3, 407.931, -993.089, 29.021, 230.0, 1, 1);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(police3Veh4);
            police3Spawned += 1;
            police3Veh5 = VEHICLE::CREATE_VEHICLE(police3, 408.210, -997.956, 29.022, 230.0, 1, 1);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(police3Veh5);
            police3Spawned += 1;
        }
    }

    Vector3 police3VehPosition = ENTITY::GET_ENTITY_COORDS(police3Veh3, 1);
    int police3VehDistance = GAMEPLAY::GET_DISTANCE_BETWEEN_COORDS(police3VehPosition.x, police3VehPosition.y, police3VehPosition.z, position.x, position.y, position.z, 0);
    if (police3SpawnDistance > 100 && police3VehDistance > 100)
    {
        if (police3Spawned == 5)
        {
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&police3Veh1);
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&police3Veh2);
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&police3Veh3);
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&police3Veh4);
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&police3Veh5);
            police3Spawned -= 5;
        }
    }

    DWORD policeb = GAMEPLAY::GET_HASH_KEY("policeb"); // Мотоцикл
    policebSpawnDistance = GAMEPLAY::GET_DISTANCE_BETWEEN_COORDS(409.370, -1004.351, 28.742, position.x, position.y, position.z, 0);

    if (policebSpawnDistance < 750)
    {
        if (policebSpawned == 0)
        {
            STREAMING::REQUEST_MODEL(policeb);
            while (!STREAMING::HAS_MODEL_LOADED(policeb))
                WAIT(0);
            policebVeh1 = VEHICLE::CREATE_VEHICLE(policeb, 409.057, -1007.126, 28.739, 122.5, 1, 1);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(policebVeh1);
            policebSpawned += 1;
            policebVeh2 = VEHICLE::CREATE_VEHICLE(policeb, 409.370, -1004.351, 28.742, 122.5, 1, 1);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(policebVeh2);
            policebSpawned += 1;
            policebVeh3 = VEHICLE::CREATE_VEHICLE(policeb, 407.668, -1002.042, 28.745, 122.5, 1, 1);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(policebVeh3);
            policebSpawned += 1;
        }
    }

    Vector3 policebVehPosition = ENTITY::GET_ENTITY_COORDS(policebVeh2, 1);
    int policebVehDistance = GAMEPLAY::GET_DISTANCE_BETWEEN_COORDS(policebVehPosition.x, policebVehPosition.y, policebVehPosition.z, position.x, position.y, position.z, 0);
    if (policebSpawnDistance > 100 && policebVehDistance > 100)
    {
        if (policebSpawned == 3)
        {
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&policebVeh1);
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&policebVeh2);
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&policebVeh3);
            policebSpawned -= 3;
        }
    }

    DWORD police = GAMEPLAY::GET_HASH_KEY("police"); // Stainer
    policeSpawnDistance = GAMEPLAY::GET_DISTANCE_BETWEEN_COORDS(431.053, -1026.89, 28.518, position.x, position.y, position.z, 0);

    if (policeSpawnDistance < 750)
    {
        if (policeSpawned == 0)
        {
            STREAMING::REQUEST_MODEL(police);
            while (!STREAMING::HAS_MODEL_LOADED(police))
                WAIT(0);
            policeVeh1 = VEHICLE::CREATE_VEHICLE(police, 427.269, -1027.138, 28.586, 5.8, 1, 1);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(policeVeh1);
            policeSpawned += 1;
            policeVeh2 = VEHICLE::CREATE_VEHICLE(police, 431.053, -1026.89, 28.518, 5.8, 1, 1);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(policeVeh2);
            policeSpawned += 1;
            policeVeh3 = VEHICLE::CREATE_VEHICLE(police, 434.827, -1026.661, 28.456, 5.8, 1, 1);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(policeVeh3);
            policeSpawned += 1;
        }
    }

    Vector3 policeVehPosition = ENTITY::GET_ENTITY_COORDS(policeVeh2, 1);
    int policeVehDistance = GAMEPLAY::GET_DISTANCE_BETWEEN_COORDS(policeVehPosition.x, policeVehPosition.y, policeVehPosition.z, position.x, position.y, position.z, 0);
    if (policeSpawnDistance > 100 && policeVehDistance > 100)
    {
        if (policeSpawned == 3)
        {
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&policeVeh1);
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&policeVeh2);
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&policeVeh3);
            policeSpawned -= 3;
        }
    }

    DWORD police2 = GAMEPLAY::GET_HASH_KEY("police2"); // Buffalo
    police2SpawnDistance = GAMEPLAY::GET_DISTANCE_BETWEEN_COORDS(438.583, -1026.324, 28.391, position.x, position.y, position.z, 0);

    if (police2SpawnDistance < 750)
    {
        if (police2Spawned == 0)
        {
            STREAMING::REQUEST_MODEL(police2);
            while (!STREAMING::HAS_MODEL_LOADED(police2))
                WAIT(0);
            police2Veh1 = VEHICLE::CREATE_VEHICLE(police2, 438.583, -1026.324, 28.391, 5.8, 1, 1);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(police2Veh1);
            police2Spawned += 1;
            police2Veh2 = VEHICLE::CREATE_VEHICLE(police2, 442.408, -1026.017, 28.319, 5.8, 1, 1);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(police2Veh2);
            police2Spawned += 1;
        }
    }

    Vector3 police2VehPosition = ENTITY::GET_ENTITY_COORDS(police2Veh1, 1);
    int police2VehDistance = GAMEPLAY::GET_DISTANCE_BETWEEN_COORDS(police2VehPosition.x, police2VehPosition.y, police2VehPosition.z, position.x, position.y, position.z, 0);
    if (police2SpawnDistance > 100 && police2VehDistance > 100)
    {
        if (police2Spawned == 2)
        {
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&police2Veh1);
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&police2Veh2);
            police2Spawned -= 2;
        }
    }

    DWORD polmav = GAMEPLAY::GET_HASH_KEY("polmav"); // Вертолет
    polmavSpawnDistance = GAMEPLAY::GET_DISTANCE_BETWEEN_COORDS(450.454, -981.296, 44.078, position.x, position.y, position.z, 0);

    if (polmavSpawnDistance < 750)
    {
        if (polmavSpawned == 0)
        {
            STREAMING::REQUEST_MODEL(polmav);
            while (!STREAMING::HAS_MODEL_LOADED(polmav))
                WAIT(0);
            polmavVeh1 = VEHICLE::CREATE_VEHICLE(polmav, 450.454, -981.296, 44.078, 272.0, 1, 1);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(polmavVeh1);
            polmavSpawned += 1;
            polmavVeh2 = VEHICLE::CREATE_VEHICLE(polmav, 482.948, -982.156, 41.395, 272.0, 1, 1);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(polmavVeh2);
            polmavSpawned += 1;
        }
    }

    Vector3 polmavVehPosition = ENTITY::GET_ENTITY_COORDS(polmavVeh1, 1);
    int polmavVehDistance = GAMEPLAY::GET_DISTANCE_BETWEEN_COORDS(polmavVehPosition.x, polmavVehPosition.y, polmavVehPosition.z, position.x, position.y, position.z, 0);
    if (polmavSpawnDistance > 100 && polmavVehDistance > 100)
    {
        if (polmavSpawned == 2)
        {
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&polmavVeh1);
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&polmavVeh2);
            polmavSpawned -= 2;
        }
    }

    DWORD policet = GAMEPLAY::GET_HASH_KEY("policet"); // Автозак
    policetSpawnDistance = GAMEPLAY::GET_DISTANCE_BETWEEN_COORDS(462.846, -1019.376, 28.076, position.x, position.y, position.z, 0);

    if (policetSpawnDistance < 750)
    {
        if (policetSpawned == 0)
        {
            STREAMING::REQUEST_MODEL(policet);
            while (!STREAMING::HAS_MODEL_LOADED(policet))
                WAIT(0);
            policetVeh1 = VEHICLE::CREATE_VEHICLE(policet, 462.846, -1019.376, 28.076, 90.0, 1, 1);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(policetVeh1);
            policetSpawned += 1;
            policetVeh2 = VEHICLE::CREATE_VEHICLE(policet, 463.017, -1014.739, 28.063, 90.0, 1, 1);
            VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(policetVeh2);
            policetSpawned += 1;
        }
    }

    Vector3 policetVehPosition = ENTITY::GET_ENTITY_COORDS(policetVeh1, 1);
    int policetVehDistance = GAMEPLAY::GET_DISTANCE_BETWEEN_COORDS(policetVehPosition.x, policetVehPosition.y, policetVehPosition.z, position.x, position.y, position.z, 0);
    if (policetSpawnDistance > 100 && policetVehDistance > 100)
    {
        if (policetSpawned == 2)
        {
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&policetVeh1);
            ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&policetVeh2);
            policetSpawned -= 2;
        }
    }
}

Маверики и грузовики (которые по 2) спавнятся отлично, остальные не останавливаются и спавнятся в большом количестве (25-30 машин), что не так?
 

Gabriel__

Известный
Проверенный
411
183
Почему когда запускаю самп с сф плагином воспроизводится музыка из клуба джиззи. Исходник брал из вики (самый первый)
Код:
#include <windows.h>
#include <string>
#include <assert.h>
#include <process.h>

#include "SAMPFUNCS_API.h"
#include "game_api\game_api.h"

SAMPFUNCS *SF = new SAMPFUNCS();

void CALLBACK cmd_show_info_player(std::string param)
{
    if (param.empty()) return;
    int    i = std::stoi(param);

    char buf[128];

    stRemotePlayer *pPlayer = SF->getSAMP()->getPlayers()->pRemotePlayer[i];

    if (!pPlayer) return;

    sprintf(buf, "Nickname - %s, Ping - %d, Score - %d, isNPC - %d, AFKState - %d",
        pPlayer->szPlayerName,
        pPlayer->iPing,
        pPlayer->iScore,
        pPlayer->iIsNPC,
        pPlayer->pPlayerData->iAFKState == 2);

    SF->getSAMP()->getChat()->AddChatMessage(-1, buf);
};

void CALLBACK mainloop()
{
    static bool init = false;
    if (!init)
    {
        if (GAME == nullptr)
            return;
        if (GAME->GetSystemState() != eSystemState::GS_PLAYING_GAME)
            return;
        GAME->GetAudio()->PlayBeatTrack(2);

        if (!SF->getSAMP()->IsInitialized())
            return;
        SF->getSAMP()->getChat()->AddChatMessage( D3DCOLOR_XRGB( 0, 0xAA, 0 ), "SAMPFUNCS Plugin loaded )" );
        SF->getSAMP()->registerChatCommand("showinfo", cmd_show_info_player);
        init = true;
    }
}

BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReasonForCall, LPVOID lpReserved)
{
    switch (dwReasonForCall)
    {
        case DLL_PROCESS_ATTACH:
            SF->initPlugin(mainloop, hModule);
            break;
        case DLL_THREAD_ATTACH:
        case DLL_THREAD_DETACH:
        case DLL_PROCESS_DETACH:
            break;
    }
    return TRUE;
}
 

Dark_Knight

Me, me and me.
Друг
4,078
2,095
Код:
 GAME->GetAudio()->PlayBeatTrack(2);
И для СФ АПИ есть отдельная тема.
 

Gabriel__

Известный
Проверенный
411
183
Почему во всех библиотеках функций c++. (заголовочных файлах) содержимое оформляется по такому шаблону ?
Код:
#ifndef _fileName_H_
#define _fileName_H_
... //функции,
... //функции,
... //функции
#endif;
Зачем нужны эти дефайны и т.п. Почему бы просто не засунуть все функции в файл ???
 

Stas07

Известный
Проверенный
266
113
Скиньте, пожалуйста, урок по получению оффсетов для любой игры)
find out what writes to this address, в Cheat engine не даёт результатов.
 
Последнее редактирование: