Jump to content

عندي مشكله في حفظ الاسلحه


MeZo999

Recommended Posts

اخوي اذا طلعت ودخلت من السيرفر يحفظ بس اذا متت ما يرجعو الاسلحه

ارجوووووووووووووووووووووكم حل

https://forum.multitheftauto.com/viewtopic.php?f=160&t=67365#p632720

جرب ذا

addEventHandler("onPlayerWasted", root, 
    function() 
        local weapons = convertWeaponsToJSON(source) 
        setElementData(source,"tempWeapons",weapons) 
    end 
) 
  
addEventHandler("onPlayerSpawn", root, 
    function () 
        local weapons = getElementData(source,"tempWeapons") 
        if (weapons) then 
            giveWeaponsFromJSON(source, weapons) 
        end 
    end 
) 
  
function convertWeaponsToJSON(player) 
    local weaponSlots = 12 
    local weaponsTable = {} 
    for slot=1, weaponSlots do 
        local weapon = getPedWeapon( source, slot ) 
        local ammo = getPedTotalAmmo( source, slot ) 
        if (weapon > 0 and ammo > 0) then 
            weaponsTable[weapon] = ammo 
        end 
    end 
    return toJSON(weaponsTable) 
end 
  
function giveWeaponsFromJSON(player, weapons) 
    if (weapons and weapons ~= "") then 
        for weapon, ammo in pairs(fromJSON(weapons)) do 
            if (weapon and ammo) then 
                giveWeapon(player, tonumber(weapon), tonumber(ammo)) 
            end 
        end 
    end 
end 
Link to comment

اخوي اذا طلعت ودخلت من السيرفر يحفظ بس اذا متت ما يرجعو الاسلحه

ارجوووووووووووووووووووووكم حل

https://forum.multitheftauto.com/viewtopic.php?f=160&t=67365#p632720

جرب ذا

addEventHandler("onPlayerWasted", root, 
    function() 
        local weapons = convertWeaponsToJSON(source) 
        setElementData(source,"tempWeapons",weapons) 
    end 
) 
  
addEventHandler("onPlayerSpawn", root, 
    function () 
        local weapons = getElementData(source,"tempWeapons") 
        if (weapons) then 
            giveWeaponsFromJSON(source, weapons) 
        end 
    end 
) 
  
function convertWeaponsToJSON(player) 
    local weaponSlots = 12 
    local weaponsTable = {} 
    for slot=1, weaponSlots do 
        local weapon = getPedWeapon( source, slot ) 
        local ammo = getPedTotalAmmo( source, slot ) 
        if (weapon > 0 and ammo > 0) then 
            weaponsTable[weapon] = ammo 
        end 
    end 
    return toJSON(weaponsTable) 
end 
  
function giveWeaponsFromJSON(player, weapons) 
    if (weapons and weapons ~= "") then 
        for weapon, ammo in pairs(fromJSON(weapons)) do 
            if (weapon and ammo) then 
                giveWeapon(player, tonumber(weapon), tonumber(ammo)) 
            end 
        end 
    end 
end 

يحفظ تمام بس الاسلحه تزيد ض1

Link to comment
getPedTotalAmmo 

* Server Side

الكود ما يعطيك عدد الطلقات الصحيح في حالة موتك او اذا تم سحب السلاح منك

مثال: جرب اعطي نفسك 100 غاز

بعدين جرب اسحب السلاح بكود

takeWeapon 

بعدين جرب الكود راح تلاحظ ان يقولك معك 100 غاز، لكن الغاز مسحوب!!1

ونفس الكلام اذا راحت اسلحتك لما تموت، الكود يعطيك عدد الرصاص الي كان معك قبل الموت

* Client Side

الكود مافيه اي مشكلة

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...