Jump to content

Check data


Klesh

Recommended Posts

Posted

Im trying to get the data when the player is login, doesnt show it!

    addEvent( 'onPlayerRaceWasted',true ) 
    addEvent( "stats", true ) 
      
    exports[ 'scoreboard' ]:addScoreboardColumn( 'Wins' ) 
    --exports[ 'scoreboard' ]:addScoreboardColumn( 'Deaths' ) 
    --exports[ 'scoreboard' ]:addScoreboardColumn( 'ratio' ) 
      
    local restriction = { } 
      
    function restrictionEnd( playerName ) 
        restriction[ playerName ] = nil 
    end 
      
      
    function publicstatsinfo( ) 
        if isElement( source ) then 
            local account = getPlayerAccount( source ) 
            if account then 
                if isGuestAccount( account ) then return end 
                local askdname = getPlayerName( source ) 
                local wins = getAccountData( account, "Wins" ) or 0 
                local loses = getAccountData( account, "Deaths" ) or 0 
                if loses and wins then 
                    --outputChatBox("#FFA824*" .. askdname .. " won " .. tostring( wins ) .. " times and he lost " ..tostring( loses ).. " times, his ratio is " .. tostring( ratio ) .. "%", root, 255, 12, 15, true) 
                end 
            end 
        else 
            outputChatBox( "Error source is not player" ) 
        end 
    end 
      
    
      
    function DestructionWin( vehicle ) 
        local alivePlayers = getAlivePlayers( ) 
        if #alivePlayers == 1 then 
            if isElement( alivePlayers[1] ) then 
                local account = getPlayerAccount( alivePlayers[1] ) 
                if isGuestAccount( account ) then return end 
                local count = tonumber( getAccountData( account,"Wins" ) or 0 ) + 1 
                setAccountData( account,"Wins",count ) 
                setElementData( alivePlayers[1],'Wins', count ) 
                --outputChatBox ( "#FFA824The player " .. getPlayerName( alivePlayers[1] ) .. " won!", root, 255, 255, 255, true ) 
            end 
        else 
            local account = getPlayerAccount( source ) 
            if isGuestAccount( account ) then return end 
            local loses = tonumber( getAccountData( account,"Deaths" ) or 0 ) + 1 
            setAccountData( account,"Deaths", loses ) 
            setElementData( source,'Deaths', loses ) 
        end 
    end 
     
        function onPlayerLogin ( _, acc ) 
        if acc then 
            local acc = getPlayerAccount ( source ) 
            local wins = getAccountData( account, "Wins" ) 
            if wins then 
               setAccountData(acc, wins) 
            end 
        end 
    end 
    addEventHandler ( "onPlayerLogin",root, onPlayerLogin ) 
      
      
    addEventHandler( "stats", root, publicstatsinfo ) 
    addEventHandler( "onPlayerRaceWasted", root,DestructionWin ) 
     
     

Posted

Instead of:

setAccountData(acc, wins) 

It should be:

setElementData ( source, "Wins", wins ) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
  
  local count = tonumber( getAccountData( account,"Wins" ) or 0 ) + 1 -- ????? 
                                      setAccountData( account,"Wins",count ) 
  

Why Not

  
local count = tonumber ( getAccountData ( account , "Wins" ) ) or 0 
     setAccountData ( account, "Wins",  tonumber(count) + 1) 
  

Posted
  
  local count = tonumber( getAccountData( account,"Wins" ) or 0 ) + 1 -- ????? 
                                      setAccountData( account,"Wins",count ) 
  

Why Not

  
local count = tonumber ( getAccountData ( account , "Wins" ) ) or 0 
     setAccountData ( account, "Wins",  tonumber(count) + 1) 
  

It makes no sense changing it because it's exactly the same.

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted
  
  local count = tonumber( getAccountData( account,"Wins" ) or 0 ) + 1 -- ????? 
                                      setAccountData( account,"Wins",count ) 
  

Why Not

  
local count = tonumber ( getAccountData ( account , "Wins" ) ) or 0 
     setAccountData ( account, "Wins",  tonumber(count) + 1) 
  

It makes no sense changing it because it's exactly the same.

But why u reply everytimes negative in my post ? What is u problem? :lol:

This is correct :

  
local count = tonumber ( getAccountData ( account , "Wins" ) ) or 0 
     setAccountData ( account, "Wins",  tonumber(count) + 1) 
  

Posted
Changed, still the same error, the data doesn't set when player login!

Try adding a debug output to see what 'wins' return when you login.

@Hunterix: Is both the same thing, it won't make any difference.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
  
  local count = tonumber( getAccountData( account,"Wins" ) or 0 ) + 1 -- ????? 
                                      setAccountData( account,"Wins",count ) 
  

Why Not

  
local count = tonumber ( getAccountData ( account , "Wins" ) ) or 0 
     setAccountData ( account, "Wins",  tonumber(count) + 1) 
  

It makes no sense changing it because it's exactly the same.

But why u reply everytimes negative in my post ? What is u problem? :lol:

This is correct :

  
local count = tonumber ( getAccountData ( account , "Wins" ) ) or 0 
     setAccountData ( account, "Wins",  tonumber(count) + 1) 
  

It's not negative, I just said the truth. And as I said already before, it is correct just like the code he had before.

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted
  
exports.scoreboard:addScoreboardColumn('Wins') 
function winScore () 
local sourceAccount = getPlayerAccount ( source ) 
local count = tonumber ( getAccountData ( sourceAccount , "Wins" ) ) or 0 
if count == false then 
setElementData ( source, "Wins", "0" ) 
else 
setElementData ( source, "Wins", count ) 
end 
end 
addEventHandler ( "onPlayerSpawn", getRootElement(), winScore ) 
addEventHandler ( "onPlayerLogin", getRootElement(), winScore ) 
  

Tested with other Data

Posted
function onPlayerLogin ( _, acc ) 
    if ( acc ) then 
        local wins = tonumber ( getAccountData ( account, "Wins" ) ) or 0 
        setElementData ( source, "Wins", wins ) 
    end 
end 
addEventHandler ( "onPlayerLogin",root, onPlayerLogin ) 

That's easier.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Which means the script is not really saving anything.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

How i can save this data ?

    addEvent( 'onPlayerRaceWasted',true ) 
    addEvent( "stats", true ) 
      
    exports[ 'scoreboard' ]:addScoreboardColumn( 'Wins' ) 
    --exports[ 'scoreboard' ]:addScoreboardColumn( 'Deaths' ) 
    --exports[ 'scoreboard' ]:addScoreboardColumn( 'ratio' ) 
      
    local restriction = { } 
      
    function restrictionEnd( playerName ) 
        restriction[ playerName ] = nil 
    end 
      
      
    function publicstatsinfo( ) 
        if isElement( source ) then 
            local account = getPlayerAccount( source ) 
            if account then 
                if isGuestAccount( account ) then return end 
                local askdname = getPlayerName( source ) 
                local wins = getAccountData( account, "Wins" ) or 0 
                local loses = getAccountData( account, "Deaths" ) or 0 
                if loses and wins then 
                    --outputChatBox("#FFA824*" .. askdname .. " won " .. tostring( wins ) .. " times and he lost " ..tostring( loses ).. " times, his ratio is " .. tostring( ratio ) .. "%", root, 255, 12, 15, true) 
                end 
            end 
        else 
            outputChatBox( "Error source is not player" ) 
        end 
    end 
      
    
      
    function DestructionWin( vehicle ) 
        local alivePlayers = getAlivePlayers( ) 
        if #alivePlayers == 1 then 
            if isElement( alivePlayers[1] ) then 
                local account = getPlayerAccount( alivePlayers[1] ) 
                if isGuestAccount( account ) then return end 
                local count = tonumber( getAccountData( account,"Wins" ) ) or 0  
                setAccountData( account,"Wins",count ) 
                setElementData( alivePlayers[1],'Wins', count ) 
                --outputChatBox ( "#FFA824The player " .. getPlayerName( alivePlayers[1] ) .. " won!", root, 255, 255, 255, true ) 
            end 
        else 
            local account = getPlayerAccount( source ) 
            if isGuestAccount( account ) then return end 
            local loses = tonumber( getAccountData( account,"Deaths" ) or 0 ) + 1 
            setAccountData( account,"Deaths", loses ) 
            setElementData( source,'Deaths', loses ) 
        end 
    end 
     
    function onPlayerLogin ( _, acc ) 
        if ( acc ) then 
            local wins = tonumber ( getAccountData ( account, "Wins" ) ) or 0 
            setElementData ( source, "Wins", wins ) 
        end 
    end 
    addEventHandler ( "onPlayerLogin",root, onPlayerLogin ) 
      
      
    addEventHandler( "stats", root, publicstatsinfo ) 
    addEventHandler( "onPlayerRaceWasted", root,DestructionWin ) 
     
     

Posted
function DestructionWin ( vehicle ) 
    local alivePlayers = getAlivePlayers ( ) 
    if ( #alivePlayers == 1 ) then 
        if isElement ( alivePlayers[1] ) then 
            local account = getPlayerAccount ( alivePlayers[1] ) 
            if isGuestAccount ( account ) then 
                return 
            end 
  
            local count = ( tonumber ( getAccountData ( account, "Wins" ) ) or 0 ) + 1 
            setAccountData ( account, "Wins", count ) 
            setElementData ( alivePlayers[1], 'Wins', count ) 
            --outputChatBox ( "#FFA824The player " .. getPlayerName( alivePlayers[1] ) .. " won!", root, 255, 255, 255, true ) 
        end 
    else 
        local account = getPlayerAccount ( source ) 
        if isGuestAccount ( account ) then 
            return 
        end 
  
        local loses = ( tonumber ( getAccountData( account,"Deaths" ) or 0 ) ) + 1 
        setAccountData ( account, "Deaths", loses ) 
        setElementData ( source, 'Deaths', loses ) 
    end 
end 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Is not even updating the 'Wins' element data?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
function DestructionWin ( vehicle ) 
    local alivePlayers = getAlivePlayers ( ) 
    if ( #alivePlayers == 1 ) then 
        outputChatBox ( "Passed check #1" ) 
        if isElement ( alivePlayers[1] ) then 
            outputChatBox ( "Passed check #2" ) 
            local account = getPlayerAccount ( alivePlayers[1] ) 
            if isGuestAccount ( account ) then 
                return 
            end 
            outputChatBox ( "Passed check #3" ) 
  
            local count = ( tonumber ( getAccountData ( account, "Wins" ) ) or 0 ) + 1 
            setAccountData ( account, "Wins", count ) 
            setElementData ( alivePlayers[1], 'Wins', count ) 
            --outputChatBox ( "#FFA824The player " .. getPlayerName( alivePlayers[1] ) .. " won!", root, 255, 255, 255, true ) 
        end 
    else 
        local account = getPlayerAccount ( source ) 
        if isGuestAccount ( account ) then 
            return 
        end 
  
        local loses = ( tonumber ( getAccountData( account,"Deaths" ) or 0 ) ) + 1 
        setAccountData ( account, "Deaths", loses ) 
        setElementData ( source, 'Deaths', loses ) 
    end 
end 

Post here what does it output to chat.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Mind telling us what was it?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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