Jump to content

getAccountData problem


SkatCh

Recommended Posts

Posted

guys please i need some help how can i fix this i create a medkits system but i have a problem when i try to save player medkits .

function getPlayerMedKits(player) 
    local medKits = tonumber(getAccountData(player, "medKits")) or 0 
    return medKits 
end 
  
function setPlayerMedKits(player, amount) 
    setAccountData(player, "medKits", tostring(amount)) 
    getPlayerAccount(player, "medKits", tostring(amount)) 
    triggerClientEvent(player, "onMedKitLoad", player, amount) 
    return true 
end 

warnings :

-Bad argument @ 'getAccountData' [Expected account at argument 1, got player ]

-Bad argument @ 'setAccountData' [Expected account at argument 1, got player ]

Failure is simply an opportunity to begin again more intelligently - Henry Ford

Posted

Try, it will be works perfectly:

function getPlayerMedKits(player) 
    local account = getPlayerAccount(player) 
    if not account then outputChatBox("Player not logged in!") return 0 end 
    local medKits = getAccountData(account, "medKits") or 0 
    return medKits 
end 
  
function setPlayerMedKits(player, amount) 
    local account = getPlayerAccount(player) 
    if not account then outputChatBox("Player not logged in!") return false end 
    setAccountData(account, "medKits", tonumber(amount)) 
    --WTF? getPlayerAccount(player, "medKits", tonumber(amount)) 
    triggerClientEvent(player, "onMedKitLoad", player, tonumber(amount)) 
    return true 
end 

Posted

lol i already fixed it . topic can be closed

Failure is simply an opportunity to begin again more intelligently - Henry Ford

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...