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 )