Advertisement
Guest User

hmmmm

a guest
Apr 21st, 2018
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.02 KB | None | 0 0
  1. Client
  2. AddEventHandler('bodybag', function()
  3.     local distanceToCheck = 5.0 -- Do i even need this?
  4.     local ped = GetPlayerPed(-1)
  5.     local t, distance = GetClosestPed()
  6.         if(distance ~= -1 and distance < 5) then
  7.         TriggerServerEvent("bodybag", GetPlayerServerId(t))
  8.     else
  9.          drawNotification("no ped close on you")
  10.     end
  11.  
  12. end)
  13.  
  14.  
  15.  
  16. Citizen.CreateThread(function() -- i'm Scuffed Right?
  17.     while true do
  18.         if DeletePed then -- is this Right? Feel like this is Wrong
  19.             local ped = GetPlayerPed(GetPlayerFromServerId(DeletePed(-1))
  20.             plyPos = GetEntityCoords(ped,  true)
  21.             SetEntityCoords(ped, plyPos.x, plyPos.y, plyPos.z)    
  22.         end
  23.         Citizen.Wait(1000)
  24.     end
  25. end)
  26.  
  27.  
  28. function GetClosestPed()
  29.     local ped = GetPlayerPed(player)()
  30.     local closestDistance = -1
  31.     local closestPed = -1
  32.     local ply = GetPlayerPed(-1)
  33.     local plyCoords = GetEntityCoords(ply, 0)
  34.    
  35.     for index,value in ipairs(players) do -- Players?? or? can i do Ped???
  36.     local target = GetPlayerPed(value)
  37.         if(target ~= ply) then
  38.     local targetCoords = GetEntityCoords(GetPlayerPed(value), 0)
  39.     local distance = Vdist(targetCoords["x"], targetCoords["y"], targetCoords["z"], plyCoords["x"], plyCoords["y"], plyCoords["z"])
  40.         if(closestDistance == -1 or closestDistance > distance) then
  41.                 closestPed = value
  42.                 closestDistance = distance
  43.             end
  44.         end
  45.     end
  46.    
  47.     return closestPed, closestDistance
  48. end
  49.  
  50. function DeletePed(entity)
  51.     Citizen.InvokeNative(0x9614299DCB53E54B, Citizen.PointerValueIntInitialized(entity))
  52. end
  53.  
  54. function drawNotification(text)
  55.     SetNotificationTextEntry("STRING")
  56.     AddTextComponentString(text)
  57.     DrawNotification(false, false)
  58. end
  59.  
  60.  
  61.  
  62. Server
  63.  
  64. AddEventHandler('chatMessage', function(source, name, msg)
  65.     sm = stringsplit(msg, " ");
  66.     if sm[1] == "/bodybagto" then
  67.     TriggerClientEvent("bodybag", source)
  68.     CancelEvent()
  69.     end
  70. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement