-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.lua
More file actions
102 lines (87 loc) · 3.5 KB
/
Copy pathclient.lua
File metadata and controls
102 lines (87 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
local marderKittyEnabled = Config.Enabled
RegisterCommand("toggleMarderKitty", function()
marderKittyEnabled = not marderKittyEnabled
local status = marderKittyEnabled and "enabled" or "disabled"
TriggerEvent("chat:addMessage", {
color = {255, 0, 0},
multiline = false,
args = {"CES_marderKitty", "Animal suppression " .. status}
})
end, false)
RegisterCommand("spawnCoyote", function()
spawnTestAnimal(`a_c_coyote`, "Coyote")
end, false)
RegisterCommand("spawnCougar", function()
spawnTestAnimal(`a_c_mtlion`, "Mountain Lion")
end, false)
function spawnTestAnimal(model, label)
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)
RequestModel(model)
while not HasModelLoaded(model) do
Wait(100)
end
local animal = CreatePed(28, model, coords.x + 5.0, coords.y + 5.0, coords.z, 0.0, true, false)
SetModelAsNoLongerNeeded(model)
SetEntityAsMissionEntity(animal, true, true)
TriggerEvent("chat:addMessage", {
color = {0, 255, 0},
multiline = false,
args = {"CES_marderKitty", "Test " .. label .. " spawned nearby!"}
})
end
Citizen.CreateThread(function()
while true do
if marderKittyEnabled then
local playerPed = PlayerPedId()
local playerCoords = GetEntityCoords(playerPed)
local animalPool = GetGamePool("CPed")
for _, ped in ipairs(animalPool) do
if DoesEntityExist(ped) and not IsPedAPlayer(ped) then
local pedModel = GetEntityModel(ped)
if Config.BlockedAnimals[pedModel] then
local pedCoords = GetEntityCoords(ped)
if #(playerCoords - pedCoords) < Config.CheckRadius then
SetPedCanBeTargetted(ped, false)
ClearPedTasks(ped)
TaskWanderStandard(ped, 10.0, 10)
SetBlockingOfNonTemporaryEvents(ped, true)
SetPedFleeAttributes(ped, 0, true)
SetPedCombatAttributes(ped, 46, true)
SetEntityAsNoLongerNeeded(ped)
if Config.Debug then
DrawText3D(pedCoords.x, pedCoords.y, pedCoords.z + 1.0, "Suppressed " .. pedModel)
end
local blip = AddBlipForEntity(ped)
SetBlipSprite(blip, 141)
SetBlipColour(blip, 1)
SetBlipScale(blip, 0.7)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString("Suppressed Animal")
EndTextCommandSetBlipName(blip)
Citizen.CreateThread(function()
Wait(15000)
if DoesBlipExist(blip) then
RemoveBlip(blip)
end
end)
end
end
end
end
end
Wait(Config.CheckInterval)
end
end)
function DrawText3D(x, y, z, text)
SetTextScale(0.35, 0.35)
SetTextFont(4)
SetTextProportional(1)
SetTextColour(255, 0, 0, 215)
SetTextEntry("STRING")
SetTextCentre(true)
AddTextComponentString(text)
SetDrawOrigin(x, y, z, 0)
DrawText(0.0, 0.0)
ClearDrawOrigin()
end