Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Client
- AddEventHandler('bodybag', function()
- local distanceToCheck = 5.0 -- Do i even need this?
- local ped = GetPlayerPed(-1)
- local t, distance = GetClosestPed()
- if(distance ~= -1 and distance < 5) then
- TriggerServerEvent("bodybag", GetPlayerServerId(t))
- else
- drawNotification("no ped close on you")
- end
- end)
- Citizen.CreateThread(function() -- i'm Scuffed Right?
- while true do
- if DeletePed then -- is this Right? Feel like this is Wrong
- local ped = GetPlayerPed(GetPlayerFromServerId(DeletePed(-1))
- plyPos = GetEntityCoords(ped, true)
- SetEntityCoords(ped, plyPos.x, plyPos.y, plyPos.z)
- end
- Citizen.Wait(1000)
- end
- end)
- function GetClosestPed()
- local ped = GetPlayerPed(player)()
- local closestDistance = -1
- local closestPed = -1
- local ply = GetPlayerPed(-1)
- local plyCoords = GetEntityCoords(ply, 0)
- for index,value in ipairs(players) do -- Players?? or? can i do Ped???
- local target = GetPlayerPed(value)
- if(target ~= ply) then
- local targetCoords = GetEntityCoords(GetPlayerPed(value), 0)
- local distance = Vdist(targetCoords["x"], targetCoords["y"], targetCoords["z"], plyCoords["x"], plyCoords["y"], plyCoords["z"])
- if(closestDistance == -1 or closestDistance > distance) then
- closestPed = value
- closestDistance = distance
- end
- end
- end
- return closestPed, closestDistance
- end
- function DeletePed(entity)
- Citizen.InvokeNative(0x9614299DCB53E54B, Citizen.PointerValueIntInitialized(entity))
- end
- function drawNotification(text)
- SetNotificationTextEntry("STRING")
- AddTextComponentString(text)
- DrawNotification(false, false)
- end
- Server
- AddEventHandler('chatMessage', function(source, name, msg)
- sm = stringsplit(msg, " ");
- if sm[1] == "/bodybagto" then
- TriggerClientEvent("bodybag", source)
- CancelEvent()
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement