Jump to content

Problem with new script


Recommended Posts

Hi all i tree make new script for save score but don't work, Thx for all help

This is my lua

addEventHandler ( "onPlayerLogin", root, 
    function( thePreviousAccount, theCurrentAccount, autoLogin ) 
        setAccountData( account,"score",tonumber( getAccountData( account,"score" ) ) ) 
                setElementData( Player, "score", tonumber( getAccountData( account,"score" ) ) ) 
source, "score") ) ) 
            end  
        else 
            local accountSource = getPlayerAccount ( source ) 
            setElementData( source, "score", tonumber( getAccountData( accountSource,"score" ) ) ) 
    end 
)       
  
addEventHandler( "onPlayerQuit",root, 
        local account = getPlayerAccount ( source ) 
        if not getAccountData( account,"score" ) and not getAccountData( account,"score" ) 
        end 
        setElementData( source,"score",tonumber( getAccountData( account,"score" ) ) ) 
source, "score") ) 
    end 
 ) 
  
addEventHandler( "onResourceStart",resourceRoot, 
    function( ) 
        outputDebugString( "add score to scoreboard Return: "..tostring( 
            call( getResourceFromName("Scoreboard"), "addScoreboardColumn", "score",root,2, 0.032 ) 
        ) ) 
    end 
) 
  

Edited by Guest
Link to comment

ok i tree make new script but still doesn't work :( i still write wiki but nothing i make one week score save scriptt but still dosen't work please help .. i have this error... !! savescore/server.lua:18: attempt to call global 'getPlayerScore' (a nil value) !!

lua

node = xmlLoadFile ("player.xml") 
  
function playerLogin (thePreviousAccount, theCurrentAccount, autoLogin) 
    if not (isGuestAccount (getPlayerAccount(source))) then 
        local accountData = getAccountData (theCurrentAccount, "score") 
        if (accountData) then 
            local playerScore = getAccountData(theCurrentAccount, "score") 
            setPlayerScore(source, playerScore) 
              end 
              end 
            end 
            addEventHandler("onPlayerLogin", getRootElement(), playerLogin) 
  
function onQuit() 
    if not (isGuestAccount (getPlayerAccount (source))) then 
        account = getPlayerAccount (source) 
        if (account) then 
            setAccountData(account,"score", tostring(getPlayerScore(source))) 
        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...