Guest User

Untitled

a guest
Nov 24th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 44.33 KB | None | 0 0
  1. armoredCars = { [427]=true, [528]=true, [432]=true, [601]=true, [428]=true, [597]=true } -- Enforcer, FBI Truck, Rhino, SWAT Tank, Securicar, SFPD Car
  2. totalTempVehicles = 0
  3. respawnTimer = nil
  4.  
  5. -- EVENTS
  6. addEvent("onVehicleDelete", false)
  7.  
  8. -- /unflip
  9. function unflipCar(thePlayer, commandName, targetPlayer)
  10. if (exports.global:isPlayerAdmin(thePlayer) or getTeamName(getPlayerTeam(thePlayer)) == "Los Santos Towing and Recovery") then
  11. if not targetPlayer then
  12. if not (isPedInVehicle(thePlayer)) then
  13. outputChatBox("You are not in vehicle.", thePlayer, 255, 0, 0)
  14. else
  15. local veh = getPedOccupiedVehicle(thePlayer)
  16. local rx, ry, rz = getVehicleRotation(veh)
  17. setVehicleRotation(veh, 0, ry, rz)
  18. outputChatBox("Your car was unflipped!", thePlayer, 0, 255, 0)
  19. end
  20. else
  21. local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, targetPlayer)
  22. if targetPlayer then
  23. local logged = getElementData(targetPlayer, "loggedin")
  24. local username = getPlayerName(thePlayer):gsub("_"," ")
  25.  
  26. if (logged==0) then
  27. outputChatBox("Player is not logged in.", thePlayer, 255, 0, 0)
  28. else
  29. local pveh = getPedOccupiedVehicle(targetPlayer)
  30. if pveh then
  31. local rx, ry, rz = getVehicleRotation(pveh)
  32. setVehicleRotation(pveh, 0, ry, rz)
  33. if getElementData(thePlayer, "hiddenadmin") == 1 then
  34. outputChatBox("Your car was unflipped by a Hidden Admin.", targetPlayer, 0, 255, 0)
  35. else
  36. outputChatBox("Your car was unflipped by " .. username .. ".", targetPlayer, 0, 255, 0)
  37. end
  38. outputChatBox("You unflipped " .. targetPlayerName:gsub("_"," ") .. "'s car.", thePlayer, 0, 255, 0)
  39. else
  40. outputChatBox(targetPlayerName:gsub("_"," ") .. " is not in a vehicle.", thePlayer, 255, 0, 0)
  41. end
  42. end
  43. end
  44. end
  45. end
  46. end
  47. addCommandHandler("unflip", unflipCar, false, false)
  48.  
  49. -- /unlockcivcars
  50. function unlockAllCivilianCars(thePlayer, commandName)
  51. if (exports.global:isPlayerAdmin(thePlayer)) then
  52. local count = 0
  53. for key, value in ipairs(exports.pool:getPoolElementsByType("vehicle")) do
  54. if (isElement(value)) and (getElementType(value)) then
  55. local id = getElementData(value, "dbid")
  56.  
  57. if (id) and (id>=0) then
  58. local owner = getElementData(value, "owner")
  59. if (owner==-2) then
  60. setVehicleLocked(value, false)
  61. count = count + 1
  62. end
  63. end
  64. end
  65. end
  66.  
  67. outputChatBox("Unlocked " .. count .. " civilian vehicles.", thePlayer, 255, 194, 14)
  68. end
  69. end
  70. addCommandHandler("unlockcivcars", unlockAllCivilianCars, false, false)
  71.  
  72. -- /veh
  73. local leadplus = { [425] = true, [520] = true, [447] = true, [432] = true, [444] = true, [556] = true, [557] = true, [441] = true, [464] = true, [501] = true, [465] = true, [564] = true, [476] = true }
  74. function createTempVehicle(thePlayer, commandName, ...)
  75. if (exports.global:isPlayerFullAdmin(thePlayer)) then
  76. local args = {...}
  77. if (#args < 1) then
  78. outputChatBox("SYNTAX: /" .. commandName .. " [id/name] [color1] [color2]", thePlayer, 255, 194, 14)
  79. else
  80. local vehicleID = tonumber(args[1])
  81. local col1 = #args ~= 1 and tonumber(args[#args - 1]) or -1
  82. local col2 = #args ~= 1 and tonumber(args[#args]) or -1
  83.  
  84. if not vehicleID then -- vehicle is specified as name
  85. local vehicleEnd = #args
  86. repeat
  87. vehicleID = getVehicleModelFromName(table.concat(args, " ", 1, vehicleEnd))
  88. vehicleEnd = vehicleEnd - 1
  89. until vehicleID or vehicleEnd == -1
  90. if vehicleEnd == -1 then
  91. outputChatBox("Invalid Vehicle Name.", thePlayer, 255, 0, 0)
  92. return
  93. elseif vehicleEnd == #args - 2 then
  94. col2 = -1
  95. elseif vehicleEnd == #args - 1 then
  96. col1 = -1
  97. col2 = -1
  98. end
  99. end
  100.  
  101. local r = getPedRotation(thePlayer)
  102. local x, y, z = getElementPosition(thePlayer)
  103. x = x + ( ( math.cos ( math.rad ( r ) ) ) * 5 )
  104. y = y + ( ( math.sin ( math.rad ( r ) ) ) * 5 )
  105.  
  106. local letter1 = string.char(math.random(65,90))
  107. local letter2 = string.char(math.random(65,90))
  108. local plate = letter1 .. letter2 .. math.random(0, 9) .. " " .. math.random(1000, 9999)
  109.  
  110. if vehicleID then
  111. if leadplus[ vehicleID ] and not exports.global:isPlayerLeadAdmin(thePlayer) then
  112. outputChatBox( "Insufficient access.", thePlayer, 255, 0, 0)
  113. return
  114. end
  115.  
  116. local veh = createVehicle(vehicleID, x, y, z, 0, 0, r, plate)
  117.  
  118. if not (veh) then
  119. outputChatBox("Invalid Vehicle ID.", thePlayer, 255, 0, 0)
  120. else
  121. if (armoredCars[vehicleID]) then
  122. setVehicleDamageProof(veh, true)
  123. end
  124.  
  125. totalTempVehicles = totalTempVehicles + 1
  126. local dbid = (-totalTempVehicles)
  127. exports.pool:allocateElement(veh, dbid)
  128.  
  129. setVehicleColor(veh, col1, col2, col1, col2)
  130.  
  131. setElementInterior(veh, getElementInterior(thePlayer))
  132. setElementDimension(veh, getElementDimension(thePlayer))
  133.  
  134. setVehicleOverrideLights(veh, 1)
  135. setVehicleEngineState(veh, false)
  136. setVehicleFuelTankExplodable(veh, false)
  137.  
  138. exports['anticheat-system']:changeProtectedElementDataEx(veh, "dbid", dbid)
  139. exports['anticheat-system']:changeProtectedElementDataEx(veh, "fuel", 100, false)
  140. exports['anticheat-system']:changeProtectedElementDataEx(veh, "Impounded", 0)
  141. exports['anticheat-system']:changeProtectedElementDataEx(veh, "engine", 0, false)
  142. exports['anticheat-system']:changeProtectedElementDataEx(veh, "oldx", x, false)
  143. exports['anticheat-system']:changeProtectedElementDataEx(veh, "oldy", y, false)
  144. exports['anticheat-system']:changeProtectedElementDataEx(veh, "oldz", z, false)
  145. exports['anticheat-system']:changeProtectedElementDataEx(veh, "faction", -1)
  146. exports['anticheat-system']:changeProtectedElementDataEx(veh, "owner", -1, false)
  147. exports['anticheat-system']:changeProtectedElementDataEx(veh, "job", 0, false)
  148. exports['anticheat-system']:changeProtectedElementDataEx(veh, "handbrake", 0, false)
  149. outputChatBox(getVehicleName(veh) .. " spawned with TEMP ID " .. dbid .. ".", thePlayer, 255, 194, 14)
  150.  
  151. exports['vehicle-interiors']:add( veh )
  152. end
  153. else
  154. outputChatBox("Invalid Vehicle ID.", thePlayer, 255, 0, 0)
  155. end
  156. end
  157. end
  158. end
  159. addCommandHandler("veh", createTempVehicle, false, false)
  160.  
  161. -- /oldcar
  162. function getOldCarID(thePlayer, commandName)
  163. local oldvehid = getElementData(thePlayer, "lastvehid")
  164.  
  165. if not (oldvehid) then
  166. outputChatBox("You have not been in a vehicle yet.", thePlayer, 255, 0, 0)
  167. else
  168. outputChatBox("Old Vehicle ID: " .. tostring(oldvehid) .. ".", thePlayer, 255, 194, 14)
  169. end
  170. end
  171. addCommandHandler("oldcar", getOldCarID, false, false)
  172.  
  173. -- /thiscar
  174. function getCarID(thePlayer, commandName)
  175. local veh = getPedOccupiedVehicle(thePlayer)
  176.  
  177. if (veh) then
  178. local dbid = getElementData(veh, "dbid")
  179. outputChatBox("Current Vehicle ID: " .. dbid, thePlayer, 255, 194, 14)
  180. else
  181. outputChatBox("You are not in a vehicle.", thePlayer, 255, 0, 0)
  182. end
  183. end
  184. addCommandHandler("thiscar", getCarID, false, false)
  185.  
  186. -- /gotocar
  187. function gotoCar(thePlayer, commandName, id)
  188. if (exports.global:isPlayerAdmin(thePlayer)) then
  189. if not (id) then
  190. outputChatBox("SYNTAX: /" .. commandName .. " [id]", thePlayer, 255, 194, 14)
  191. else
  192. local theVehicle = exports.pool:getElement("vehicle", tonumber(id))
  193. if theVehicle then
  194. local rx, ry, rz = getVehicleRotation(theVehicle)
  195. local x, y, z = getElementPosition(theVehicle)
  196. x = x + ( ( math.cos ( math.rad ( rz ) ) ) * 5 )
  197. y = y + ( ( math.sin ( math.rad ( rz ) ) ) * 5 )
  198.  
  199. setElementPosition(thePlayer, x, y, z)
  200. setPedRotation(thePlayer, rz)
  201. setElementInterior(thePlayer, getElementInterior(theVehicle))
  202. setElementDimension(thePlayer, getElementDimension(theVehicle))
  203.  
  204. outputChatBox("Teleported to vehicles location.", thePlayer, 255, 194, 14)
  205. else
  206. outputChatBox("Invalid Vehicle ID.", thePlayer, 255, 0, 0)
  207. end
  208. end
  209. end
  210. end
  211. addCommandHandler("gotocar", gotoCar, false, false)
  212.  
  213. -- /getcar
  214. function getCar(thePlayer, commandName, id)
  215. if (exports.global:isPlayerAdmin(thePlayer)) then
  216. if not (id) then
  217. outputChatBox("SYNTAX: /" .. commandName .. " [id]", thePlayer, 255, 194, 14)
  218. else
  219. local theVehicle = exports.pool:getElement("vehicle", tonumber(id))
  220. if theVehicle then
  221. local r = getPedRotation(thePlayer)
  222. local x, y, z = getElementPosition(thePlayer)
  223. x = x + ( ( math.cos ( math.rad ( r ) ) ) * 5 )
  224. y = y + ( ( math.sin ( math.rad ( r ) ) ) * 5 )
  225.  
  226. if (getElementHealth(theVehicle)==0) then
  227. spawnVehicle(theVehicle, x, y, z, 0, 0, r)
  228. else
  229. setElementPosition(theVehicle, x, y, z)
  230. setVehicleRotation(theVehicle, 0, 0, r)
  231. end
  232.  
  233. setElementInterior(theVehicle, getElementInterior(thePlayer))
  234. setElementDimension(theVehicle, getElementDimension(thePlayer))
  235.  
  236. outputChatBox("Vehicle teleported to your location.", thePlayer, 255, 194, 14)
  237. else
  238. outputChatBox("Invalid Vehicle ID.", thePlayer, 255, 0, 0)
  239. end
  240. end
  241. end
  242. end
  243. addCommandHandler("getcar", getCar, false, false)
  244.  
  245. function getNearbyVehicles(thePlayer, commandName)
  246. if (exports.global:isPlayerAdmin(thePlayer)) then
  247. outputChatBox("Nearby Vehicles:", thePlayer, 255, 126, 0)
  248. local count = 0
  249.  
  250. for index, nearbyVehicle in ipairs( exports.global:getNearbyElements(thePlayer, "vehicle") ) do
  251. local thisvehid = getElementData(nearbyVehicle, "dbid")
  252. local vehicleID = getElementModel(nearbyVehicle)
  253. local vehicleName = getVehicleNameFromModel(vehicleID)
  254. local owner = getElementData(nearbyVehicle, "owner")
  255. local faction = getElementData(nearbyVehicle, "faction")
  256. count = count + 1
  257.  
  258. local ownerName = ""
  259.  
  260. if (faction>0) then
  261. local theTeam = exports.pool:getElement("team", faction)
  262. if theTeam then
  263. ownerName = getTeamName(theTeam)
  264. end
  265. elseif (owner==-1) then
  266. ownerName = "Admin"
  267. elseif (owner>0) then
  268. ownerName = exports['cache']:getCharacterName(owner)
  269. else
  270. ownerName = "Civilian"
  271. end
  272.  
  273. if (thisvehid) then
  274. outputChatBox(" " .. vehicleName .. " (" .. vehicleID ..") with ID: " .. thisvehid .. ". Owner: " .. ownerName, thePlayer, 255, 126, 0)
  275. elseif not (thisvehid) then
  276. outputChatBox(" " .. "*Temporary* " .. vehicleName .. " (" .. vehicleID ..") with ID: " .. thisvehid .. ". Owner: " .. ownerName, thePlayer, 255, 126, 0)
  277. end
  278. end
  279.  
  280. if (count==0) then
  281. outputChatBox(" None.", thePlayer, 255, 126, 0)
  282. end
  283. end
  284. end
  285. addCommandHandler("nearbyvehicles", getNearbyVehicles, false, false)
  286.  
  287. function respawnCmdVehicle(thePlayer, commandName, id)
  288. if (exports.global:isPlayerAdmin(thePlayer)) then
  289. if not (id) then
  290. outputChatBox("SYNTAX: /respawnveh [id]", thePlayer, 255, 194, 14)
  291. else
  292. local theVehicle = exports.pool:getElement("vehicle", tonumber(id))
  293. if theVehicle then
  294. if isElementAttached(theVehicle) then
  295. detachElements(theVehicle)
  296. end
  297. exports['anticheat-system']:changeProtectedElementDataEx(theVehicle, 'i:left')
  298. exports['anticheat-system']:changeProtectedElementDataEx(theVehicle, 'i:right')
  299. local dbid = getElementData(theVehicle,"dbid")
  300. if (dbid<0) then -- TEMP vehicle
  301. fixVehicle(theVehicle) -- Can't really respawn this, so just repair it
  302. if armoredCars[ getElementModel( theVehicle ) ] then
  303. setVehicleDamageProof(theVehicle, true)
  304. else
  305. setVehicleDamageProof(theVehicle, false)
  306. end
  307. setVehicleWheelStates(theVehicle, 0, 0, 0, 0)
  308. exports['anticheat-system']:changeProtectedElementDataEx(theVehicle, "enginebroke", 0, false)
  309. else
  310. respawnVehicle(theVehicle)
  311. if getElementData(theVehicle, "owner") == -2 and getElementData(theVehicle,"Impounded") == 0 then
  312. setVehicleLocked(theVehicle, false)
  313. end
  314. end
  315. outputChatBox("Vehicle respawned.", thePlayer, 255, 194, 14)
  316. else
  317. outputChatBox("Invalid Vehicle ID.", thePlayer, 255, 0, 0)
  318. end
  319. end
  320. end
  321. end
  322. addCommandHandler("respawnveh", respawnCmdVehicle, false, false)
  323.  
  324. function round(num, idp)
  325. local mult = 10^(idp or 0)
  326. return math.floor(num * mult + 0.5) / mult
  327. end
  328.  
  329. function respawnAllVehicles(thePlayer, commandName, timeToRespawn)
  330. if (exports.global:isPlayerAdmin(thePlayer)) then
  331. if commandName then
  332. if isTimer(respawnTimer) then
  333. outputChatBox("There is already a Vehicle Respawn active, /respawnstop to stop it first.", thePlayer, 255, 0, 0)
  334. else
  335. timeToRespawn = tonumber(timeToRespawn) or 30
  336. timeToRespawn = timeToRespawn < 10 and 10 or timeToRespawn
  337. for k, arrayPlayer in ipairs(exports.global:getAdmins()) do
  338. local logged = getElementData(arrayPlayer, "loggedin")
  339. if (logged) then
  340. if exports.global:isPlayerLeadAdmin(arrayPlayer) then
  341. outputChatBox( "LeadAdmWarn: " .. getPlayerName(thePlayer) .. " executed a vehicle respawn.", arrayPlayer, 255, 194, 14)
  342. end
  343. end
  344. end
  345.  
  346. outputChatBox("*** All vehicles will be respawned in "..timeToRespawn.." seconds! ***", getRootElement(), 255, 194, 14)
  347. outputChatBox("You can stop it by typing /respawnstop!", thePlayer)
  348. respawnTimer = setTimer(respawnAllVehicles, timeToRespawn*1000, 1, thePlayer)
  349. end
  350. return
  351. end
  352. local tick = getTickCount()
  353. local vehicles = exports.pool:getPoolElementsByType("vehicle")
  354. local counter = 0
  355. local tempcounter = 0
  356. local tempoccupied = 0
  357. local occupiedcounter = 0
  358. local unlockedcivs = 0
  359. local notmoved = 0
  360.  
  361. local dimensions = { }
  362. for k, p in ipairs(getElementsByType("player")) do
  363. dimensions[ getElementDimension( p ) ] = true
  364. end
  365.  
  366. for k, theVehicle in ipairs(vehicles) do
  367. if isElement( theVehicle ) then
  368. local dbid = getElementData(theVehicle, "dbid")
  369. if not (dbid) or (dbid<0) then -- TEMP vehicle
  370. local driver = getVehicleOccupant(theVehicle)
  371. local pass1 = getVehicleOccupant(theVehicle, 1)
  372. local pass2 = getVehicleOccupant(theVehicle, 2)
  373. local pass3 = getVehicleOccupant(theVehicle, 3)
  374.  
  375. if (dbid and dimensions[dbid + 20000]) or (pass1) or (pass2) or (pass3) or (driver) or (getVehicleTowingVehicle(theVehicle)) or #getAttachedElements(theVehicle) > 0 then
  376. tempoccupied = tempoccupied + 1
  377. else
  378. destroyElement(theVehicle)
  379. tempcounter = tempcounter + 1
  380. end
  381. else
  382. local driver = getVehicleOccupant(theVehicle)
  383. local pass1 = getVehicleOccupant(theVehicle, 1)
  384. local pass2 = getVehicleOccupant(theVehicle, 2)
  385. local pass3 = getVehicleOccupant(theVehicle, 3)
  386.  
  387. if (dimensions[dbid + 20000]) or (pass1) or (pass2) or (pass3) or (driver) or (getVehicleTowingVehicle(theVehicle)) or #getAttachedElements(theVehicle) > 0 then
  388. occupiedcounter = occupiedcounter + 1
  389. else
  390. if isVehicleBlown(theVehicle) or isElementInWater(theVehicle) then
  391. fixVehicle(theVehicle)
  392. if armoredCars[ getElementModel( theVehicle ) ] then
  393. setVehicleDamageProof(theVehicle, true)
  394. else
  395. setVehicleDamageProof(theVehicle, false)
  396. end
  397. for i = 0, 5 do
  398. setVehicleDoorState(theVehicle, i, 4) -- all kind of stuff missing
  399. end
  400. setElementHealth(theVehicle, 300) -- lowest possible health
  401. end
  402.  
  403. exports['anticheat-system']:changeProtectedElementDataEx(theVehicle, 'i:left')
  404. exports['anticheat-system']:changeProtectedElementDataEx(theVehicle, 'i:right')
  405. if getElementData(theVehicle, "owner") == -2 and getElementData(theVehicle,"Impounded") == 0 then
  406. if isElementAttached(theVehicle) then
  407. detachElements(theVehicle)
  408. end
  409. respawnVehicle(theVehicle)
  410. setVehicleLocked(theVehicle, false)
  411. unlockedcivs = unlockedcivs + 1
  412. else
  413. local checkx, checky, checkz = getElementPosition( theVehicle )
  414. local x, y, z, rx, ry, rz = unpack(getElementData(theVehicle, "respawnposition"))
  415.  
  416. if (round(checkx, 6) == x) and (round(checky, 6) == y) then
  417. notmoved = notmoved + 1
  418. else
  419. if isElementAttached(theVehicle) then
  420. detachElements(theVehicle)
  421. end
  422. setElementPosition(theVehicle, x, y, z)
  423. setVehicleRotation(theVehicle, rx, ry, rz)
  424. setElementInterior(theVehicle, getElementData(theVehicle, "interior"))
  425. setElementDimension(theVehicle, getElementData(theVehicle, "dimension"))
  426. counter = counter + 1
  427. end
  428. end
  429.  
  430. -- fix faction vehicles
  431. if getElementData(theVehicle, "faction") ~= -1 then
  432. fixVehicle(theVehicle)
  433. if (getElementData(theVehicle, "Impounded") == 0) then
  434. exports['anticheat-system']:changeProtectedElementDataEx(theVehicle, "enginebroke", 0, false)
  435. if armoredCars[ getElementModel( theVehicle ) ] then
  436. setVehicleDamageProof(theVehicle, true)
  437. else
  438. setVehicleDamageProof(theVehicle, false)
  439. end
  440. end
  441. end
  442. end
  443. end
  444. end
  445. end
  446. local timeTaken = (getTickCount() - tick)/1000
  447. outputChatBox(" =-=-=-=-=-=- All Vehicles Respawned =-=-=-=-=-=-=")
  448. outputChatBox("Respawned " .. counter .. "/" .. counter + notmoved .. " vehicles. (" .. occupiedcounter .. " Occupied) .", thePlayer)
  449. outputChatBox("Deleted " .. tempcounter .. " temporary vehicles. (" .. tempoccupied .. " Occupied).", thePlayer)
  450. outputChatBox("Unlocked and Respawned " .. unlockedcivs .. " civilian vehicles.", thePlayer)
  451. outputChatBox("All that in " .. timeTaken .." seconds.", thePlayer)
  452. end
  453. end
  454. addCommandHandler("respawnall", respawnAllVehicles, false, false)
  455.  
  456. function respawnVehiclesStop(thePlayer, commandName)
  457. if exports.global:isPlayerAdmin(thePlayer) and isTimer(respawnTimer) then
  458. killTimer(respawnTimer)
  459. respawnTimer = nil
  460. if commandName then
  461. local name = getPlayerName(thePlayer):gsub("_", " ")
  462. if getElementData(thePlayer, "hiddenadmin") == 1 then
  463. name = "Hidden Admin"
  464. end
  465. outputChatBox( "*** " .. name .. " cancelled the vehicle respawn ***", getRootElement(), 255, 194, 14)
  466. end
  467. end
  468. end
  469. addCommandHandler("respawnstop", respawnVehiclesStop, false, false)
  470.  
  471. function respawnAllCivVehicles(thePlayer, commandName)
  472. if (exports.global:isPlayerAdmin(thePlayer)) then
  473. local vehicles = exports.pool:getPoolElementsByType("vehicle")
  474. local counter = 0
  475.  
  476. for k, theVehicle in ipairs(vehicles) do
  477. local dbid = getElementData(theVehicle, "dbid")
  478. if dbid and dbid > 0 then
  479. local driver = getVehicleOccupant(theVehicle)
  480. local pass1 = getVehicleOccupant(theVehicle, 1)
  481. local pass2 = getVehicleOccupant(theVehicle, 2)
  482. local pass3 = getVehicleOccupant(theVehicle, 3)
  483.  
  484. if not pass1 and not pass2 and not pass3 and not driver and not getVehicleTowingVehicle(theVehicle) and #getAttachedElements(theVehicle) == 0 then
  485. -- civ vehicles
  486. if getElementData(theVehicle, "owner") == -2 then
  487. if isElementAttached(theVehicle) then
  488. detachElements(theVehicle)
  489. end
  490. exports['anticheat-system']:changeProtectedElementDataEx(theVehicle, 'i:left')
  491. exports['anticheat-system']:changeProtectedElementDataEx(theVehicle, 'i:right')
  492. respawnVehicle(theVehicle)
  493. setVehicleLocked(theVehicle, false)
  494. counter = counter + 1
  495. end
  496. end
  497. end
  498. end
  499. outputChatBox(" =-=-=-=-=-=- All Civilian Vehicles Respawned =-=-=-=-=-=-=")
  500. outputChatBox("Respawned " .. counter .. " civilian vehicles.", thePlayer)
  501. end
  502. end
  503. addCommandHandler("respawnciv", respawnAllCivVehicles, false, false)
  504.  
  505. function respawnAllInteriorVehicles(thePlayer, commandName, repair)
  506. local repair = tonumber( repair ) == 1 and exports.global:isPlayerAdmin( thePlayer )
  507. local dimension = getElementDimension(thePlayer)
  508. if dimension > 0 and ( exports.global:hasItem(thePlayer, 4, dimension) or exports.global:hasItem(thePlayer, 5, dimension) ) then
  509. local vehicles = exports.pool:getPoolElementsByType("vehicle")
  510. local counter = 0
  511.  
  512. for k, theVehicle in ipairs(vehicles) do
  513. if getElementData(theVehicle, "dimension") == dimension then
  514. local dbid = getElementData(theVehicle, "dbid")
  515. if dbid and dbid > 0 then
  516. local driver = getVehicleOccupant(theVehicle)
  517. local pass1 = getVehicleOccupant(theVehicle, 1)
  518. local pass2 = getVehicleOccupant(theVehicle, 2)
  519. local pass3 = getVehicleOccupant(theVehicle, 3)
  520.  
  521. if not pass1 and not pass2 and not pass3 and not driver and not getVehicleTowingVehicle(theVehicle) and #getAttachedElements(theVehicle) == 0 then
  522. local checkx, checky, checkz = getElementPosition( theVehicle )
  523. local x, y, z, rx, ry, rz = unpack(getElementData(theVehicle, "respawnposition"))
  524.  
  525. if (round(checkx, 6) ~= x) or (round(checky, 6) ~= y) then
  526. if isElementAttached(theVehicle) then
  527. detachElements(theVehicle)
  528. end
  529. if repair then
  530. respawnVehicle(theVehicle)
  531. else
  532. setElementPosition(theVehicle, x, y, z)
  533. setVehicleRotation(theVehicle, rx, ry, rz)
  534. setElementInterior(theVehicle, getElementData(theVehicle, "interior"))
  535. setElementDimension(theVehicle, dimension)
  536. end
  537. counter = counter + 1
  538. end
  539. end
  540. end
  541. end
  542. end
  543. outputChatBox("Respawned " .. counter .. " district vehicles.", thePlayer)
  544. else
  545. outputChatBox( "Ain't your place, is it?", thePlayer, 255, 0, 0 )
  546. end
  547. end
  548. addCommandHandler("respawnint", respawnAllInteriorVehicles, false, false)
  549.  
  550. function addUpgrade(thePlayer, commandName, target, upgradeID)
  551. if (exports.global:isPlayerSuperAdmin(thePlayer)) then
  552. if not (target) or not (upgradeID) then
  553. outputChatBox("SYNTAX: /" .. commandName .. " [Partial Player Nick] [Upgrade ID]", thePlayer, 255, 194, 14)
  554. else
  555. local username = getPlayerName(thePlayer)
  556. local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, target)
  557.  
  558. if targetPlayer then
  559. if not (isPedInVehicle(targetPlayer)) then
  560. outputChatBox("That player is not in a vehicle.", thePlayer, 255, 0, 0)
  561. else
  562. local theVehicle = getPedOccupiedVehicle(targetPlayer)
  563. local success = addVehicleUpgrade(theVehicle, upgradeID)
  564.  
  565. if (success) then
  566. exports.logs:logMessage("[/ADDUPGRADE] " .. getElementData(thePlayer, "gameaccountusername") .. "/".. getPlayerName(thePlayer) .." added upgrade ".. upgradeID .. "(" .. getVehicleUpgradeSlotName(upgradeID) .. ") to car " .. getElementData(theVehicle, "dbid"), 4)
  567. outputChatBox(getVehicleUpgradeSlotName(upgradeID) .. " upgrade added to " .. targetPlayerName .. "'s vehicle.", thePlayer)
  568. outputChatBox("Admin " .. username .. " added upgrade " .. getVehicleUpgradeSlotName(upgradeID) .. " to your vehicle.", targetPlayer)
  569. exports['savevehicle-system']:saveVehicleMods(theVehicle)
  570. else
  571. outputChatBox("Invalid Upgrade ID, or this vehicle doesn't support this upgrade.", thePlayer, 255, 0, 0)
  572. end
  573. end
  574. end
  575. end
  576. end
  577. end
  578. addCommandHandler("addupgrade", addUpgrade, false, false)
  579.  
  580. function addPaintjob(thePlayer, commandName, target, paintjobID)
  581. if (exports.global:isPlayerSuperAdmin(thePlayer)) then
  582. if not (target) or not (paintjobID) then
  583. outputChatBox("SYNTAX: /" .. commandName .. " [Partial Player Nick] [Paintjob ID]", thePlayer, 255, 194, 14)
  584. else
  585. local username = getPlayerName(thePlayer)
  586. local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, target)
  587.  
  588. if targetPlayer then
  589. if not (isPedInVehicle(targetPlayer)) then
  590. outputChatBox("That player is not in a vehicle.", thePlayer, 255, 0, 0)
  591. else
  592. local theVehicle = getPedOccupiedVehicle(targetPlayer)
  593. paintjobID = tonumber(paintjobID)
  594. if paintjobID == getVehiclePaintjob(theVehicle) then
  595. outputChatBox("This Vehicle already has this paintjob.", thePlayer, 255, 0, 0)
  596. else
  597. local success = setVehiclePaintjob(theVehicle, paintjobID)
  598.  
  599. if (success) then
  600. exports.logs:logMessage("[/PAINTJOB] " .. getElementData(thePlayer, "gameaccountusername") .. "/".. getPlayerName(thePlayer) .." added paintjob ".. paintjobID .. " to car " .. getElementData(theVehicle, "dbid"), 4)
  601. outputChatBox("Paintjob #" .. paintjobID .. " added to " .. targetPlayerName .. "'s vehicle.", thePlayer)
  602. outputChatBox("Admin " .. username .. " added Paintjob #" .. paintjobID .. " to your vehicle.", targetPlayer)
  603. exports['savevehicle-system']:saveVehicleMods(theVehicle)
  604. else
  605. outputChatBox("Invalid Paintjob ID, or this vehicle doesn't support this paintjob.", thePlayer, 255, 0, 0)
  606. end
  607. end
  608. end
  609. end
  610. end
  611. end
  612.  
  613. end
  614. addCommandHandler("paintjob", addPaintjob, false, false)
  615.  
  616. function resetUpgrades(thePlayer, commandName, target)
  617. if (exports.global:isPlayerSuperAdmin(thePlayer)) then
  618. if not (target) then
  619. outputChatBox("SYNTAX: /" .. commandName .. " [Partial Player Nick]", thePlayer, 255, 194, 14)
  620. else
  621. local username = getPlayerName(thePlayer)
  622. local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, target)
  623.  
  624. if targetPlayer then
  625. if not (isPedInVehicle(targetPlayer)) then
  626. outputChatBox("That player is not in a vehicle.", thePlayer, 255, 0, 0)
  627. else
  628. local theVehicle = getPedOccupiedVehicle(targetPlayer)
  629. exports.logs:logMessage("[/RESETUPGRADES] " .. getElementData(thePlayer, "gameaccountusername") .. "/".. getPlayerName(thePlayer) .." reset car " .. getElementData(theVehicle, "dbid") .. "'s upgrades", 4)
  630. for key, value in ipairs(getVehicleUpgrades(theVehicle)) do
  631. removeVehicleUpgrade(theVehicle, value)
  632. end
  633. setVehiclePaintjob(theVehicle, 3)
  634. outputChatBox("Removed all upgrades from " .. targetPlayerName .. "'s vehicles.", thePlayer, 0, 255, 0)
  635. exports['savevehicle-system']:saveVehicleMods(theVehicle)
  636. end
  637. end
  638. end
  639. end
  640. end
  641. addCommandHandler("resetupgrades", resetUpgrades, false, false)
  642.  
  643. function findVehID(thePlayer, commandName, ...)
  644. if (exports.global:isPlayerAdmin(thePlayer)) then
  645. if not (...) then
  646. outputChatBox("SYNTAX: /" .. commandName .. " [Partial Name]", thePlayer, 255, 194, 14)
  647. else
  648. local vehicleName = table.concat({...}, " ")
  649. local carID = getVehicleModelFromName(vehicleName)
  650.  
  651. if (carID) then
  652. local fullName = getVehicleNameFromModel(carID)
  653. outputChatBox(fullName .. ": ID " .. carID .. ".", thePlayer)
  654. else
  655. outputChatBox("Vehicle not found.", thePlayer, 255, 0 , 0)
  656. end
  657. end
  658. end
  659. end
  660. addCommandHandler("findvehid", findVehID, false, false)
  661.  
  662. -----------------------------[FIX VEH]---------------------------------
  663. function fixPlayerVehicle(thePlayer, commandName, target)
  664. if (exports.global:isPlayerAdmin(thePlayer)) then
  665. if not (target) then
  666. outputChatBox("SYNTAX: /" .. commandName .. " [Partial Player Nick]", thePlayer, 255, 194, 14)
  667. else
  668. local username = getPlayerName(thePlayer)
  669. local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, target)
  670.  
  671. if targetPlayer then
  672. local logged = getElementData(targetPlayer, "loggedin")
  673. if (logged==0) then
  674. outputChatBox("Player is not logged in.", thePlayer, 255, 0, 0)
  675. else
  676. local veh = getPedOccupiedVehicle(targetPlayer)
  677. if (veh) then
  678. fixVehicle(veh)
  679. if (getElementData(veh, "Impounded") == 0) then
  680. exports['anticheat-system']:changeProtectedElementDataEx(veh, "enginebroke", 0, false)
  681. if armoredCars[ getElementModel( veh ) ] then
  682. setVehicleDamageProof(veh, true)
  683. else
  684. setVehicleDamageProof(veh, false)
  685. end
  686. end
  687. outputChatBox("You repaired " .. targetPlayerName .. "'s vehicle.", thePlayer)
  688. outputChatBox("Your vehicle was repaired by admin " .. username .. ".", targetPlayer)
  689. else
  690. outputChatBox("That player is not in a vehicle.", thePlayer, 255, 0, 0)
  691. end
  692. end
  693. end
  694. end
  695. end
  696. end
  697. addCommandHandler("fixveh", fixPlayerVehicle, false, false)
  698.  
  699. -----------------------------[FIX VEH VIS]---------------------------------
  700. function fixPlayerVehicleVisual(thePlayer, commandName, target)
  701. if (exports.global:isPlayerAdmin(thePlayer)) then
  702. if not (target) then
  703. outputChatBox("SYNTAX: /" .. commandName .. " [Partial Player Nick]", thePlayer, 255, 194, 14)
  704. else
  705. local username = getPlayerName(thePlayer)
  706. local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, target)
  707.  
  708. if targetPlayer then
  709. local logged = getElementData(targetPlayer, "loggedin")
  710. if (logged==0) then
  711. outputChatBox("Player is not logged in.", thePlayer, 255, 0, 0)
  712. else
  713. local veh = getPedOccupiedVehicle(targetPlayer)
  714. if (veh) then
  715. local health = getElementHealth(veh)
  716. fixVehicle(veh)
  717. setElementHealth(veh, health)
  718. outputChatBox("You repaired " .. targetPlayerName .. "'s vehicle visually.", thePlayer)
  719. outputChatBox("Your vehicle was visually repaired by admin " .. username .. ".", targetPlayer)
  720. else
  721. outputChatBox("That player is not in a vehicle.", thePlayer, 255, 0, 0)
  722. end
  723. end
  724. end
  725. end
  726. end
  727. end
  728. addCommandHandler("fixvehvis", fixPlayerVehicleVisual, false, false)
  729.  
  730. -----------------------------[BLOW CAR]---------------------------------
  731. function blowPlayerVehicle(thePlayer, commandName, target)
  732. if (exports.global:isPlayerAdmin(thePlayer)) then
  733. if not (target) then
  734. outputChatBox("SYNTAX: /" .. commandName .. " [Partial Player Nick]", thePlayer, 255, 194, 14)
  735. else
  736. local username = getPlayerName(thePlayer)
  737. local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, target)
  738.  
  739. if targetPlayer then
  740. local logged = getElementData(targetPlayer, "loggedin")
  741. if (logged==0) then
  742. outputChatBox("Player is not logged in.", thePlayer, 255, 0, 0)
  743. else
  744. local veh = getPedOccupiedVehicle(targetPlayer)
  745. if (veh) then
  746. blowVehicle(veh)
  747. outputChatBox("You blew up " .. targetPlayerName .. "'s vehicle.", thePlayer)
  748. exports.logs:logMessage("[/BLOWVEH] " .. getElementData(thePlayer, "gameaccountusername") .. "/".. getPlayerName(thePlayer) .." blew ".. targetPlayerName , 4)
  749.  
  750. else
  751. outputChatBox("That player is not in a vehicle.", thePlayer, 255, 0, 0)
  752. end
  753. end
  754. end
  755. end
  756. end
  757. end
  758. addCommandHandler("blowveh", blowPlayerVehicle, false, false)
  759.  
  760. -----------------------------[SET CAR HP]---------------------------------
  761. function setCarHP(thePlayer, commandName, target, hp)
  762. if (exports.global:isPlayerAdmin(thePlayer)) then
  763. if not (target) or not (hp) then
  764. outputChatBox("SYNTAX: /" .. commandName .. " [Partial Player Nick] [Health]", thePlayer, 255, 194, 14)
  765. else
  766. local username = getPlayerName(thePlayer)
  767. local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, target)
  768.  
  769. if targetPlayer then
  770. local logged = getElementData(targetPlayer, "loggedin")
  771. if (logged==0) then
  772. outputChatBox("Player is not logged in.", thePlayer, 255, 0, 0)
  773. else
  774. local veh = getPedOccupiedVehicle(targetPlayer)
  775. if (veh) then
  776. local sethp = setElementHealth(veh, tonumber(hp))
  777.  
  778. if (sethp) then
  779. outputChatBox("You set " .. targetPlayerName .. "'s vehicle health to " .. hp .. ".", thePlayer)
  780. exports.logs:logMessage("[/SETCARHP] " .. getElementData(thePlayer, "gameaccountusername") .. "/".. getPlayerName(thePlayer) .." set ".. targetPlayerName .. "his car to hp: " .. hp , 4)
  781.  
  782. else
  783. outputChatBox("Invalid health value.", thePlayer, 255, 0, 0)
  784. end
  785. else
  786. outputChatBox("That player is not in a vehicle.", thePlayer, 255, 0, 0)
  787. end
  788. end
  789. end
  790. end
  791. end
  792. end
  793. addCommandHandler("setcarhp", setCarHP, false, false)
  794.  
  795. function fixAllVehicles(thePlayer, commandName)
  796. if (exports.global:isPlayerAdmin(thePlayer)) then
  797. local username = getPlayerName(thePlayer)
  798. for key, value in ipairs(exports.pool:getPoolElementsByType("vehicle")) do
  799. fixVehicle(value)
  800. if (not getElementData(value, "Impounded")) then
  801. exports['anticheat-system']:changeProtectedElementDataEx(value, "enginebroke", 0, false)
  802. if armoredCars[ getElementModel( value ) ] then
  803. setVehicleDamageProof(value, true)
  804. else
  805. setVehicleDamageProof(value, false)
  806. end
  807. end
  808. end
  809. outputChatBox("All vehicles repaired by Admin " .. username .. ".")
  810. end
  811. end
  812. addCommandHandler("fixvehs", fixAllVehicles)
  813.  
  814. -----------------------------[FUEL VEH]---------------------------------
  815. function fuelPlayerVehicle(thePlayer, commandName, target)
  816. if (exports.global:isPlayerAdmin(thePlayer)) then
  817. if not (target) then
  818. outputChatBox("SYNTAX: /" .. commandName .. " [Partial Player Nick]", thePlayer, 255, 194, 14)
  819. else
  820. local username = getPlayerName(thePlayer)
  821. local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, target)
  822.  
  823. if targetPlayer then
  824. local logged = getElementData(targetPlayer, "loggedin")
  825. if (logged==0) then
  826. outputChatBox("Player is not logged in.", thePlayer, 255, 0, 0)
  827. else
  828. local veh = getPedOccupiedVehicle(targetPlayer)
  829. if (veh) then
  830. exports['anticheat-system']:changeProtectedElementDataEx(veh, "fuel", 100, false)
  831. triggerClientEvent(targetPlayer, "syncFuel", veh)
  832. outputChatBox("You refueled " .. targetPlayerName .. "'s vehicle.", thePlayer)
  833. outputChatBox("Your vehicle was refueled by admin " .. username .. ".", targetPlayer)
  834. else
  835. outputChatBox("That player is not in a vehicle.", thePlayer, 255, 0, 0)
  836. end
  837. end
  838. end
  839. end
  840. end
  841. end
  842. addCommandHandler("fuelveh", fuelPlayerVehicle, false, false)
  843.  
  844. function fuelAllVehicles(thePlayer, commandName)
  845. if (exports.global:isPlayerAdmin(thePlayer)) then
  846. local username = getPlayerName(thePlayer)
  847. for key, value in ipairs(exports.pool:getPoolElementsByType("vehicle")) do
  848. exports['anticheat-system']:changeProtectedElementDataEx(value, "fuel", 100, false)
  849. end
  850. outputChatBox("All vehicles refuelled by Admin " .. username .. ".")
  851. end
  852. end
  853. addCommandHandler("fuelvehs", fuelAllVehicles, false, false)
  854.  
  855. -----------------------------[SET COLOR]---------------------------------
  856. function setPlayerVehicleColor(thePlayer, commandName, target, col1, col2)
  857. if (exports.global:isPlayerAdmin(thePlayer)) then
  858. if not (target) or not (col1) or not (col2) then
  859. outputChatBox("SYNTAX: /" .. commandName .. " [Partial Player Nick] [Color 1] [Color 2]", thePlayer, 255, 194, 14)
  860. else
  861. local username = getPlayerName(thePlayer)
  862. local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, target)
  863.  
  864. if targetPlayer then
  865. local logged = getElementData(targetPlayer, "loggedin")
  866. if (logged==0) then
  867. outputChatBox("Player is not logged in.", thePlayer, 255, 0, 0)
  868. else
  869. local veh = getPedOccupiedVehicle(targetPlayer)
  870. if (veh) then
  871. local color = setVehicleColor(veh, col1, col2, col1, col2)
  872.  
  873. if (color) then
  874. outputChatBox("Vehicle's color was set.", thePlayer)
  875. exports.logs:logMessage("[/setcolor] " .. getPlayerName(thePlayer) .." changed vehicle " .. getElementData(veh, "dbid") .. " their colors to " .. col1 .. "-" .. col2, 29)
  876. exports['savevehicle-system']:saveVehicleMods(veh)
  877. else
  878. outputChatBox("Invalid Color ID.", thePlayer, 255, 194, 14)
  879. end
  880. else
  881. outputChatBox("That player is not in a vehicle.", thePlayer, 255, 0, 0)
  882. end
  883. end
  884. end
  885. end
  886. end
  887. end
  888. addCommandHandler("setcolor", setPlayerVehicleColor, false, false)
  889. -----------------------------[GET COLOR]---------------------------------
  890. function getAVehicleColor(thePlayer, commandName, carid)
  891. if (exports.global:isPlayerAdmin(thePlayer)) then
  892. if not (carid) then
  893. outputChatBox("SYNTAX: /" .. commandName .. " [Car ID]", thePlayer, 255, 194, 14)
  894. else
  895. local acar = nil
  896. for i,c in ipairs(getElementsByType("vehicle")) do
  897. if (getElementData(c, "dbid") == tonumber(carid)) then
  898. acar = c
  899. end
  900. end
  901. if acar then
  902. local c1, c2 = getVehicleColor(acar)
  903. outputChatBox("Vehicle's colors are " .. tonumber(c1) .. " and " .. tonumber(c2) .. ".", thePlayer)
  904. else
  905. outputChatBox("Invalid Car ID.", thePlayer, 255, 194, 14)
  906. end
  907. end
  908. end
  909. end
  910. addCommandHandler("getcolor", getAVehicleColor, false, false)
  911.  
  912. function deleteVehicle(thePlayer, commandName, id)
  913. if (exports.global:isPlayerAdmin(thePlayer)) then
  914. local dbid = tonumber(id)
  915. if not (dbid) then
  916. outputChatBox("SYNTAX: /" .. commandName .. " [id]", thePlayer, 255, 194, 14)
  917. else
  918. local theVehicle = exports.pool:getElement("vehicle", dbid)
  919. if theVehicle then
  920. triggerEvent("onVehicleDelete", theVehicle)
  921. if (dbid<0) then -- TEMP vehicle
  922. destroyElement(theVehicle)
  923. else
  924. if (exports.global:isPlayerSuperAdmin(thePlayer)) then
  925. mysql:query_free("DELETE FROM vehicles WHERE id='" .. mysql:escape_string(dbid) .. "'")
  926. call( getResourceFromName( "item-system" ), "deleteAll", 3, dbid )
  927. call( getResourceFromName( "item-system" ), "clearItems", theVehicle )
  928. destroyElement(theVehicle)
  929. exports.logs:logMessage("[DELVEH] " .. getPlayerName( thePlayer ) .. " deleted vehicle #" .. dbid, 9)
  930. else
  931. outputChatBox("You do not have permission to delete permanent vehicles.", thePlayer, 255, 0, 0)
  932. return
  933. end
  934. end
  935. outputChatBox("Vehicle deleted.", thePlayer)
  936. else
  937. outputChatBox("No vehicles with that ID found.", thePlayer, 255, 0, 0)
  938. end
  939. end
  940. end
  941. end
  942. addCommandHandler("delveh", deleteVehicle, false, false)
  943.  
  944. -- DELTHISVEH
  945.  
  946. function deleteThisVehicle(thePlayer, commandName)
  947. local veh = getPedOccupiedVehicle(thePlayer)
  948. local dbid = getElementData(veh, "dbid")
  949. if (exports.global:isPlayerAdmin(thePlayer)) then
  950. if dbid < 0 or exports.global:isPlayerSuperAdmin(thePlayer) then
  951. if not (isPedInVehicle(thePlayer)) then
  952. outputChatBox("You are not in a vehicle.", thePlayer, 255, 0, 0)
  953. else
  954. if dbid > 0 then
  955. mysql:query_free("DELETE FROM vehicles WHERE id='" .. mysql:escape_string(dbid) .. "'")
  956. call( getResourceFromName( "item-system" ), "deleteAll", 3, dbid )
  957. call( getResourceFromName( "item-system" ), "clearItems", veh )
  958. exports.logs:logMessage("[DELVEH] " .. getPlayerName( thePlayer ) .. " deleted vehicle #" .. dbid, 9)
  959. end
  960. destroyElement(veh)
  961. end
  962. else
  963. outputChatBox("You do not have the permission to delete permanent vehicles.", thePlayer, 255, 0, 0)
  964. return
  965. end
  966. end
  967. end
  968. addCommandHandler("delthisveh", deleteThisVehicle, false, false)
  969.  
  970. function setVehTFFaction(thePlayer, commandName, pid, fid)
  971. if (exports.global:isPlayerSuperAdmin(thePlayer)) then
  972. if not (pid) or not (fid) then
  973. outputChatBox("SYNTAX: /" .. commandName .. " [player] [faction or -1]", thePlayer, 255, 194, 14)
  974. else
  975. local username = getPlayerName(thePlayer):gsub("_"," ")
  976. local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, pid)
  977. if (targetPlayer) then
  978. local pv = getPedOccupiedVehicle(targetPlayer)
  979. if (pv) then
  980. local faction = tonumber(fid)
  981. local tnplayer = tonumber(getElementData(targetPlayer, "dbid"))
  982. local ocarid = tonumber(getElementData(pv, "dbid"))
  983. local oowner = tonumber(getElementData(pv, "owner"))
  984. local ofaction = tonumber(getElementData(pv, "faction"))
  985. if (faction == -1) then
  986. exports['anticheat-system']:changeProtectedElementDataEx(pv, "faction", -1, false)
  987. exports['anticheat-system']:changeProtectedElementDataEx(pv, "owner", tnplayer, false)
  988. exports['savevehicle-system']:saveVehicle(pv)
  989.  
  990. outputChatBox("Car #" .. ocarid .. " was set from faction '" .. ofaction .. "' to owner '" .. targetPlayerName .. "'.", thePlayer, 0, 255, 0)
  991. outputChatBox("Admin " .. username .. " has set your vehicle's owner to you from faction: " .. ofaction .. ".", targetPlayer, 0, 255, 0)
  992. exports.logs:logMessage("[SET FACTION] Car #" .. ocarid .. " was set by " .. username .. " from faction '" .. ofaction .. "' to owner [Player: " .. targetPlayerName .. "(" .. tnplayer .. ")]." , 9)
  993. mysql:query_free("UPDATE vehicles SET owner= '" .. mysql:escape_string(tnplayer) .. "', faction='" .. mysql:escape_string(ofaction) .. "' WHERE id='" .. mysql:escape_string(ocarid) .. "'")
  994. elseif (exports.pool:getElement("team", faction)) then
  995. exports['anticheat-system']:changeProtectedElementDataEx(pv, "faction", faction, false)
  996. exports['anticheat-system']:changeProtectedElementDataEx(pv, "owner", -1, false)
  997. exports['savevehicle-system']:saveVehicle(pv)
  998.  
  999. outputChatBox("Car #" .. ocarid .. " was set to faction '" .. faction .. "' from '" .. ofaction .. "'.", thePlayer, 0, 255, 0)
  1000. outputChatBox("Admin " .. username .. " has set your vehicle's owner from you to faction '" .. faction .. "'.", targetPlayer, 0, 255, 0)
  1001. exports.logs:logMessage("[SET FACTION] Car #" .. ocarid .. " was set by " .. username .. " to faction '" .. faction .. "' from [Player: " .. oowner .. " Faction: " .. ofaction .. "].", 9)
  1002. mysql:query_free("UPDATE vehicles SET owner= '" .. mysql:escape_string(tnplayer) .. "', faction='" .. mysql:escape_string(ofaction) .. "' WHERE id='" .. mysql:escape_string(ocarid) .. "'")
  1003. else
  1004. outputChatBox("Invalid Faction.", thePlayer, 255, 0, 0)
  1005. end
  1006. else
  1007. outputChatBox("Player not in a vehicle.", thePlayer, 255, 194, 14)
  1008. end
  1009. end
  1010. end
  1011. end
  1012. end
  1013. addCommandHandler("setvehfaction", setVehTFFaction)
  1014.  
  1015. --Adding/Removing tint
  1016. function setVehTint(admin, command, target, status)
  1017. if (exports.global:isPlayerSuperAdmin(admin)) then
  1018. if not (target) or not (status) then
  1019. outputChatBox("SYNTAX: /" .. command .. " [player] [0- Off, 1- On]", admin, 255, 194, 14)
  1020. else
  1021. local username = getPlayerName(admin):gsub("_"," ")
  1022. local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(admin, target)
  1023.  
  1024. if (targetPlayer) then
  1025. local pv = getPedOccupiedVehicle(targetPlayer)
  1026. if (pv) then
  1027. local vid = getElementData(pv, "dbid")
  1028. local stat = tonumber(status)
  1029. if (stat == 1) then
  1030. mysql:query_free("UPDATE vehicles SET tintedwindows = '1' WHERE id='" .. mysql:escape_string(vid) .. "'")
  1031. for i = 0, getVehicleMaxPassengers(pv) do
  1032. local player = getVehicleOccupant(pv, i)
  1033. if (player) then
  1034. triggerEvent("setTintName", pv, player)
  1035. end
  1036. end
  1037.  
  1038. exports['anticheat-system']:changeProtectedElementDataEx(pv, "tinted", true, true)
  1039.  
  1040. outputChatBox("You have added tint to vehicle #" .. vid .. ".", admin)
  1041. for k, arrayPlayer in ipairs(exports.global:getAdmins()) do
  1042. local logged = getElementData(arrayPlayer, "loggedin")
  1043. if (logged) then
  1044. if exports.global:isPlayerLeadAdmin(arrayPlayer) then
  1045. outputChatBox( "LeadAdmWarn: " .. getPlayerName(admin):gsub("_"," ") .. " added tint to vehicle #" .. vid .. ".", arrayPlayer, 255, 194, 14)
  1046. end
  1047. end
  1048. end
  1049.  
  1050. exports.logs:logMessage("[ADD TINT-ADMIN] " .. getPlayerName(admin):gsub("_"," ") .. " has added tint to vehicle #" .. vid .. " - " .. getVehicleName(pv) .. ".", 9)
  1051. elseif (stat == 0) then
  1052. mysql:query_free("UPDATE vehicles SET tintedwindows = '0' WHERE id='" .. mysql:escape_string(vid) .. "'")
  1053. for i = 0, getVehicleMaxPassengers(pv) do
  1054. local player = getVehicleOccupant(pv, i)
  1055. if (player) then
  1056. triggerEvent("resetTintName", pv, player)
  1057. end
  1058. end
  1059. exports['anticheat-system']:changeProtectedElementDataEx(pv, "tinted", false, true)
  1060.  
  1061. outputChatBox("You have removed tint from vehicle #" .. vid .. ".", admin)
  1062. for k, arrayPlayer in ipairs(exports.global:getAdmins()) do
  1063. local logged = getElementData(arrayPlayer, "loggedin")
  1064. if (logged) then
  1065. if exports.global:isPlayerLeadAdmin(arrayPlayer) then
  1066. outputChatBox( "LeadAdmWarn: " .. getPlayerName(admin):gsub("_"," ") .. " removed tint from vehicle #" .. vid .. ".", arrayPlayer, 255, 194, 14)
  1067. end
  1068. end
  1069. end
  1070.  
  1071. exports.logs:logMessage("[REMOVED TINT-ADMIN] " .. getPlayerName(admin):gsub("_"," ") .. " has removed tint from vehicle #" .. vid .. " - " .. getVehicleName(pv) .. ".", 9)
  1072. end
  1073. else
  1074. outputChatBox("Player not in a vehicle.", admin, 255, 194, 14)
  1075. end
  1076. end
  1077. end
  1078. end
  1079. end
  1080. addCommandHandler("setvehtint", setVehTint)
Add Comment
Please, Sign In to add comment