@@ -196,35 +196,63 @@ wndSkin = {
196
196
}
197
197
198
198
function setSkinCommand (cmd , skin )
199
+
200
+ if isPlayerMoving (localPlayer ) then
201
+ errMsg (" You can't use /ss while running! Stop moving first!" )
202
+ return
203
+ end
204
+
199
205
skin = skin and tonumber (skin )
200
206
if skin then
201
207
server .setMySkin (skin )
202
208
fadeCamera (true )
203
209
closeWindow (wndSpawnMap )
204
210
closeWindow (wndSetPos )
211
+ else
212
+ errMsg (" Invalid skin ID! Usage: /ss [id]" )
205
213
end
206
214
end
207
215
addCommandHandler (' setskin' , setSkinCommand )
208
216
addCommandHandler (' ss' , setSkinCommand )
209
217
218
+ function isPlayerMoving (p )
219
+ if isElement (p ) and getElementType (p ) == " player" then
220
+ return Vector3 (getElementVelocity (p )).length ~= 0
221
+ end
222
+ return false
223
+ end
224
+
210
225
---- -----------------------
211
226
--- Set animation window
212
227
---- -----------------------
213
228
214
229
function applyAnimation (leaf )
215
- if type (leaf ) ~= ' table' then
216
- leaf = getSelectedGridListLeaf (wndAnim , ' animlist' )
217
- if not leaf then
230
+ if isPlayerAiming (localPlayer ) then
231
+ errMsg (" You cannot perform animations while actively aiming a weapon!" )
232
+ return
233
+ end
234
+
235
+ if isPedReloadingWeapon (localPlayer ) then
236
+ errMsg (" You cannot perform animations while reloading a weapon!" )
237
+ return
238
+ end
239
+
240
+ if type (leaf ) ~= " table" then
241
+ leaf = getSelectedGridListLeaf (wndAnim , " animlist" )
242
+ if not leaf or not leaf .parent .name or not leaf .name or string.len (leaf .name ) > 25 or string.len (leaf .parent .name ) > 25
243
+ then errMsg (" Invalid animation request" )
218
244
return
219
245
end
220
246
end
221
247
server .setPedAnimation (localPlayer , leaf .parent .name , leaf .name , true , true )
222
248
end
223
249
224
250
function stopAnimation ()
225
- server .setPedAnimation (localPlayer , false )
251
+ if getPedAnimation (localPlayer ) then
252
+ server .setPedAnimation (localPlayer , false )
253
+ end
226
254
end
227
- addCommandHandler (" stopanim" , stopAnimation )
255
+ addCommandHandler (' stopanim' , stopAnimation )
228
256
bindKey (" lshift" , " down" , stopAnimation )
229
257
230
258
wndAnim = {
@@ -255,6 +283,22 @@ wndAnim = {
255
283
256
284
addCommandHandler (' anim' ,
257
285
function (command , lib , name )
286
+
287
+ if not lib or not name then
288
+ return errMsg (" Invalid animation! Rule of thumb: Provide both library and anim name!" )
289
+ end
290
+
291
+ if not tostring (lib ) or not tostring (name ) then
292
+ return errMsg (" Invalid animation!" )
293
+ end
294
+
295
+ if string.len (lib ) > 40 or string.len (name ) > 40 then
296
+ return errMsg (" Invalid animation!" )
297
+ end
298
+
299
+ if isPlayerAiming (localPlayer ) then errMsg (" You cannot perform animations while actively aiming a weapon!" ) return end
300
+ if isPedReloadingWeapon (localPlayer ) then errMsg (" You cannot perform animations while reloading a weapon!" ) return end
301
+
258
302
if lib and name and (
259
303
(lib :lower () == " finale" and name :lower () == " fin_jump_on" ) or
260
304
(lib :lower () == " finale2" and name :lower () == " fin_cop1_climbout" )
@@ -278,20 +322,24 @@ function addWeapon(leaf, amount)
278
322
return
279
323
end
280
324
end
281
- if amount < 1 then
282
- errMsg (" Invalid amount" )
325
+ if amount < 1 or amount > 999999999 or string.len ( amount ) > 10 then
326
+ errMsg (" Invalid amount! " )
283
327
return
284
328
end
285
329
if isPedReloadingWeapon (localPlayer ) then
286
330
errMsg (" You can't get weapons while reloading a weapon!" )
287
- return
331
+ return
332
+ end
333
+ if isPlayerAiming (localPlayer ) then
334
+ errMsg (" You can't get weapons while aiming a weapon!" )
335
+ return
288
336
end
289
337
server .giveMeWeapon (leaf .id , amount )
290
338
end
291
339
292
340
function isPlayerAiming (p )
293
341
if isElement (p ) then
294
- if getPedTask (p , " secondary" , 0 ) == " TASK_SIMPLE_USE_GUN" then
342
+ if getPedTask (p , " secondary" , 0 ) == " TASK_SIMPLE_USE_GUN" or isPedDoingGangDriveby ( p ) then
295
343
return true
296
344
end
297
345
end
@@ -323,12 +371,19 @@ wndWeapon = {
323
371
}
324
372
325
373
function giveWeaponCommand (cmd , weapon , amount )
374
+
375
+ if weapon and string.len (weapon ) > 25 then errMsg (" Invalid weapon name/ID!" ) return end
376
+ if amount and string.len (amount ) > 9 then errMsg (" Invalid amount!" ) return end
377
+
326
378
weapon = tonumber (weapon ) and math.floor (tonumber (weapon )) or weapon and getWeaponIDFromName (weapon ) or 0
327
- amount = amount and math.floor (tonumber (amount )) or 1500
328
- if amount < 1 or weapon < 1 or weapon > 46 then return end
379
+ amount = tonumber (amount ) and math.floor (tonumber (amount )) or 2500
380
+
381
+ if not weapon then errMsg (" Invalid weapon! Syntax: /wp [weapon id/name]" ) return end
382
+ if not amount or amount < 1 or amount > 999999999 or weapon < 1 or weapon > 46 then return end
329
383
if internallyBannedWeapons [weapon ] then return end
330
- if isPlayerAiming (localPlayer ) then errMsg (" You can't use this command while aiming a weapon!" ) return end
384
+ if isPlayerAiming (localPlayer ) then errMsg (" You can't get weapons while aiming a weapon or driveby'ing !" ) return end
331
385
if isPedReloadingWeapon (localPlayer ) then errMsg (" You can't use this command while reloading a weapon!" ) return end
386
+ if weapon == 39 or weapon == 40 then errMsg (" You can't get Satchels with /wp command! Use F1 > weapons instead!" ) return end
332
387
server .giveMeWeapon (weapon , amount )
333
388
end
334
389
addCommandHandler (' give' , giveWeaponCommand )
@@ -340,7 +395,16 @@ addCommandHandler('wp', giveWeaponCommand)
340
395
341
396
addCommandHandler (' setstyle' ,
342
397
function (cmd , style )
343
- style = style and tonumber (style ) or 7
398
+ style = style and tonumber (style ) or 6
399
+
400
+ if not style then return end
401
+
402
+ if string.len (style ) > 2 or style < 0 or style > 16 then
403
+ return errMsg (" Invalid style ID!" )
404
+ end
405
+
406
+ if getPedFightingStyle (localPlayer ) == style then return end
407
+
344
408
if allowedStyles [style ] then
345
409
server .setPedFightingStyle (localPlayer , style )
346
410
end
@@ -440,6 +504,12 @@ wndClothes = {
440
504
441
505
function addClothesCommand (cmd , type , model , texture )
442
506
type = type and tonumber (type )
507
+
508
+ if string.len (type ) > 30 or string.len (model ) > 30 or string.len (texture ) > 30 then
509
+ errMsg (" Invalid clothes input!" )
510
+ return
511
+ end
512
+
443
513
if type and model and texture then
444
514
server .addPedClothes (localPlayer , texture , model , type )
445
515
end
@@ -449,7 +519,7 @@ addCommandHandler('ac', addClothesCommand)
449
519
450
520
function removeClothesCommand (cmd , type )
451
521
type = type and tonumber (type )
452
- if type then
522
+ if type and string.len ( type ) < 30 then
453
523
server .removePedClothes (localPlayer , type )
454
524
end
455
525
end
@@ -1102,6 +1172,9 @@ addCommandHandler('getpos', getPosCommand)
1102
1172
addCommandHandler (' gp' , getPosCommand )
1103
1173
1104
1174
function setPosCommand (cmd , x , y , z , r )
1175
+ if isPlayerAiming (localPlayer ) then return errMsg (" You can't use /sp while aiming a weapon!" ) end
1176
+ if isPedReloadingWeapon (localPlayer ) then return errMsg (" You can't use /sp while reloading a weapon!" ) end
1177
+
1105
1178
local vehicle = getPedOccupiedVehicle (localPlayer )
1106
1179
if vehicle then
1107
1180
local vehModel = getElementModel (vehicle )
@@ -1278,12 +1351,27 @@ wndCreateVehicle = {
1278
1351
}
1279
1352
1280
1353
function createVehicleCommand (cmd , ...)
1354
+
1281
1355
local args = {... }
1282
- vehID = getVehicleModelFromName (table.concat (args ," " )) or tonumber (args [1 ]) and math.floor (tonumber (args [1 ])) or false
1356
+
1357
+ if not ... then
1358
+ return errMsg (" Enter vehicle model please! Syntax: /cv [vehicle ID/name]" )
1359
+ end
1360
+
1361
+ vehID = getVehicleModelFromName (table.concat (args , " " )) or tonumber (args [1 ]) and math.floor (tonumber (args [1 ])) or false
1362
+
1363
+ if not vehID or not tostring (vehID ) or not tonumber (vehID ) then
1364
+ return errMsg (" Invalid vehicle model!" )
1365
+ end
1366
+
1367
+ if string.len (table.concat (args , " " )) > 25 or tonumber (vehID ) and string.len (vehID ) > 3 then
1368
+ return errMsg (" Invalid vehicle model!" )
1369
+ end
1370
+
1283
1371
if vehID and vehID >= 400 and vehID <= 611 then
1284
1372
server .giveMeVehicles (vehID )
1285
1373
else
1286
- errMsg (" Invalid vehicle model" )
1374
+ errMsg (" Invalid vehicle model! " )
1287
1375
end
1288
1376
end
1289
1377
addCommandHandler (' createvehicle' , createVehicleCommand )
@@ -1462,9 +1550,19 @@ function setColorCommand(cmd, ...)
1462
1550
if not vehicle then
1463
1551
return
1464
1552
end
1465
- local colors = { getVehicleColor (vehicle ) }
1466
- local args = { ... }
1467
- for i = 1 ,12 do
1553
+ local colors = {getVehicleColor (vehicle )}
1554
+ local args = {... }
1555
+
1556
+ if string.len (... ) > 5 or not tonumber (... ) then
1557
+ return
1558
+ end
1559
+
1560
+ if not ... then
1561
+ errMsg (" Enter colors please!" )
1562
+ return
1563
+ end
1564
+
1565
+ for i = 1 , 12 do
1468
1566
colors [i ] = args [i ] and tonumber (args [i ]) or colors [i ]
1469
1567
end
1470
1568
server .setVehicleColor (vehicle , unpack (colors ))
@@ -1498,6 +1596,7 @@ function openColorPicker()
1498
1596
end
1499
1597
1500
1598
function closedColorPicker ()
1599
+ if not editingVehicle then return end
1501
1600
local r1 , g1 , b1 , r2 , g2 , b2 , r3 , g3 , b3 , r4 , g4 , b4 = getVehicleColor (editingVehicle , true )
1502
1601
server .setVehicleColor (editingVehicle , r1 , g1 , b1 , r2 , g2 , b2 , r3 , g3 , b3 , r4 , g4 , b4 )
1503
1602
local r , g , b = getVehicleHeadLightColor (editingVehicle )
@@ -1548,7 +1647,10 @@ function paintjobInit()
1548
1647
end
1549
1648
1550
1649
function applyPaintjob (paint )
1551
- server .setVehiclePaintjob (getPedOccupiedVehicle (localPlayer ), paint .id )
1650
+ local vehicle = getPedOccupiedVehicle (localPlayer )
1651
+ if vehicle and tonumber (paint .id ) and string.len (paint .id ) == 1 then
1652
+ server .setVehiclePaintjob (vehicle , paint .id )
1653
+ end
1552
1654
end
1553
1655
1554
1656
wndPaintjob = {
@@ -1582,11 +1684,17 @@ wndPaintjob = {
1582
1684
}
1583
1685
1584
1686
function setPaintjobCommand (cmd , paint )
1687
+
1585
1688
local vehicle = getPedOccupiedVehicle (localPlayer )
1689
+ if not vehicle then return end
1690
+
1586
1691
paint = paint and tonumber (paint )
1587
- if not paint or not vehicle then
1588
- return
1692
+
1693
+ if not paint then return end
1694
+ if string.len (paint ) > 5 then errMsg (" Invalid paintjob ID!" )
1695
+ return
1589
1696
end
1697
+
1590
1698
server .setVehiclePaintjob (vehicle , paint )
1591
1699
end
1592
1700
addCommandHandler (' paintjob' , setPaintjobCommand )
@@ -1715,6 +1823,10 @@ wndWeather = {
1715
1823
1716
1824
function setWeatherCommand (cmd , weather )
1717
1825
weather = weather and tonumber (weather )
1826
+ if weather and string.len (weather ) > 266 then
1827
+ errMsg (" Invalid weather ID!" )
1828
+ return
1829
+ end
1718
1830
if weather then
1719
1831
setWeather (weather )
1720
1832
end
@@ -1754,7 +1866,7 @@ end
1754
1866
1755
1867
function applyGameSpeed ()
1756
1868
speed = getControlNumber (wndGameSpeed , ' speed' )
1757
- if speed then
1869
+ if speed and tonumber ( speed ) then
1758
1870
setMyGameSpeed (speed )
1759
1871
end
1760
1872
closeWindow (wndGameSpeed )
@@ -1906,6 +2018,10 @@ end
1906
2018
1907
2019
function alphaCommand (command , alpha )
1908
2020
alpha = alpha and tonumber (alpha ) or 255
2021
+ if alpha and string.len (alpha ) > 3 then
2022
+ errMsg (" Invalid input!" )
2023
+ return
2024
+ end
1909
2025
if alpha >= 0 and alpha <= 255 then
1910
2026
server .setElementAlpha (localPlayer , alpha )
1911
2027
end
@@ -1996,7 +2112,8 @@ addEventHandler('onClientResourceStart', resourceRoot,
1996
2112
function ()
1997
2113
fadeCamera (true )
1998
2114
getPlayers ()
1999
- setJetpackMaxHeight ( 9001 )
2115
+ setJetpackMaxHeight (9001 )
2116
+ setAircraftMaxHeight (1600 )
2000
2117
triggerServerEvent (' onLoadedAtClient' , resourceRoot )
2001
2118
createWindow (wndMain )
2002
2119
hideAllWindows ()
0 commit comments