Jump to content

save [help]


boro

Recommended Posts

Please help what is bad ?

[2012-12-19 12:17:15] WARNING: killsave/server.lua:4: Bad argument @ 'isGuestAccount' [Expected account at argument 1, got nil]

[2012-12-19 12:17:15] WARNING: killsave/server.lua:5: Bad argument @ 'getAccountData' [Expected account at argument 1, got nil]

[2012-12-19 12:17:15] WARNING: killsave/server.lua:6: Bad argument @ 'getAccountData' [Expected account at argument 1, got nil]

node = xmlLoadFile ("player.xml") 
  
function playerLogin (_, theCurrentAccount, autoLogin) 
    if not (isGuestAccount (theCurrentAccount)) then -- no need to get the players account 
        local accountData = getAccountData (theCurrentAccount, "Deaths") 
        local accountData = getAccountData (theCurrentAccount, "Kills") 
        if (accountData) then 
            setElementData(source,"Deaths",accountData ) --use the account data var instead of getting another var plus use setElementData 
            setElementData(source,"Kills",accountData ) --use the account data var instead of getting another var plus use setElementData 
    end 
    end 
end 
addEventHandler("onPlayerLogin", getRootElement(), playerLogin) 
  
function onQuit() 
    local account = getPlayerAccount (source) --get there account here first 
    if not (isGuestAccount (account)) then 
            setAccountData(account,"Deaths",getElementData(source,"Deaths")) --use getElementData 
            setAccountData(account,"Kills",getElementData(source,"Kills")) --use getElementData 
    end 
end 
addEventHandler("onPlayerQuit", getRootElement(), onQuit) 

Link to comment

Im not so sure but try

  
function playerLogin (_, theCurrentAccount, autoLogin) 
    local account = getAccountName (theCurrentAccount ) 
    if not (isGuestAccount (account)) then -- no need to get the players account 
        local accountData = getAccountData (account , "Deaths") 
        local accountData = getAccountData (account , "Kills") 
        if (accountData) then 
            setElementData(source,"Deaths",accountData ) --use the account data var instead of getting another var plus use setElementData 
            setElementData(source,"Kills",accountData ) --use the account data var instead of getting another var plus use setElementData 
    end 
    end 
end 
addEventHandler("onPlayerLogin", getRootElement(), playerLogin) 
  

Link to comment
node = xmlLoadFile ("player.xml") 
  
function playerLogin (_, theCurrentAccount, autoLogin) 
    if not (isGuestAccount (theCurrentAccount)) then -- no need to get the players account 
        local accountData = getAccountData (theCurrentAccount, "Deaths") 
        local accountData = getAccountData (theCurrentAccount, "Kills") 
        if (accountData) then 
            setElementData(source,"Deaths",accountData ) --use the account data var instead of getting another var plus use setElementData 
            setElementData(source,"Kills",accountData ) --use the account data var instead of getting another var plus use setElementData 
    end 
    end 
end 
addEventHandler("onPlayerLogin", getRootElement(), playerLogin) 
  
function onQuit() 
    local account = getPlayerAccount (source) --get there account here first 
    if not (isGuestAccount (account)) then 
            setAccountData(account,"Deaths",getElementData(source,"Deaths")) --use getElementData 
            setAccountData(account,"Kills",getElementData(source,"Kills")) --use getElementData 
    end 
end 
addEventHandler("onPlayerQuit", getRootElement(), onQuit) 

You defined accountData twice, but i don't know why isGuestAccount gives you error.

Maybe you can try this, i use the same method to save things.

  
function playerLogin (acc,account) 
if not account or isGuestAccount(account) then return false end 
    local accountDataD = getAccountData (account, "Deaths") 
    local accountDataK = getAccountData (account, "Kills") 
    if accountDataK and accountDataD then 
        setElementData(source,"Deaths",accountDataD ) 
        setElementData(source,"Kills",accountDataK ) 
    end 
end 
addEventHandler("onPlayerLogin", getRootElement(), playerLogin) 
  
function onQuit() 
  
    local account = getPlayerAccount(source) 
    if not account or (isGuestAccount(account)) then return false end 
     
    setAccountData(account,"Deaths",getElementData(source,"Deaths")) 
    setAccountData(account,"Kills",getElementData(source,"Kills")) 
     
end 
addEventHandler("onPlayerQuit", getRootElement(), onQuit) 
  

NOT TESTED!

I hope i'm helped you, but i'm not sure it's work.

Other thing:

Im not so sure but try
  
function playerLogin (_, theCurrentAccount, autoLogin) 
    local account = getAccountName (theCurrentAccount ) 
    if not (isGuestAccount (account)) then -- no need to get the players account 
        local accountData = getAccountData (account , "Deaths") 
        local accountData = getAccountData (account , "Kills") 
        if (accountData) then 
            setElementData(source,"Deaths",accountData ) --use the account data var instead of getting another var plus use setElementData 
            setElementData(source,"Kills",accountData ) --use the account data var instead of getting another var plus use setElementData 
    end 
    end 
end 
addEventHandler("onPlayerLogin", getRootElement(), playerLogin) 
  

Same problem in your code, and you can't use strings. You need to define 'account' as an "account element", not string.

Link to comment

Try This

function playerLogin (thePreviousAccount, theCurrentAccount, autoLogin) 
  if  not (isGuestAccount (getPlayerAccount (source))) then 
        local accountData = getAccountData (theCurrentAccount , "Deaths") 
        local accountData = getAccountData (theCurrentAccount , "Kills") 
        if (accountData) then 
            setElementData(source, "Deaths",accountData )  
            setElementData(source, "Kills",accountData )  
    end 
  end 
end 
addEventHandler ("onPlayerLogin", getRootElement(), playerLogin) 
  
function onQuit (quitType, reason, responsibleElement) 
  if not (isGuestAccount (getPlayerAccount (source))) then 
    account = getPlayerAccount (source) 
    if (account) then 
            setAccountData(account, "Deaths",getElementData(source,"Deaths"))  
            setAccountData(account, "Kills",getElementData(source,"Kills"))  
    end 
  end 
end 
addEventHandler ("onPlayerQuit", getRootElement(), onQuit) 

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