Paylaşım - Disc Uyumlu Silah Eklentileri Scripti

Fivem.com.tr

Fivem.com.tr
Katılım
1 Eki 2022
Mesajlar
5,891
Tepki
84
Selamlar. Bildiğiniz üzere disc-inventoryde eklenti takılı silahınızı belinize koyup tekrar aldığınızda bile tüm silah eklentileri tamamen sıfırlanıyor. Bu konumda kendi yazdığım eklenti scriptini paylaşacağım.



Script Hakkında:

- Bu script sayesinde oyuncu eklenti takılı olan silahını moteline, bagajına vs. koysa bile veya sunucuya restart atılsa bile oyuncunun silahına takmış olduğu eklentiler kaybolmaz.

- Takılan tüm eklentiler "/eklenticikart" komutuyla çıkartılır ve çıkartılan eklentilerin eşyaları geri iade edilmez. Yani eklentiler tek kullanımlıktır. İsteğe göre kendiniz düzenleyebilirsiniz.



Kurulum:



Öncelikle items tablonuza aşağıdaki eşyaları eklemeyi unutmayın. Genelde items tabloları farklı olabildiği için sql dosyasının içine eklemedim.



items tablosuna eklenecekler: "susturucu", "fener", "tutamac", "kaplama", "durbun"



Sonrasında script dosyası içerisinde vermiş olduğum sql dosyasını datanıza çıkartınız.





disc-inventoryhud\client\weapons.lua içerisinde bulunan "GiveWeapon" fonksiyonunu aşağıdaki şekilde güncelleyin:





Kod:


Kod:
supp1 = {-2084633992, -1357824103, 2132975508, -494615257}
supp2 = {-1716589765, 324215364, -270015777, -1074790547, -1063057011, -1654528753, 984333226}
supp3 = {1593441988, -771403250, 584646201, 137902532, 736523883}
supp4 = {487013001}
flash1 = {453432689, 1593441988, 584646201, -1716589765, -771403250, 324215364}
flash2 = {736523883, -270015777, 171789620, -1074790547, -2084633992, -1357824103, -1063057011, 2132975508, 487013001, -494615257, -1654528753, 984333226}
grip1 = {171789620, -1074790547, -2084633992, -1063057011, 2132975508, 2144741730, -494615257, -1654528753, 984333226}
scope1 = {-2084633992}

function GiveWeapon(weapon)
    local checkh = Config.Throwables
    local playerPed = GetPlayerPed(-1)
    local hash = GetHashKey(weapon)
    ESX.TriggerServerCallback('disc-inventoryhud:getAmmoCount', function(ammoCount, susturucu, fener, tutamac, kaplama, durbun)
        GiveWeaponToPed(playerPed, hash, 1, false, true)

        if susturucu == 1 then
            if hash == GetHashKey("WEAPON_PISTOL") then
                GiveWeaponComponentToPed(GetPlayerPed(-1), GetHashKey("WEAPON_PISTOL"), GetHashKey("component_at_pi_supp_02"))
            elseif table.includes(supp1, hash) then
                GiveWeaponComponentToPed(GetPlayerPed(-1), hash, 0x837445AA)
            elseif table.includes(supp2, hash) then
                GiveWeaponComponentToPed(GetPlayerPed(-1), hash, 0xA73D4664)
            elseif table.includes(supp3, hash) then
                GiveWeaponComponentToPed(GetPlayerPed(-1), hash, 0xC304849A)
            elseif table.includes(supp4, hash) then
                GiveWeaponComponentToPed(GetPlayerPed(-1), hash, 0xE608B35E)
            end
        end

        if fener == 1 then
            if table.includes(flash1, hash) then
                GiveWeaponComponentToPed(GetPlayerPed(-1), hash, 0x359B7AAE)
            elseif table.includes(flash2, hash) then
                GiveWeaponComponentToPed(GetPlayerPed(-1), hash, 0x7BC4CDDC)
            end
        end

        if tutamac ==  1 then
            if table.includes(grip1, hash) then
                GiveWeaponComponentToPed(GetPlayerPed(-1), hash, 0xC164F53)
            end
        end

        if kaplama == 1 then
            if hash == GetHashKey("WEAPON_PISTOL") then
                GiveWeaponComponentToPed(GetPlayerPed(-1), GetHashKey("WEAPON_PISTOL"), GetHashKey("COMPONENT_PISTOL_VARMOD_LUXE"))
            elseif hash == GetHashKey("WEAPON_PISTOL50") then
                GiveWeaponComponentToPed(GetPlayerPed(-1), GetHashKey("WEAPON_PISTOL50"), GetHashKey("COMPONENT_PISTOL50_VARMOD_LUXE"))
            elseif hash == GetHashKey("WEAPON_APPISTOL") then
                GiveWeaponComponentToPed(GetPlayerPed(-1), GetHashKey("WEAPON_APPISTOL"), GetHashKey("COMPONENT_APPISTOL_VARMOD_LUXE"))

            elseif hash == GetHashKey("WEAPON_HEAVYPISTOL") then
                GiveWeaponComponentToPed(GetPlayerPed(-1), GetHashKey("WEAPON_HEAVYPISTOL"), GetHashKey("COMPONENT_HEAVYPISTOL_VARMOD_LUXE"))

            elseif hash == GetHashKey("WEAPON_SMG") then
                GiveWeaponComponentToPed(GetPlayerPed(-1), GetHashKey("WEAPON_SMG"), GetHashKey("COMPONENT_SMG_VARMOD_LUXE"))

            elseif hash == GetHashKey("WEAPON_MICROSMG") then
                GiveWeaponComponentToPed(GetPlayerPed(-1), GetHashKey("WEAPON_MICROSMG"), GetHashKey("COMPONENT_MICROSMG_VARMOD_LUXE"))

            elseif hash == GetHashKey("WEAPON_ASSAULTRIFLE") then
                GiveWeaponComponentToPed(GetPlayerPed(-1), GetHashKey("WEAPON_ASSAULTRIFLE"), GetHashKey("COMPONENT_ASSAULTRIFLE_VARMOD_LUXE"))

            elseif hash == GetHashKey("WEAPON_CARBINERIFLE") then
                GiveWeaponComponentToPed(GetPlayerPed(-1), GetHashKey("WEAPON_CARBINERIFLE"), GetHashKey("COMPONENT_CARBINERIFLE_VARMOD_LUXE"))

            elseif hash == GetHashKey("WEAPON_ADVANCEDRIFLE") then
                GiveWeaponComponentToPed(GetPlayerPed(-1), GetHashKey("WEAPON_ADVANCEDRIFLE"), GetHashKey("COMPONENT_ADVANCEDRIFLE_VARMOD_LUXE"))
            end
        end

        if durbun ==  1 then
            if table.includes(scope1, hash) then
                GiveWeaponComponentToPed(GetPlayerPed(-1), hash, 0xA0D89C42)
            end
        end

        if checkh[weapon] == hash then     
            SetPedAmmo(playerPed, hash, 1)
        elseif Config.FuelCan == hash and ammoCount == nil then
            SetPedAmmo(playerPed, hash, 1000)
        else
            SetPedAmmo(playerPed, hash, ammoCount or 0)
        end
    end, hash)
end

function table.includes(table, element)
    for _, value in pairs(table) do
        if value == element then
            return true
        end
    end
    return false
end



Sonrasında disc-inventoryhud\server\weapons.lua içerisinde "disc-inventoryhud:getAmmoCount" isimli ServerCallback'i aşağıdaki kodla değiştirin:





Kod:


Kod:
ESX.RegisterServerCallback('disc-inventoryhud:getAmmoCount', function(source, cb, hash)
    local _source = source
    local player = ESX.GetPlayerFromId(_source)
    MySQL.Async.fetchAll('SELECT * FROM disc_ammo WHERE owner = @owner and hash = @hash', {
        ['@owner'] = player.identifier,
        ['@hash'] = hash
    }, function(results)
        if #results == 0 then
            cb(nil)
        else
            cb(results[1].count, results[1].susturucu, results[1].fener, results[1].tutamac, results[1].kaplama, results[1].durbun, ammoCount, susturucu, fener, tutamac, kaplama, durbun)
        end
    end)
end)



Bunları da yaptıktan sonra scripte start vermekten başka yapmanız gereken birşey kalmıyor. Umarım sorunsuz kullanabilirsiniz.








Parasızlığın eğlenmenizi engellemesine asla izin vermeyin. -Anonim

Konu alıntıdır, yanlış veya hatalı bir bilgi/paylaşım var ise yanıtlayabilir veya bizimle iletişime geçebilirsiniz.
 

Şu anda bu konu'yu okuyan kullanıcılar

Benzer konular

Üst