Bvural41 1
Bvural41
-TuRKuaZ- 1
-TuRKuaZ-
farkmt2official 1
farkmt2official
Sevdamsın 1
Sevdamsın
mavzermete 1
mavzermete
xranzei 1
xranzei
Best Studio 1
Best Studio
Hikaye Ekle

FiveM Script - Meslek değişimsiz Polis GPS itemi ekleme

HERAKLES Otomatik Avlı kalıcı sunucu. 19 Haziran'da açılıyor. Atius & Wizard güvencesiyle hemen kayıt ol, ön kayıt ödülleri aktif. HEMEN TIKLA!

DEĞİŞİKLİK YAPMADAN ÖNCE ESX_POLICEJOB VE ESX_SOCIETY YEDEĞİNİZİ ALINIZ.

Kod:
RegisterNetEvent('esx_policejob:updateBlip')
AddEventHandler('esx_policejob:updateBlip', function()

    -- Refresh all blips
    for k, existingBlip in pairs(blipsCops) do
        RemoveBlip(existingBlip)
    end

    -- Clean the blip table
    blipsCops = {}

    -- Enable blip?
    if Config.MaxInService ~= -1 and not playerInService then
        return
    end

    if not Config.EnableJobBlip then
        return
    end

    -- Is the player a cop? In that case show all the blips for other cops
    if PlayerData.job and PlayerData.job.name == 'police' then
        ESX.TriggerServerCallback('esx_society:getOnlinePlayers', function(players)
            for i=1, #players, 1 do
                if players[i].job.name == 'police' then
                    local id = GetPlayerFromServerId(players[i].source)
                    if NetworkIsPlayerActive(id) and GetPlayerPed(id) ~= PlayerPedId() then
                        createBlip(id)
                    end
                end
            end
        end)
    end

end)

default policejob client dosyasındaki 1903. satırdaki update blip eventini alttaki kodlarla değiştiriyoruz (üstteki default hali)

Kod:
RegisterNetEvent('esx_policejob:updateBlip')
AddEventHandler('esx_policejob:updateBlip', function()

    -- Refresh all blips
    for k, existingBlip in pairs(blipsCops) do
        RemoveBlip(existingBlip)
    end

    -- Clean the blip table
    blipsCops = {}

    -- Enable blip?
    if Config.MaxInService ~= -1 and not playerInService then
        return
    end

    if not Config.EnableJobBlip then
        return
    end

    -- Is the player a cop? In that case show all the blips for other cops
    if PlayerData.job and PlayerData.job.name == 'police' then
        ESX.TriggerServerCallback('esx_society:getOnlinePlayers', function(players)
            for i=1, #players, 1 do
                if players[i].job.name == 'police' and players[i].gps > 0 then
                    local id = GetPlayerFromServerId(players[i].source)
                    if NetworkIsPlayerActive(id) and GetPlayerPed(id) ~= PlayerPedId() then
                        createBlip(id)
                    end
                end
                if players[i].job.name == 'ambulance' then
                    local id = GetPlayerFromServerId(players[i].source)
                    if NetworkIsPlayerActive(id) and GetPlayerPed(id) ~= PlayerPedId() then
                        createBlip2(id)
                    end
                end
            end
        end)
    end

end)

RegisterNetEvent('esx_policejob:removeBlip')
AddEventHandler('esx_policejob:removeBlip', function()

    -- Refresh all blips
    for k, existingBlip in pairs(blipsCops) do
        RemoveBlip(existingBlip)
    end

    -- Clean the blip table
    blipsCops = {}
end)

sonrasında policejob client dosyasının en altına bu kodları ekliyoruz

Kod:
Citizen.CreateThread(function()
    while true do
        Citizen.Wait(15000)
        if PlayerData.job and PlayerData.job.name == 'police' then
            ESX.TriggerServerCallback('esx_policejob:getItemAmount', function(qtty)
                if qtty > 0 then
                    TriggerEvent('esx_policejob:updateBlip')
                end
            end, 'gps')
        end
        if PlayerData.job and PlayerData.job.name == 'ambulance' then
            TriggerEvent('esx_policejob:updateBlip')
        end
    end
end)

sonrasında default policejob client dosyasında 1885. satırdan itibaren 1900. satır dahil silip yerine bu kodları yapıştırıyoruz

Kod:
-- Create blip for colleagues

function createBlip(id)

    local ped = GetPlayerPed(id)

    local blip = GetBlipFromEntity(ped)



    if not DoesBlipExist(blip) then -- Add blip and create head display on player

        blip = AddBlipForEntity(ped)

        SetBlipSprite(blip, 1)

        SetBlipColour(blip, 57)

        ShowHeadingIndicatorOnBlip(blip, true) -- Player Blip indicator

        SetBlipRotation(blip, math.ceil(GetEntityHeading(ped))) -- update rotation

        SetBlipScale(blip, 0.85) -- set scale

        SetBlipAsShortRange(blip, true)

        BeginTextCommandSetBlipName('STRING')

        AddTextComponentString('[~b~LSPD~s~]')

        EndTextCommandSetBlipName(blip)



        table.insert(blipsCops, blip) -- add blip to array so we can remove it later

    end

end

function createBlip2(id)

    local ped = GetPlayerPed(id)

    local blip = GetBlipFromEntity(ped)



    if not DoesBlipExist(blip) then

        blip = AddBlipForEntity(ped)

        SetBlipSprite(blip, 1)

        SetBlipColour(blip, 1)

        ShowHeadingIndicatorOnBlip(blip, true)

        SetBlipRotation(blip, math.ceil(GetEntityHeading(ped)))

        SetBlipScale(blip, 0.85)

        SetBlipAsShortRange(blip, true)

        BeginTextCommandSetBlipName('STRING')

        AddTextComponentString('[~r~EMS~s~]')

        EndTextCommandSetBlipName(blip)

  

        table.insert(blipsCops, blip)

    end

end

sonrasında default policejob server dosyasının en altına bu verdiğim kodları ekliyoruz

Kod:
ESX.RegisterServerCallback('esx_policejob:getItemAmount', function(source, cb, item)
        local xPlayer = ESX.GetPlayerFromId(source)
        local items = xPlayer.getInventoryItem(item)
        if items == nil then
            cb(0)
        else
            cb(items.count)
        end
end)

sonrasında default policejob server dosyasında 513. satırdan itibaren 543. satır aralığını bu verdiğim kod ile değiştiriyoruz

Kod:
AddEventHandler('playerDropped', function()
    -- Save the source in case we lose it (which happens a lot)
    local _source         = source
    local xPlayer         = ESX.GetPlayerFromId(_source)

    -- Did the player ever join?
    if _source ~= nil then
      

        -- Is it worth telling all clients to refresh?
        if xPlayer ~= nil and xPlayer.job ~= nil and xPlayer.job.name == 'police' then
            local currentGPS    = xPlayer.getInventoryItem('gps').count
            Citizen.Wait(5000)
            if currentGPS > 0 then
                TriggerClientEvent('esx_policejob:updateBlip', -1)
            end
        end
    end
end)

RegisterServerEvent('esx_policejob:spawned')
AddEventHandler('esx_policejob:spawned', function()
    local _source             = source
    local xPlayer             = ESX.GetPlayerFromId(_source)

    if xPlayer ~= nil and xPlayer.job ~= nil and xPlayer.job.name == 'police' then
        local currentGPS         = xPlayer.getInventoryItem('gps').count
        Citizen.Wait(5000)
        if currentGPS > 0 then
            TriggerClientEvent('esx_policejob:updateBlip', -1)
        end
    end
end)

RegisterServerEvent('esx_policejob:forceBlip')
AddEventHandler('esx_policejob:forceBlip', function()
    local _source = source
    local xPlayer = ESX.GetPlayerFromId(_source)
    local currentGPS     = xPlayer.getInventoryItem('gps').count

    if currentGPS > 0 then
        TriggerClientEvent('esx_policejob:updateBlip', -1)
    end
end)

eğer default bir policejob kullanmıyorsanız event isimlerine bakarak düzenleme yapınız
tekrardan policejob server dosyasının en altına bu kodları ekliyoruz

Kod:
AddEventHandler('esx:onAddInventoryItem', function(source, item, count)
    local _source = source
    local xPlayer = ESX.GetPlayerFromId(_source)
    if xPlayer ~= nil and xPlayer.job ~= nil and xPlayer.job.name == 'police' then
        if item.name == 'gps' and item.count > 0 then
            TriggerClientEvent('esx_policejob:updateBlip', source)
        end
    end
end)

AddEventHandler('esx:onRemoveInventoryItem', function(source, item, count)
    local _source = source
    local xPlayer = ESX.GetPlayerFromId(_source)
    if xPlayer ~= nil and xPlayer.job ~= nil and xPlayer.job.name == 'police' then
        if item.name == 'gps' and item.count < 1 then
            TriggerClientEvent('esx_policejob:removeBlip', source) -- bu event cliente sonradan ekleniyor
        end
    end
end)

son olarak esx_society scriptinin server dosyasında 313. satırından itibaren 328. satır dahil silip yerine bu kodları yapıştırıyoruz

Kod:
ESX.RegisterServerCallback('esx_society:getOnlinePlayers', function(source, cb)
    local xPlayers = ESX.GetPlayers()
    local players  = {}

    for i=1, #xPlayers, 1 do
        local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
        local currentGPS     = xPlayer.getInventoryItem('gps').count
        table.insert(players, {
            source     = xPlayer.source,
            identifier = xPlayer.identifier,
            name       = xPlayer.name,
            job        = xPlayer.job,
            gps        = currentGPS
        })
    end

    cb(players)
end)

eğer esx_policejob ve esx_society scriptlerinde düzenleme yaptıysanız event isimlerine dikkat ederek yapabilirsiniz default hallerindeki satır numaralarını vererek anlattım.

databasenize gps adında item oluşturmanız gerekiyor.
 
DEĞİŞİKLİK YAPMADAN ÖNCE ESX_POLICEJOB VE ESX_SOCIETY YEDEĞİNİZİ ALINIZ.

Kod:
RegisterNetEvent('esx_policejob:updateBlip')
AddEventHandler('esx_policejob:updateBlip', function()

    -- Refresh all blips
    for k, existingBlip in pairs(blipsCops) do
        RemoveBlip(existingBlip)
    end

    -- Clean the blip table
    blipsCops = {}

    -- Enable blip?
    if Config.MaxInService ~= -1 and not playerInService then
        return
    end

    if not Config.EnableJobBlip then
        return
    end

    -- Is the player a cop? In that case show all the blips for other cops
    if PlayerData.job and PlayerData.job.name == 'police' then
        ESX.TriggerServerCallback('esx_society:getOnlinePlayers', function(players)
            for i=1, #players, 1 do
                if players[i].job.name == 'police' then
                    local id = GetPlayerFromServerId(players[i].source)
                    if NetworkIsPlayerActive(id) and GetPlayerPed(id) ~= PlayerPedId() then
                        createBlip(id)
                    end
                end
            end
        end)
    end

end)

default policejob client dosyasındaki 1903. satırdaki update blip eventini alttaki kodlarla değiştiriyoruz (üstteki default hali)

Kod:
RegisterNetEvent('esx_policejob:updateBlip')
AddEventHandler('esx_policejob:updateBlip', function()

    -- Refresh all blips
    for k, existingBlip in pairs(blipsCops) do
        RemoveBlip(existingBlip)
    end

    -- Clean the blip table
    blipsCops = {}

    -- Enable blip?
    if Config.MaxInService ~= -1 and not playerInService then
        return
    end

    if not Config.EnableJobBlip then
        return
    end

    -- Is the player a cop? In that case show all the blips for other cops
    if PlayerData.job and PlayerData.job.name == 'police' then
        ESX.TriggerServerCallback('esx_society:getOnlinePlayers', function(players)
            for i=1, #players, 1 do
                if players[i].job.name == 'police' and players[i].gps > 0 then
                    local id = GetPlayerFromServerId(players[i].source)
                    if NetworkIsPlayerActive(id) and GetPlayerPed(id) ~= PlayerPedId() then
                        createBlip(id)
                    end
                end
                if players[i].job.name == 'ambulance' then
                    local id = GetPlayerFromServerId(players[i].source)
                    if NetworkIsPlayerActive(id) and GetPlayerPed(id) ~= PlayerPedId() then
                        createBlip2(id)
                    end
                end
            end
        end)
    end

end)

RegisterNetEvent('esx_policejob:removeBlip')
AddEventHandler('esx_policejob:removeBlip', function()

    -- Refresh all blips
    for k, existingBlip in pairs(blipsCops) do
        RemoveBlip(existingBlip)
    end

    -- Clean the blip table
    blipsCops = {}
end)

sonrasında policejob client dosyasının en altına bu kodları ekliyoruz

Kod:
Citizen.CreateThread(function()
    while true do
        Citizen.Wait(15000)
        if PlayerData.job and PlayerData.job.name == 'police' then
            ESX.TriggerServerCallback('esx_policejob:getItemAmount', function(qtty)
                if qtty > 0 then
                    TriggerEvent('esx_policejob:updateBlip')
                end
            end, 'gps')
        end
        if PlayerData.job and PlayerData.job.name == 'ambulance' then
            TriggerEvent('esx_policejob:updateBlip')
        end
    end
end)

sonrasında default policejob client dosyasında 1885. satırdan itibaren 1900. satır dahil silip yerine bu kodları yapıştırıyoruz

Kod:
-- Create blip for colleagues

function createBlip(id)

    local ped = GetPlayerPed(id)

    local blip = GetBlipFromEntity(ped)



    if not DoesBlipExist(blip) then -- Add blip and create head display on player

        blip = AddBlipForEntity(ped)

        SetBlipSprite(blip, 1)

        SetBlipColour(blip, 57)

        ShowHeadingIndicatorOnBlip(blip, true) -- Player Blip indicator

        SetBlipRotation(blip, math.ceil(GetEntityHeading(ped))) -- update rotation

        SetBlipScale(blip, 0.85) -- set scale

        SetBlipAsShortRange(blip, true)

        BeginTextCommandSetBlipName('STRING')

        AddTextComponentString('[~b~LSPD~s~]')

        EndTextCommandSetBlipName(blip)



        table.insert(blipsCops, blip) -- add blip to array so we can remove it later

    end

end

function createBlip2(id)

    local ped = GetPlayerPed(id)

    local blip = GetBlipFromEntity(ped)



    if not DoesBlipExist(blip) then

        blip = AddBlipForEntity(ped)

        SetBlipSprite(blip, 1)

        SetBlipColour(blip, 1)

        ShowHeadingIndicatorOnBlip(blip, true)

        SetBlipRotation(blip, math.ceil(GetEntityHeading(ped)))

        SetBlipScale(blip, 0.85)

        SetBlipAsShortRange(blip, true)

        BeginTextCommandSetBlipName('STRING')

        AddTextComponentString('[~r~EMS~s~]')

        EndTextCommandSetBlipName(blip)



        table.insert(blipsCops, blip)

    end

end

sonrasında default policejob server dosyasının en altına bu verdiğim kodları ekliyoruz

Kod:
ESX.RegisterServerCallback('esx_policejob:getItemAmount', function(source, cb, item)
        local xPlayer = ESX.GetPlayerFromId(source)
        local items = xPlayer.getInventoryItem(item)
        if items == nil then
            cb(0)
        else
            cb(items.count)
        end
end)

sonrasında default policejob server dosyasında 513. satırdan itibaren 543. satır aralığını bu verdiğim kod ile değiştiriyoruz

Kod:
AddEventHandler('playerDropped', function()
    -- Save the source in case we lose it (which happens a lot)
    local _source         = source
    local xPlayer         = ESX.GetPlayerFromId(_source)

    -- Did the player ever join?
    if _source ~= nil then
    

        -- Is it worth telling all clients to refresh?
        if xPlayer ~= nil and xPlayer.job ~= nil and xPlayer.job.name == 'police' then
            local currentGPS    = xPlayer.getInventoryItem('gps').count
            Citizen.Wait(5000)
            if currentGPS > 0 then
                TriggerClientEvent('esx_policejob:updateBlip', -1)
            end
        end
    end
end)

RegisterServerEvent('esx_policejob:spawned')
AddEventHandler('esx_policejob:spawned', function()
    local _source             = source
    local xPlayer             = ESX.GetPlayerFromId(_source)

    if xPlayer ~= nil and xPlayer.job ~= nil and xPlayer.job.name == 'police' then
        local currentGPS         = xPlayer.getInventoryItem('gps').count
        Citizen.Wait(5000)
        if currentGPS > 0 then
            TriggerClientEvent('esx_policejob:updateBlip', -1)
        end
    end
end)

RegisterServerEvent('esx_policejob:forceBlip')
AddEventHandler('esx_policejob:forceBlip', function()
    local _source = source
    local xPlayer = ESX.GetPlayerFromId(_source)
    local currentGPS     = xPlayer.getInventoryItem('gps').count

    if currentGPS > 0 then
        TriggerClientEvent('esx_policejob:updateBlip', -1)
    end
end)

eğer default bir policejob kullanmıyorsanız event isimlerine bakarak düzenleme yapınız
tekrardan policejob server dosyasının en altına bu kodları ekliyoruz

Kod:
AddEventHandler('esx:onAddInventoryItem', function(source, item, count)
    local _source = source
    local xPlayer = ESX.GetPlayerFromId(_source)
    if xPlayer ~= nil and xPlayer.job ~= nil and xPlayer.job.name == 'police' then
        if item.name == 'gps' and item.count > 0 then
            TriggerClientEvent('esx_policejob:updateBlip', source)
        end
    end
end)

AddEventHandler('esx:onRemoveInventoryItem', function(source, item, count)
    local _source = source
    local xPlayer = ESX.GetPlayerFromId(_source)
    if xPlayer ~= nil and xPlayer.job ~= nil and xPlayer.job.name == 'police' then
        if item.name == 'gps' and item.count < 1 then
            TriggerClientEvent('esx_policejob:removeBlip', source) -- bu event cliente sonradan ekleniyor
        end
    end
end)

son olarak esx_society scriptinin server dosyasında 313. satırından itibaren 328. satır dahil silip yerine bu kodları yapıştırıyoruz

Kod:
ESX.RegisterServerCallback('esx_society:getOnlinePlayers', function(source, cb)
    local xPlayers = ESX.GetPlayers()
    local players  = {}

    for i=1, #xPlayers, 1 do
        local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
        local currentGPS     = xPlayer.getInventoryItem('gps').count
        table.insert(players, {
            source     = xPlayer.source,
            identifier = xPlayer.identifier,
            name       = xPlayer.name,
            job        = xPlayer.job,
            gps        = currentGPS
        })
    end

    cb(players)
end)

eğer esx_policejob ve esx_society scriptlerinde düzenleme yaptıysanız event isimlerine dikkat ederek yapabilirsiniz default hallerindeki satır numaralarını vererek anlattım.

databasenize gps adında item oluşturmanız gerekiyor.



Gps ismi steam değilde karakter işmi nasıl yaparız ? biliyormusun başkan
 

Şu an konuyu görüntüleyenler (Toplam : 0, Üye: 0, Misafir: 0)

Geri
Üst