-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclient.lua
191 lines (158 loc) · 7.34 KB
/
client.lua
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
local horses ={}
local rareHorses ={}
local spawntimerRare = Config.spawntimerRare * 6000
local spawntimer = Config.spawntimer * 6000
local triggeractive =false
function Listentrys(table)
local keys = 0
for k,v in pairs(table) do
keys = keys + 1
end
return keys
end
local totalkeysRare = Listentrys(Config.rareLocations)
local totalkeys = Listentrys(Config.Locations)
Citizen.CreateThread(function()
Citizen.Wait(5000)
TriggerServerEvent("twh_wilds:setHost")
end)
RegisterNetEvent("twh_wilds:fetch")
AddEventHandler("twh_wilds:fetch", function()
TriggerServerEvent("twh_wilds:host",GetPlayers())
end)
local host
RegisterNetEvent("twh_wilds:set")
AddEventHandler("twh_wilds:set", function(main)
host = main
end)
RegisterNetEvent("twh_wildHorses:trigger")
AddEventHandler("twh_wildHorses:trigger", function(ptrigger)
triggeractive = ptrigger
end)
RegisterNetEvent("vorp:SelectedCharacter")
AddEventHandler("vorp:SelectedCharacter", function(charid)
Citizen.Wait(10000)
Spawning()
end)
function Spawning()
while true do
Citizen.Wait(100)
if Config.normals then
Wait(1000)
if GetPlayerServerId(PlayerId()) == host then
for k,v in pairs(horses) do
DeletePed(v)
end
for k,v in pairs(Config.Locations) do
local hashModel = GetHashKey(v.model)
if IsModelValid(hashModel) then
RequestModel(hashModel)
while not HasModelLoaded(hashModel) do
Wait(100)
end
end
if v.isGroup then
for i = 1, v.groupSize, 1 do
local height = 1
local r1 = v.radius * 1000 + (i*10)
local r2 = v.radius * 1000 + (i*10)
local l1 = math.random(i*10,r1)/1000
local l2 = math.random(i*10,r2)/1000
local locx = v.loc.x + l1
local locy = v.loc.y + l2
local locz = v.loc.z
local heads = v.heading + math.random(-v.headingDif,v.headingDif)
local horse = CreatePed(hashModel, locx, locy, locz, heads, true, true, true, true)
Citizen.InvokeNative(0x283978A15512B2FE, horse, true)
Citizen.InvokeNative(0xAEB97D84CDF3C00B, horse, true)
table.insert(horses,horse)
Citizen.Wait(1000)
end
else
local horse = CreatePed(hashModel, v.loc.x, v.loc.y, v.loc.z, v.heading, true, true, true, true)
Citizen.InvokeNative(0x283978A15512B2FE, horse, true)
Citizen.InvokeNative(0xAEB97D84CDF3C00B, horse, true)
table.insert(horses,horse)
Citizen.Wait(1000)
end
end
Wait(spawntimer)
else
Wait(5000)
end
end
if Config.rares then
if Config.spawnCount ~= 0 then
Wait(1000)
if GetPlayerServerId(PlayerId()) == host then
for k,v in pairs(rareHorses) do
DeletePed(v)
end
for i =1, Config.spawnCount do
local random = math.random(1,totalkeysRare)
for k,v in pairs(Config.rareLocations) do
if k == random then
local hashModel = GetHashKey(v.model)
if IsModelValid(hashModel) then
RequestModel(hashModel)
while not HasModelLoaded(hashModel) do
Wait(100)
end
end
if v.isGroup then
for i = 1, v.groupSize, 1 do
local height = 1
r1 = v.radius * 1000 + (i*10)
r2 = v.radius * 1000 + (i*10)
l1 = math.random(i*10,r1)/1000
l2 = math.random(i*10,r2)/1000
locx = v.loc.x + l1
locy = v.loc.y + l2
locz = v.loc.z
heads = v.heading + math.random(-v.headingDif,v.headingDif)
local rareHorse = CreatePed(hashModel, v.loc.x, v.loc.y, v.loc.z, v.heading, true, true, true, true)
Citizen.InvokeNative(0x283978A15512B2FE, rareHorse, true)
Citizen.InvokeNative(0xAEB97D84CDF3C00B, rareHorse, true)
table.insert(rareHorses,rareHorse)
Citizen.Wait(1000)
end
else
local rareHorse = CreatePed(hashModel, v.loc.x, v.loc.y, v.loc.z, v.heading, true, true, true, true)
Citizen.InvokeNative(0x283978A15512B2FE, rareHorse, true)
Citizen.InvokeNative(0xAEB97D84CDF3C00B, rareHorse, true)
table.insert(rareHorses,rareHorse)
Citizen.Wait(1000)
end
end
end
end
Wait(spawntimerRare)
else
Wait(5000)
end
else
Wait(5000)
end
end
end
end
function GetPlayers()
local players = {}
local actives = GetActivePlayers()
for k,v in pairs(actives) do
if NetworkIsPlayerActive(v) then
table.insert(players, GetPlayerServerId(v))
end
end
return players
end
AddEventHandler("onResourceStop",function(resourceName)
if resourceName == GetCurrentResourceName() then
for k,v in pairs(rareHorses) do
DeletePed(v)
end
for k,v in pairs(horses) do
DeletePed(v)
end
end
end)