-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy patha_mta.lua
603 lines (487 loc) · 14.6 KB
/
a_mta.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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
function AddPlayerClothes(amx, player, type, index)
local texture, model = getClothesByTypeIndex(type, index)
return addPedClothes(player, texture, model, type)
end
function GetPlayerClothes(amx, player, type)
local texture, model = getPedClothes(player, type)
if not texture then
return
end
local type, index = getTypeIndexFromClothes(texture, model)
return index
end
function RemovePlayerClothes(amx, player, type)
return removePedClothes(player, type)
end
-----------------------------------------------------
-- Alpha funcs
function GetAlpha(amx, elem)
return getElementAlpha(alpha)
end
function SetAlpha(amx, elem, alpha)
return setElementAlpha(elem, alpha)
end
GetPlayerAlpha = GetAlpha
GetVehicleAlpha = GetAlpha
GetObjectAlpha = GetAlpha
GetBotAlpha = GetAlpha
SetPlayerAlpha = SetAlpha
SetVehicleAlpha = SetAlpha
SetObjectAlpha = SetAlpha
SetBotAlpha = SetAlpha
-----------------------------------------------------
-- Misc player funcs
function IsPlayerInWater(amx, player)
return isElementInWater(player)
end
function IsPlayerOnFire(amx, player)
return isElementOnFire(player)
end
function IsPlayerDucked(amx, player)
return isPedDucked(player)
end
function IsPlayerOnGround(amx, player)
return isPedOnGround(amx, player)
end
function SetPlayerOnFire(amx, player, state)
return setElementOnFire(player, state)
end
function GetPlayerStat(amx, player, stat)
return getPedStat(player, stat)
end
function SetPlayerStat(amx, player, stat, value)
return setPedStat(player, stat, value)
end
function GetPlayerDoingDriveBy(amx, ped)
return getElementData(pedt, 'DoingDriveBy')
end
function SetPlayerDoingDriveBy(amx, ped, state)
clientCall(root, 'setPedDoingGangDriveby', ped, state)
return setElementData(ped, 'DoingDriveBy', state)
end
function GetPlayerCanBeKnockedOffBike(amx, ped)
return getElementData(ped, 'CanBeKnockedOffBike')
end
function SetPlayerCanBeKnockedOffBike(amx, ped, state)
clientCall(root, 'setPedCanBeKnockedOffBike', ped, state)
return setElementData(ped, 'CanBeKnockedOffBike', state)
end
function SetPlayerWeaponSlot(amx, ped, slot)
clientCall(root, 'setPedWeaponSlot', ped, slot)
return true
end
function SetPlayerHeadless(amx, ped, state)
return setPedHeadless(ped, state)
end
function GetPlayerBlurLevel(amx, player)
return getPlayerBlurLevel(player)
end
function SetPlayerBlurLevel(amx, player, level)
return setPlayerBlurLevel(player, level)
end
function SetPlayerControlState(amx, player, control, state)
return setControlState(player, control, state)
end
function GetPlayerSkillLevel(amx, player, skill)
return getPedStat(player, skill + 69)
end
IsBotInWater = IsPlayerInWater
IsBotOnFire = IsPlayerOnFire
IsBotDucked = IsPlayerDucked
IsBotOnGround = IsPlayerOnGround
GetBotFightingStyle = GetPlayerFightingStyle
SetBotFightingStyle = SetPlayerFightingStyle
SetBotOnFire = SetPlayerOnFire
GetBotSkin = GetPlayerSkin
SetBotSkin = SetPlayerSkin
GetBotStat = GetPlayerStat
SetBotStat = SetPlayerStat
GetBotDoingDriveBy = GetPlayerDoingDriveBy
SetBotDoingDriveBy = SetPlayerDoingDriveBy
GetBotCanBeKnockedOffBike = GetPlayerCanBeKnockedOffBike
SetBotCanBeKnockedOffBike = SetPlayerCanBeKnockedOffBike
SetBotWeaponSlot = SetPlayerWeaponSlot
SetBotHeadless = SetPlayerHeadless
GetBotVehicleSeat = GetPlayerVehicleSeat
GetBotVelocity = GetPlayerVelocity
SetBotVelocity = SetPlayerVelocity
-----------------------------------------------------
-- Bots
function CreateBot(amx, model, x, y, z, name)
local ped = createPed(model, x, y, z)
setElementData(ped, 'amx.shownametag', true, true)
setElementData(ped, 'BotName', name, true)
local pedID = addElem(g_Bots, ped)
procCallOnAll('OnBotConnect', pedID, name)
return pedID
end
function DestroyBot(amx, bot)
removeElem(g_Bots, bot)
destroyElement(bot)
return true
end
function GetBotState(amx, bot)
return getBotState(bot)
end
function PutBotInVehicle(amx, bot, vehicle, seat)
return warpPedIntoVehicle(bot, vehicle, seat)
end
function RemoveBotFromVehicle(amx, bot)
local vehicle = getPedOccupiedVehicle(bot)
if vehicle then
return removePedFromVehicle(bot)
end
end
function SetBotControlState(amx, bot, control, state)
clientCall(root, 'setPedControlState', bot, control, state)
return true
end
function SetBotAimTarget(amx, bot, x, y, z)
clientCall(root, 'setPedAimTarget', bot, x, y, z)
return true
end
function IsBotDead(amx, bot)
return isPedDead(bot)
end
function KillBot(amx, bot)
return killPed(bot)
end
function GetBotRot(amx, ped, refX, refY, refZ)
if not ped then
return false
end
local rX, rX, rZ = getPedRotation(ped)
writeMemFloat(amx, refX, rX)
writeMemFloat(amx, refY, rY)
writeMemFloat(amx, refZ, rZ)
return true
end
function SetBotRot(amx, Ped, rX, rY, rY)
return setPedRotation(ped, rX, rY, rZ)
end
function GetBotName(amx, bot, nameBuf, bufSize)
local name = getElementData(bot, 'BotName')
if #name <= bufSize then
writeMemString(amx, nameBuf, name)
return string.len(name)
end
end
GetBotHealth = GetPlayerHealth
SetBotHealth = SetPlayerHealth
GetBotArmour = GetPlayerArmour
SetBotArmour = SetPlayerArmour
GetBotPos = GetObjectPos
SetBotPos = SetObjectPos
-----------------------------------------------------
-- Native Markers
function CreateMarker(amx, x, y, z, typeid, size, r, g, b, a)
local marker = createMarker(x, y, z, typeid, size, r, g, b, a, root)
local markerID = addElem(g_Markers, marker)
procCallOnAll('OnMarkerCreate', markerID)
return markerID
end
function DestroyMarker(amx, marker)
removeElem(g_Markers, marker)
destroyElement(marker)
return true
end
function GetMarkerColor(amx, marker, colorid)
local R, G, B, A = getMarkerColor( marker )
if colorid == 0 then return R end
if colorid == 1 then return G end
if colorid == 2 then return B end
if colorid == 3 then return A end
return false
end
function GetMarkerIcon(amx, marker)
local icon = getMarkerIcon(marker)
if icon == "none" then return 0 end
if icon == "arrow" then return 1 end
if icon == "finish" then return 2 end
return false
end
function GetMarkerSize(amx, marker, refSize)
local size = getMarkerSize(marker)
writeMemFloat(amx, refSize, marker)
return true
end
function GetMarkerTarget(amx, marker, refX, refY, refZ)
local x, y, z = getMarkerTarget(marker)
if x == false then return false end
writeMemFloat(amx, refX, x)
writeMemFloat(amx, refY, y)
writeMemFloat(amx, refZ, z)
return true
end
function GetMarkerType(amx, marker)
local mtype = getMarkerType(marker)
if mtype == false then return false end
if mtype == "checkpoint" then return 0 end
if mtype == "ring" then return 1 end
if mtype == "cylinder" then return 2 end
if mtype == "arrow" then return 3 end
if mtype == "corona" then return 4 end
return false
end
function SetMarkerColor(amx, marker, red, green, blue, alpha)
return setMarkerColor(marker, red, green, blue, alpha)
end
function SetMarkerIcon(amx, marker, icon)
if icon == 0 then icon = "none"
elseif icon == 1 then icon = "arrow"
elseif icon == 2 then icon = "finish"
else return false end
return setMarkerIcon(amx, marker, icon)
end
function SetMarkerSize(amx, marker, size)
return setMarkerSize(marker, size)
end
function SetMarkerTarget(amx, marker, x, y, z)
return setMarkerTarget(marker, x, y, z)
end
function SetMarkerType(amx, marker, typeid)
if typeid == 0 then typeid = "checkpoint"
elseif typeid == 1 then typeid = "ring"
elseif typeid == 2 then typeid = "cylinder"
elseif typeid == 3 then typeid = "arrow"
elseif typeid == 4 then typeid = "corona"
else return false end
return setMarkerType(marker, typeid)
end
function IsPlayerInMarker(amx, marker, elem)
return isElementWithinMarker(elem, marker)
end
IsVehicleInMarker = IsPlayerInMarker
IsBotInMarker = IsPlayerInMarker
-----------------------------------------------------
-- SlothBots
--
-----------------------------------------------------
-- Player Data
function SetPlayerDataInt(amx, player, key, value)
return setElementData(player, key, value)
end
function GetPlayerDataInt(amx, player, key)
return getElementData(player, key)
end
SetPlayerDataFloat = SetPlayerDataInt
GetPlayerDataFloat = GetPlayerDataInt
SetPlayerDataBool = SetPlayerDataInt
GetPlayerDataBool = GetPlayerDataInt
SetPlayerDataStr = SetPlayerDataInt
function GetPlayerDataStr(amx, player, key, buf, len)
local data = getElementData(player, key)
if #data <= len then
writeMemString(amx, buf, data)
end
end
function IsPlayerDataSet(amx, player, key)
return true
end
function ResetPlayerData(amx, player, key)
return setElementData(player, key, nil)
end
function ResetAllPlayerData(amx, player)
return true
end
-----------------------------------------------------
-- Vehicles
function GetVehicleEngineState(amx, vehicle)
return getVehicleEngineState(vehicle)
end
function SetVehicleEngineState(amx, vehicle, state)
return setVehicleEngineState(vehicle, state)
end
function GetVehicleDoorState(amx, vehicle, door)
return getVehicleDoorState(vehicle, door)
end
function SetVehicleDoorState(amx, vehicle, door, state)
return setVehicleDoorState(vehicle, door, state)
end
function GetVehicleMaxPassengers(amx, vehicle)
return getVehicleMaxPassengers(vehicle)
end
function GetVehicleLightState(amx, vehicle, light)
return getVehicleLightState(vehicle, light)
end
function SetVehicleLightState(amx, vehicle, light, state)
return setVehicleLightState(vehicle, light, state)
end
function GetVehicleOverrideLights(amx, vehicle)
return getVehicleOverrideLights(vehicle)
end
function SetVehicleOverrideLights(amx, vehicle, state)
return setVehicleOverrideLights(vehicle, state)
end
function GetVehicleWheelState(amx, vehicle, wheelid)
local w1, w2, w3, w4 = getVehicleWheelStates(vehicleid)
if wheelid == 0 then return w1 end
if wheelid == 1 then return w2 end
if wheelid == 2 then return w3 end
if wheelid == 3 then return w4 end
end
function SetVehicleWheelState(amx, vehicle, frontLeft, rearLeft, frontRight, rearRight)
return setVehicleWheelStates(vehicle, frontLeft, rearLeft, frontRight, rearRight)
end
function GetVehiclePanelState(amx, vehicle, panel)
return getVehiclePanelState(vehicle, panel)
end
function SetVehiclePanelState(amx, vehicle, panel, state)
return setVehiclePanelState(vehicle, panel, state)
end
function GetVehiclePaintjob(amx, vehicle)
return getVehiclePaintjob(vehicle)
end
function GetVehicleSirensOn(amx, vehicle)
return getVehicleSirensOn(vehicle)
end
function SetVehicleSirensOn(amx, vehicle, state)
return setVehicleSirensOn(vehicle, state)
end
function IsTrainDerailable(amx, train)
return isTrainDerailable(train)
end
function IsTrainDerailed(amx, train)
return isTrainDerailed(train)
end
function SetTrainDerailable(amx, train, state)
return setTrainDerailable(train, state)
end
function SetTrainDerailed(amx, train, state)
return setTrainDerailed(train, state)
end
function GetTrainDirection(amx, train)
return getTrainDirection(train)
end
function SetTrainDirection(amx, train, direction)
return setTrainDirection(train, direction)
end
function GetTrainSpeed(amx, train, refSpeed)
local speed = getTrainSpeed(train)
writeMemFloat(amx, refSpeed, speed)
return true
end
function SetTrainSpeed(amx, train, speed)
return setTrainSpeed(train, speed)
end
-----------------------------------------------------
-- Water
function GetWaveHeight(amx)
return getWaveHeight()
end
function SetWaveHeight(amx, height)
return setWaveHeight(height)
end
function SetWaterLevel(amx, level)
return setWaterLevel(level)
end
-----------------------------------------------------
-- Pickups
function GetPickupType(amx, pickup)
return getPickupType(pickup)
end
function SetPickupType(amx, pickup, typeid, amount, ammo)
return setPickupType(pickup, typeid, amount, ammo)
end
function GetPickupWeapon(amx, pickup)
return getPickupWeapon(pickup)
end
function GetPickupAmount(amx, pickup)
return getPickupAmount(pickup)
end
function GetPickupAmmo(amx, pickup)
return getPickupAmmo(pickup)
end
-----------------------------------------------------
-- Misc
function SetSkyGradient(amx, topRed, topGreen, topBlue, bottomRed, bottomGreen, bottomBlue)
return setSkyGradient(topRed, topGreen, topBlue, bottomRed, bottomGreen, bottomBlue)
end
function ResetSkyGradient(amx)
return resetSkyGradient()
end
function GetCloudsEnabled(amx)
return getCloudsEnabled()
end
function SetCloudsEnabled(amx, state)
return setCloudsEnabled(state)
end
function IsGarageOpen(amx, garage)
return isGarageOpen(garage)
end
function SetGarageOpen(amx, garage, state)
return setGarageOpen( garage, state )
end
function IsGlitchEnabled(amx, glitch)
return isGlitchEnabled(glitch)
end
function SetGlitchEnabled(amx, glitch, state)
return setGlitchEnabled(amx, glitch, state)
end
function SetFPSLimit(amx, limit)
return setFPSLimit(limit)
end
function GetFPSLimit(amx)
return getFPSLimit()
end
function GetPlayerCount(amx)
return getPlayerCount(amx)
end
function GetRandomPlayer(amx)
return getElemID(getRandomPlayer())
end
function FadePlayerCamera(amx, player, fadeIn, timeToFade, red, green, blue)
return fadeCamera(player, fadeIn, timeToFade, red, green, blue)
end
function GetRuleValue(amx, rule, nameBuf, bufSize)
local ruleval = getRuleValue(rule)
if #ruleval <= bufSize then
writeMemString(amx, nameBuf, ruleval)
end
end
function SetRuleValue(amx, rule, value)
return setRuleValue(rule, value)
end
function RemoveRuleValue(amx, rule)
return removeRuleValue(rule)
end
function md5hash(amx, str, refStr, refSize)
local hash = md5(str)
if #hash <= refSize then
writeMemString(amx, refStr, hash)
end
end
function GetDistanceBetweenPoints2D(amx, x1, y1, x2, y2)
return getDistanceBetweenPoints2D(x1, y1, x2, y2)
end
function GetDistanceBetweenPoints3D(amx, x1, y1, z1, x2, y2, z2)
return getDistanceBetweenPoints3D(x1, y1, z1, x2, y2, z2)
end
function AddScoreboardColumn(amx, column)
outputDebugString("AddScoreboardColumn is being ignored!")
-- TODO(q): this needs to be added back later
-- return exports.amxscoreboard:addScoreboardColumn('_' .. column)
end
function RemoveScoreboardColumn(amx, column)
outputDebugString("RemoveScoreboardColumn is being ignored!")
-- TODO(q): this needs to be added back later
-- return exports.amxscoreboard:removeScoreboardColumn('_' .. column)
end
function SetScoreboardData(amx, player, column, data)
return setElementData(player, '_' .. column, data)
end
-----------------------------------------------------
function ShowCursor(amx, player, show, controls)
return showCursor(player, show, controls)
end
function AddEventHandler(amx, event, func)
if g_EventNames[event] then
g_Events[func] = event
end
end
function RemoveEventHandler(amx, func)
g_Events[func] = nil
end
function AttachElementToElement(amx, elem, toelem, xPos, yPos, zPos, xRot, yRot, zRot)
return attachElements(elem, toelem, xPos, yPos, zPos, xRot, yRot, zRot)
end