ShadowFon 1
ShadowFon
noisiv 1
noisiv
Manwe Work 1
Manwe Work
romegames 1
romegames
kralhakan2009 1
kralhakan2009
Vahsi Uzman 1
Vahsi Uzman
Bvural41 1
Bvural41
NovaLst 1
NovaLst
bikral 1
bikral
Hikaye Ekle
Reklam vermek için turkmmo@gmail.com

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

sergioneral

enjoy the silence 👌
Telefon Numarası Onaylanmış Üye TC Kimlik Numarası Doğrulanmış Üye
Fahri Üye
Katılım
17 Haz 2010
Konular
3,640
Mesajlar
19,614
Çözüm
54
Online süresi
17d 14h
Reaksiyon Skoru
4,815
Altın Konu
163
TM Yaşı
15 Yıl 12 Ay 2 Gün
Başarım Puanı
474
Yaş
31
MmoLira
-933
DevLira
0
Ticaret - 0%
0   0   0

ROHAN2 WORLD 1-120 TR TİPİ OFFICIAL YOHARA, BALATHOR VE AMON! 80. GÜNÜNDE! +10.000 ONLİNE! HİLE VE BOT %100 ENGELLİ 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
 
Sorunuzu anlamadım hocam, daha detaylı anlatır mısın?

polisler gps de yanı harıtada steam isimleriyle görünüyor onu nasıl karakter ismi yaparız meseala benım steam ısmım kazanova ama karakterımın ısmı tırtıl kelebek
 
polisler gps de yanı harıtada steam isimleriyle görünüyor onu nasıl karakter ismi yaparız meseala benım steam ısmım kazanova ama karakterımın ısmı tırtıl kelebek

Bu biraz daha derin kodlamaya giriyor, o kadar bilgim yok hocam maalesef.
 

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

Geri
Üst