Bleidex Posted February 15, 2011 Share Posted February 15, 2011 Hey everyone, i've got a big problem. Stats are working normally if you do login. But you need to reconnect if you are first time logged in otherwise stats dont save. also if someone neters the server noone get the win. how to fix that? addEvent("onMapStarting", true) IsRespawn = false function MapStarting(mapInfo, mapOptions, gameOptions) IsRespawn = (tostring(mapOptions["respawn"]) == "timelimit") end addEventHandler("onMapStarting", getRootElement(), MapStarting) function PlayerWasted( ammo, attacker, weapon, bodypart ) local alivePlayers = getAlivePlayers() if not IsRespawn then if #alivePlayers == 1 then if not isGuestAccount( getPlayerAccount ( alivePlayers[1] ) ) then local PlayerName = getPlayerName(alivePlayers[1]) local getPlayerAcc = getPlayerAccount ( alivePlayers[1] ) if (getPlayerAcc) then local Losers = getAccountData(getPlayerAcc, "Losers") local Wins1 = getAccountData(getPlayerAcc, "Wins") local Wins2 = tonumber(Wins1) + 1 setAccountData ( getPlayerAcc, "Wins", Wins2 ) setElementData(alivePlayers[1] ,"data.wins", Wins2) outputChatBox("* #FFFFFF" .. PlayerName .. "#0fc0fc won as last player alive! Totals DM/DD won: #FFFFFF" .. Wins2 .. " #0fc0fcof #FFFFFF" .. Losers .. "#0fc0fc.", getRootElement(), 255, 255, 255, true) -- Cash -- local getPlayerCash = getPlayerAccount ( alivePlayers[1] ) local Cash1 = getAccountData(getPlayerCash, "Cash") local Cash2 = 250 * getPlayerCount() setAccountData ( getPlayerCash, "Cash", Cash1 + Cash2 ) setElementData ( alivePlayers[1], "data.cash", Cash1 + Cash2 ) outputChatBox("* #FFFFFF" .. PlayerName .. "#0fc0fc got #FFFFFF" .. Cash2 .. "#0fc0fc$ for surviving!", getRootElement(), 255, 255, 255, true) -- Points -- local getPlayerPoints = getPlayerAccount ( alivePlayers[1] ) local Points1 = getAccountData(getPlayerCash, "Points") local Points2 = 4 * getPlayerCount() setAccountData ( getPlayerPoints, "Points", Points1 + Points2 ) setElementData ( alivePlayers[1], "data.points", Points1 + Points2 ) outputChatBox("* #FFFFFF" .. PlayerName .. "#0fc0fc got #FFFFFF" .. Points2 .. "#0fc0fc points! now has #FFFFFF" .. Points1 + Points2 .. "#0fc0fc!", getRootElement(), 255, 255, 255, true) end else outputChatBox("* #FFFFFF" .. getPlayerName( alivePlayers[1] ) .. "#0fc0fc won as last player alive!", getRootElement(), 255, 255, 255, true) end else local getPlayerAcc = getPlayerAccount ( source ) if not isGuestAccount( getPlayerAccount ( source ) ) then local Losers1 = getAccountData(getPlayerAcc, "Losers") local Losers2 = tonumber(Losers1) + 1 setAccountData ( getPlayerAcc, "Losers", Losers2 ) setElementData ( source, "data.lost", Losers1 + 1 ) end end end end addEventHandler ( "onPlayerWasted", getRootElement(), PlayerWasted ) function Logged() local getPlayerAcc = getPlayerAccount ( source ) local FalseAddSQL = getAccountData(getPlayerAcc, "AddSQL") local AddsSQL = getAccountData(getPlayerAcc, "AddSQL") if AddsSQL == "2.5" then outputChatBox("* #FFFFFF" .. getPlayerName( source ) .. "#0fc0fc has logged in and and he's ready to play!", getRootElement(), 255, 255, 255, true) else local Rank = "Beginner" local Wins = 0 local Losers = 0 local Points = 0 local Cash = 0 local Exp = 0 setAccountData(getPlayerAcc, "Rank", Rank) setAccountData(getPlayerAcc, "Wins", Wins) setAccountData(getPlayerAcc, "Losers", Losers) setAccountData(getPlayerAcc, "Points", Points) setAccountData(getPlayerAcc, "Cash", Cash) setAccountData(getPlayerAcc, "Exp", Exp) -- NO ANYMORE SET STATS ANYMORE setAccountData(getPlayerAcc, "AddSQL", "2.5") outputChatBox("* #FFFFFF" .. getPlayerName( source ) .. "#0fc0fc has logged in and he's ready to play for the first time!", getRootElement(), 255, 255, 255, true) end end addEventHandler("onPlayerLogin", getRootElement(), Logged) function stats(source) local playeracc = getPlayerAccount ( source ) local playercash = getAccountData(playeracc, "Cash") or 0 local playerpoints = getAccountData(playeracc, "Points") or 0 local playerwins = getAccountData(playeracc, "Wins") or 0 local playerlooses = getAccountData(playeracc, "Losers") or 0 if ( playeracc ) then outputChatBox ( "*" .. getPlayerName ( source ) .. " 's Stats: ", root, 0, 252, 255, false ) outputChatBox ( "* Cash Earned: " .. tonumber ( playercash ) .. " $ ", root, 0, 252, 255, false ) outputChatBox ( "* Points Earned: " .. tonumber ( playerpoints ) .. " Points", root, 0, 252, 255, false ) outputChatBox ( "* Wins: " .. tonumber ( playerwins ), root, 0, 252, 255, false) outputChatBox ( "* Looses: " .. tonumber ( playerlooses ), root, 0, 252, 255, false) end end addCommandHandler ( "stats", stats ) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now