- 1,317
- 911
В общем, данная херня работает, но криво. Когда захожу в игру - машины спавнятся, но в огромном количестве. Не понимаю, что не так сделал
п.с. Должен быть хотя бы один человек, который работает с этим апи
C++:
#include "script.h"
#include <string>
#include <ctime>
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;
}
}
int police3VehDistance = GAMEPLAY::GET_DISTANCE_BETWEEN_COORDS(408.203, -988.917, 29.021, 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;
}
}
int policebVehDistance = GAMEPLAY::GET_DISTANCE_BETWEEN_COORDS(409.370, -1004.351, 28.742, 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;
}
}
int policeVehDistance = GAMEPLAY::GET_DISTANCE_BETWEEN_COORDS(431.053, -1026.89, 28.518, 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(442.408, -1026.017, 28.319, 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;
}
}
int police2VehDistance = GAMEPLAY::GET_DISTANCE_BETWEEN_COORDS(442.408, -1026.017, 28.319, 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(482.948, -982.156, 41.395, 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;
}
}
int polmavVehDistance = GAMEPLAY::GET_DISTANCE_BETWEEN_COORDS(482.948, -982.156, 41.395, 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(463.017, -1014.739, 28.063, 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;
}
}
int policеtVehDistance = GAMEPLAY::GET_DISTANCE_BETWEEN_COORDS(463.017, -1014.739, 28.063, position.x, position.y, position.z, 0);
if (policetSpawnDistance > 100 && policеtVehDistance > 100)
{
if (policetSpawned == 2)
{
ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&policetVeh1);
ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&policetVeh2);
policetSpawned -= 2;
}
}
}
void main()
{
while (true)
{
lspd1cars();
WAIT(0);
}
}
void ScriptMain()
{
srand(GetTickCount());
main();
}