Jump to content

AccountData


Recommended Posts

السلام عليكم

بالله شوفولي وش قصصة ذا الكود, مو جاي يحفظ الداتا

local Stats = { 
    [22] = { 69 }; 
    [23] = { 70 }; 
    [24] = { 71 }; 
    [25] = { 72 }; 
    [26] = { 73 }; 
    [27] = { 74 }; 
    [28] = { 75 }; 
    [29] = { 76 }; 
    [30] = { 77 }; 
    [31] = { 78 }; 
    [34] = { 79 }; 
}; 
  
function stats ( ammo, attacker, weapon, bodypart ) 
    if ( attacker ) then 
        if ( getElementType ( attacker ) == "player") then 
            wepID = getWeaponNameFromID ( weapon ) 
            gStat = getPedStat ( attacker, Stats[tonumber(weapon)][1] ) 
            setPedStat ( attacker, Stats[tonumber(weapon)][1],gStat + 100 ) 
        end 
    end 
end 
addEventHandler ( "onPlayerWasted", getRootElement(), stats) 
  
addEventHandler('onPlayerQuit',root, 
function() 
    local vAcc = getPlayerAccount(source) 
        if not vAcc or isGuestAccount(vAcc) then return end 
        setAccountData(vAcc,'w69', getPedStat (source, 69)) 
        setAccountData(vAcc,'w71', getPedStat (source, 71)) 
        setAccountData(vAcc,'w72', getPedStat (source, 72)) 
        setAccountData(vAcc,'w73', getPedStat (source, 73)) 
        setAccountData(vAcc,'w74', getPedStat (source, 74)) 
        setAccountData(vAcc,'w75', getPedStat (source, 75)) 
        setAccountData(vAcc,'w76', getPedStat (source, 76)) 
        setAccountData(vAcc,'w77', getPedStat (source, 77)) 
        setAccountData(vAcc,'w78', getPedStat (source, 78)) 
        setAccountData(vAcc,'w79', getPedStat (source, 79)) 
end 
) 
  
addEventHandler('onPlayerLogin',root, 
function(_,acc) 
    local d69 = getAccountData(acc,'w69') 
    local d71 = getAccountData(acc,'w71') 
    local d72 = getAccountData(acc,'w72') 
    local d73 = getAccountData(acc,'w73') 
    local d74 = getAccountData(acc,'w74') 
    local d75 = getAccountData(acc,'w75') 
    local d76 = getAccountData(acc,'w76') 
    local d77 = getAccountData(acc,'w77') 
    local d78 = getAccountData(acc,'w78') 
    local d79 = getAccountData(acc,'w79') 
        if ( d69 ) then 
        setPedStat(source, 69, tonumber(d69)) 
        setPedStat(source, 71, tonumber(d71)) 
        setPedStat(source, 72, tonumber(d72)) 
        setPedStat(source, 73, tonumber(d73)) 
        setPedStat(source, 74, tonumber(d74)) 
        setPedStat(source, 75, tonumber(d75)) 
        setPedStat(source, 76, tonumber(d76)) 
        setPedStat(source, 77, tonumber(d77)) 
        setPedStat(source, 78, tonumber(d78)) 
        setPedStat(source, 79, tonumber(d79)) 
        end 
    end 
) 

Link to comment

طيب شوف الدي بق إذا فيه اي خطأ

و تأكد انك حاطه سيرفر بالميتا

و يفضل تعدل سطر 17

if ( getElementType ( attacker ) == "player") then 

و تسويه كذا عشان الي يقتل نفسه ما يزيد

if ( getElementType ( attacker ) == "player" and attacker ~= source ) then 

Link to comment

شوف السكربت ذا

,

function saveWeaponStats(player) 
    if (not player or not isElement(player)) then return end 
    local account = getPlayerAccount(player) 
    if (account and not isGuestAccount(account)) then 
        local stats = "" 
        for stat=69, 81 do 
            local value = getPedStat(player, stat) 
            stats = stats ..",".. stat ..";".. value 
        end 
        setAccountData(account, "weaponStats", stats) 
    end 
end 
  
function loadWeaponStats(player) 
    if (not player or not isElement(player)) then return end 
    local account = getPlayerAccount(player) 
    if (account and not isGuestAccount(account)) then 
        local statsData = getAccountData(account,"weaponStats") 
        local stats = split(statsData, ",") 
        for k, v in ipairs(stats) do 
            local stat = split(v, ";") 
            setPedStat(player, tonumber(stat[1]), tonumber(stat[2])) 
        end 
    end 
end 
  
addEventHandler("onPlayerQuit",root,function () saveWeaponStats(source) end) 
addEventHandler("onPlayerLogin",root,function () loadWeaponStats(source) end) 
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...