RyanUSNS

Untitled

Jan 12th, 2018
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.67 KB | None | 0 0
  1. function searchIllegalCargo()
  2.     local players = getElementsByType("player")
  3.     illegalSearch[localPlayer] = 0
  4.     local x, y, z = getElementPosition(localPlayer)
  5.     --Police output
  6.     if (lawTeam[getTeamName(getPlayerTeam(localPlayer))]) then
  7.         for crim, bool in pairs(crimInMission) do
  8.             if (bool) then
  9.                 local mX, mY, mZ = getElementPosition(crim)
  10.                 if (getDistanceBetweenPoints2D(x, y, mX, mY) <= 300) then
  11.                     illegalSearch[localPlayer] = illegalSearch[localPlayer] + 1
  12.                 end
  13.             end
  14.             if (illegalSearch[localPlayer] ~= 0) then
  15.                 exports.CIThelp:modTextBar("illegalSearch", "You are near of "..tostring(illegalSearch[localPlayer]).." crim Trucker", 0, 0, 200)
  16.             else
  17.                 exports.CIThelp:modTextBar("illegalSearch", "")
  18.             end
  19.         end
  20.     --Criminal output
  21.     elseif (crimTeam[getTeamName(getPlayerTeam(localPlayer))] and inTask) then
  22.         illegalSearch[localPlayer] = {}
  23.         for i, pol in pairs(players) do
  24.             if (lawTeam[getTeamName(getPlayerTeam(pol))]) then
  25.                 local mX, mY, mZ = getElementPosition(pol)
  26.                 local distance = getDistanceBetweenPoints2D(x, y, mX, mY)
  27.                 if (distance <= 400) then
  28.                     illegalSearch[localPlayer][#illegalSearch[localPlayer] + 1] = distance
  29.                 end
  30.             end
  31.         end
  32.         table.sort(illegalSearch[localPlayer], sortMyTable)
  33.         if (illegalSearch[localPlayer][1] ~= 0) then
  34.             exports.CIThelp:modTextBar("illegalSearch", "Run from police before they catch you! Distance: "..math.ceil(illegalSearch[localPlayer][1], 0).." m", 100, 0, 0)
  35.         else
  36.             exports.CIThelp:modTextBar("illegalSearch", "")
  37.         end
  38.     else
  39.         exports.CIThelp:modTextBar("illegalSearch", "")
  40.     end
  41. end
  42. setTimer(searchIllegalCargo, 100, 0)
  43.  
  44. function sortMyTable(a, b)
  45.     return a < b
  46. end
Advertisement
Add Comment
Please, Sign In to add comment