- Katılım
- 4 yıl 8 ay 24 gün
- Mesajlar
- 931
policejob client içine
server tarafına
Bildirimleri değiştirmeyi unutmayın
Kod:
RegisterNetEvent('hasan:ybindir')
AddEventHandler('hasan:ybindir', function()
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)
if IsAnyVehicleNearPoint(coords, 5.0) then
local vehicle = GetClosestVehicle(coords, 5.0, 0, 71)
if DoesEntityExist(vehicle) then
local maxSeats, freeSeat = GetVehicleMaxNumberOfPassengers(vehicle)
for i=maxSeats - 1, 0, -1 do
if IsVehicleSeatFree(vehicle, i) then
freeSeat = i
break
end
end
if freeSeat then
TaskWarpPedIntoVehicle(playerPed, vehicle, freeSeat)
DragStatus.IsDragged = false
end
end
end
end)
RegisterCommand("ybindir",function()
local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
if closestPlayer ~= -1 and closestDistance <= 2.0 then
ESX.TriggerServerCallback('policejob:isplayerdead', function(isPedDead)
if isPedDead then
TriggerServerEvent('hasan:yaralibindir', GetPlayerServerId(closestPlayer))
else
TriggerEvent("notification","Kişi yaralı değil",2)
end
end, GetPlayerServerId(closestPlayer))
else
TriggerEvent("notification","Yakında oyuncu yok",2)
end
end)
RegisterNetEvent('hasan:yaralıindir')
AddEventHandler('hasan:yaralıindir', function()
local playerPed = PlayerPedId()
if not IsPedSittingInAnyVehicle(playerPed) then
return
end
local vehicle = GetVehiclePedIsIn(playerPed, false)
TaskLeaveVehicle(playerPed, vehicle, 16)
end)
RegisterCommand("yindir",function()
local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
if closestPlayer ~= -1 and closestDistance <= 2.0 then
ESX.TriggerServerCallback('policejob:isplayerdead', function(isPedDead)
if isPedDead then
TriggerServerEvent('hasan:yaralindir', GetPlayerServerId(closestPlayer))
else
TriggerEvent("notification","Kişi yaralı değil",2)
end
end, GetPlayerServerId(closestPlayer))
else
TriggerEvent("notification","Yakında oyuncu yok",2)
end
end)
server tarafına
Kod:
RegisterServerEvent('hasan:yaralibindir')
AddEventHandler('hasan:yaralibindir', function(target)
TriggerClientEvent('hasan:ybindir', target)
end)
RegisterServerEvent('hasan:yaralindir')
AddEventHandler('hasan:yaralindir', function(target)
local xPlayer = ESX.GetPlayerFromId(source)
TriggerClientEvent('hasan:yaralıindir', target)
end)
ESX.RegisterServerCallback('policejob:isplayerdead', function(source, cb, target)
local player = ESX.GetPlayerFromId(target)
MySQL.Async.fetchAll('SELECT is_dead FROM users WHERE identifier = @identifier', {
['@identifier'] = player.identifier
}, function(result)
local isDead = result[1].is_dead
cb(isDead)
end)
end)