Phiilip~* Posted September 10, 2012 Share Posted September 10, 2012 (edited) What is happening with my user panel, the wins are not counting... This error in debugscript 3: ERROR: Userpanel\Stats.lua:16: attempt to perform arithmetic on a nil value addEvent("onPlayerDDDMWin",true) IsNewVersion = "1.2" IsDDDMTrue = nil IsRespawn = false Players = getPlayerCount() Ratio = nil function MapStarting(mapInfo, mapOptions, gameOptions) IsRespawn = (tostring(mapOptions["respawn"]) == "timelimit") for id, player in ipairs(getElementsByType("player")) do local getPlayerAcc = getPlayerAccount ( player ) local getMapsPlayed = getAccountData ( getPlayerAcc, "MapsPlayed" ) local getMapsPlayed2 = tonumber(getMapsPlayed) + 1 setAccountData ( getPlayerAccount(player), "stopget", "false" ) setElementData ( player, "nowin", "true" ) setAccountData ( getPlayerAccount ( player ), "MapsPlayed", getMapsPlayed2 ) setElementData ( player, "data.mapsplayed", getMapsPlayed2 ) end IsDDDMTrue = (mapInfo.modename == "Destruction derby") end addEventHandler("onMapStarting", getRootElement(), MapStarting) function DDDMWin(winner) if IsDDDMTrue then if not isGuestAccount( getPlayerAccount ( winner ) ) then local PlayerName = getPlayerName( winner ) local getPlayerAcc = getPlayerAccount ( winner ) local mapsPlayed = getAccountData ( getPlayerAcc, "MapsPlayed" ) -- Stop setAccountData ( getPlayerAcc, "stopget", "true" ) -- Win local Losers = getAccountData(getPlayerAcc, "Losers") local Wins1 = getAccountData(getPlayerAcc, "Wins") local Wins2 = Wins1 + 1 setAccountData ( getPlayerAcc, "Wins", Wins2 ) setElementData(winner ,"data.wins", Wins2) if mapsPlayed == 0 then Ratio = 0 else Ratio = (tonumber(Wins1)/tonumber(mapsPlayed))*100 end outputChatBox("#00BFFF* #FFFFFF" .. PlayerName .. "#ABCDEF won as last player alive! Total DM/DD won: " .. Wins2 .. " of " .. Losers .. " lost (" .. string.format("%.2f", Ratio) .. "%)!", getRootElement(), 255, 255, 255, true) -- Cash -- local getPlayerCash = getPlayerAccount ( winner ) local Cash1 = getAccountData(getPlayerCash, "Cash") local Cash2 = 100 * Players setAccountData ( getPlayerCash, "Cash", Cash1 + Cash2 ) setElementData ( winner, "data.cash", Cash1 + Cash2 ) -- Points -- local getPlayerPoints = getPlayerAccount ( winner ) local Points1 = getAccountData(getPlayerCash, "Points") local Points2 = 2 * Players setAccountData ( getPlayerPoints, "Points", Points1 + Points2 ) setElementData ( winner, "data.points", Points1 + Points2 ) -- Losers local Losers1 = getAccountData(getPlayerAcc, "Losers") local Losers2 = Losers1 setAccountData (getPlayerAcc, "Losers", Losers2 ) setElementData(source, "data.lost", Losers2) outputChatBox("#00BFFF* #ABCDEFEarned points: " .. string.format("%.2f", Points2) .. " (Total: " .. string.format("%.2f", Points1 + Points2) .. ") Cash earned: " .. string.format("%.2f", Cash2) .. " (Total: " .. string.format("%.2f", Cash1 + Cash2) .. "$)", getRootElement(), 255, 255, 255, true) else outputChatBox("#00BFFF* #FFFFFF" .. getPlayerName( winner ) .. "#ABCDEF won as last player alive!", getRootElement(), 255, 255, 255, true) end end end addEventHandler("onPlayerDDDMWin",getRootElement(),DDDMWin) function DDDMLoser() local getPlayerAcc = getPlayerAccount ( source ) if not isGuestAccount( getPlayerAccount ( source ) ) then local Losers1 = getAccountData(getPlayerAcc, "Losers") local Losers2 = Losers1 + 1 setAccountData ( getPlayerAcc, "Losers", Losers2 ) setElementData( source, "data.lost", Losers2) local StopGet = getAccountData ( getPlayerAcc, "stopget") if StopGet == "false" then local Cash1 = getAccountData(getPlayerAcc, "Cash") local Cash2 = 250 * Players - 200 * Players setAccountData ( getPlayerAcc, "Cash", Cash1 + Cash2 ) setElementData ( source, "data.cash", Cash1 + Cash2 ) local Points1 = getAccountData(getPlayerAcc, "Points") local Points2 = 2 * Players - 1 * Players setAccountData ( getPlayerAcc, "Points", Points1 + Points2 ) setElementData ( source, "data.points", Points1 + Points2 ) outputChatBox("#ABCDEF* You got " .. Points2 .. " points and " .. Cash2 .. " cash!", source, 255, 119, 0, true) UpdateRankDied(source) end end end addEventHandler ( "onPlayerWasted", getRootElement(), DDDMLoser ) function PlayerJoined() setElementData ( source, "nowin", "false" ) end addEventHandler ( "onPlayerJoin", getRootElement(), PlayerJoined ) function AchEarnedDate ( ) local time = getRealTime ( ) -- local year = time.year local month = time.month local dates = time.monthday --outputChatBox ( "TestAch:" .. date .. " / " .. month .. " / " .. year ) return dates .. "/" .. month .. "/2012" end function Logged() local getPlayerAcc = getPlayerAccount ( source ) local FalseAddSQL = getAccountData(getPlayerAcc, "AddSQL") local AddsSQL = getAccountData(getPlayerAcc, "AddSQL") if AddsSQL == IsNewVersion then outputChatBox("#00BFFF* #FFFFFF" .. getPlayerName( source ) .. "#00BFFF has logged in and and he's ready to play!", getRootElement(), 255, 255, 255, true) -- User Panel local PlayerName = getPlayerName(source) local getPlayerAcc = getPlayerAccount ( source ) local Cash = getAccountData(getPlayerAcc, "Cash") -- Cash local Ranking = getAccountData(getPlayerAcc, "Rank") -- Ranking local Points = getAccountData(getPlayerAcc, "Points") -- Points local Exp = getAccountData(getPlayerAcc, "Exp") -- Exp local Wins = getAccountData(getPlayerAcc, "Wins") -- Wins local MapsPlayed = getAccountData(getPlayerAcc, "MapsPlayed") -- Maps Played local Loser = getAccountData(getPlayerAcc, "Losers") -- Losers local AchEarned = getAccountData(getPlayerAcc, "AchEarned") -- Achievements earned local AchPoints = getAccountData(getPlayerAcc, "AchPoints") -- Achievement points ...and another problem local Error = "Sorry, you do not have money!" local ErrorDead = "Sorry, you are not alive!" local GuestError = "Sorry, you are a guest. Please register and login!" local Fix = 10000 local Nitro = 5000 local Flip = 5000 local buy50Pts = 10000 local buy100Pts = 25000 function Shop(player, commands, commands2) local Car = getPedOccupiedVehicle(player) local getAcc = getPlayerAccount ( player ) local getCashPlayer = getAccountData(getAcc, "Cash") local getPointsPlayer = getAccountData(getAcc, "Points") if not isGuestAccount( getPlayerAccount ( player ) ) then if commands2 == "fix" then if not ( isPedDead ( player ) ) then if getCashPlayer >= Fix then outputChatBox("#00BFFF* #FFFFFF" .. getPlayerName(player) .. " #00BFFFfixed his car for #FFFFFF" .. Fix .. "#00BFFF$!" , getRootElement(), 255, 255, 255, true) setAccountData ( getAcc, "Cash", getCashPlayer - Fix ) setElementData(source, "data.cash", getCashPlayer - Fix) fixVehicle ( Car ) else outputChatBox(Error, player) end else outputChatBox(ErrorDead, player, 255, 0, 0, true) end elseif commands2 == "nitro" then if not ( isPedDead ( player ) ) then if getCashPlayer >= Fix then outputChatBox("#00BFFF* #FFFFFF" .. getPlayerName(player) .. " #00BFFFhas bought nitro for #FFFFFF" .. Nitro .. "#00BFFF$!" , getRootElement(), 255, 255, 255, true) setAccountData ( getAcc, "Cash", getCashPlayer - Nitro ) setElementData(source, "data.cash", getCashPlayer - Nitro) addVehicleUpgrade( Car, 1010 ) else outputChatBox(Error, player, 255, 0, 0, true) end else outputChatBox(ErrorDead, player, 255, 0, 0, true) end elseif commands2 == "flip" then if not ( isPedDead ( player ) ) then if getCashPlayer >= Fix then local rX,rY,rZ = getVehicleRotation(Car) outputChatBox("#00BFFF* #FFFFFF" .. getPlayerName(player) .. " #00BFFFhas flipped for #FFFFFF" .. Flip .. "#00BFFF$!" , getRootElement(), 255, 255, 255, true) setAccountData ( getAcc, "Cash", getCashPlayer - Flip ) setElementData(source, "data.cash", getCashPlayer - Flip) setVehicleRotation(Car, 0, 0, (rX > 90 and rX < 270) and (rZ + 180) or rZ) else outputChatBox(Error, player, 255, 0, 0, true) end else outputChatBox(Error, player, 255, 0, 0, true) end elseif commands2 == "50pts" then if getCashPlayer >= buy50Pts then outputChatBox("#00BFFF* #FFFFFF" .. getPlayerName(player) .. " #00BFFFhas bought 50 points for #FFFFFF" .. buy50Pts .. "#00BFFF$!" , getRootElement(), 255, 255, 255, true) setAccountData ( getAcc, "Cash", getCashPlayer - buy50Pts ) setElementData ( source, "data.cash", getCashPlayer - buy50Pts ) setAccountData ( getAcc, "Points", getPointsPlayer + 50 ) setElementData ( source, "data.points", getPointsPlayer + 50 ) else outputChatBox(Error, player, 255, 0, 0 ) end elseif commands2 == "100pts" then if getCashPlayer >= buy100Pts then outputChatBox("#00BFFF* #FFFFFF" .. getPlayerName(player) .. " #00BFFFhas bought 100 points for #FFFFFF" .. buy100Pts .. "#00BFFF$!" , getRootElement(), 255, 255, 255, true) setAccountData ( getAcc, "Cash", getCashPlayer - buy100Pts ) setElementData ( source, "data.cash", getCashPlayer - buy100Pts ) setAccountData ( getAcc, "Points", getPointsPlayer + 100 ) setElementData ( source, "data.points", getPointsPlayer + 100 ) else outputChatBox(Error, player, 255, 0, 0 ) end end else outputChatBox(GuestError, player, 255, 0, 0, true) end end addCommandHandler("buy",Shop) outputChatBox("#00BFFF* #FFFFFF" .. getPlayerName(player) .. " #00BFFFhas bought 50 points for #FFFFFF" .. buy50Pts .. "#00BFFF$!" , getRootElement(), 255, 255, 255, true) and outputChatBox("#00BFFF* #FFFFFF" .. getPlayerName(player) .. " #00BFFFhas bought 100 points for #FFFFFF" .. buy100Pts .. "#00BFFF$!" , getRootElement(), 255, 255, 255, true) Is not returning after buying points, but fix, nitro and flip return normally Can someone help me? Tks Edited September 12, 2012 by Guest Link to comment
robhol Posted September 12, 2012 Share Posted September 12, 2012 The line numbers are off, we need to know where the error happens. Link to comment
Phiilip~* Posted September 12, 2012 Author Share Posted September 12, 2012 The line numbers are off, we need to know where the error happens. ERROR: Userpanel\Stats.lua:16: attempt to perform arithmetic on a nil value debugscript 3 showed an error in line 16 This is the line 16 setElementData ( player, "nowin", "true" ) Tks Link to comment
robhol Posted September 12, 2012 Share Posted September 12, 2012 And since no arithmetic is happening anywhere in that line, it's obviously not the right one. Link to comment
Phiilip~* Posted September 12, 2012 Author Share Posted September 12, 2012 I don't understand what you need to try identify this problem? Link to comment
Cadu12 Posted September 12, 2012 Share Posted September 12, 2012 Show your meta, please. Link to comment
Phiilip~* Posted September 13, 2012 Author Share Posted September 13, 2012 Show your meta, please. Tks Link to comment
TAPL Posted September 13, 2012 Share Posted September 13, 2012 Your problem is getAccountData return nil/false i suggest to try this put (or 0) for every getAccountData Example: This local getMapsPlayed = getAccountData ( getPlayerAcc, "MapsPlayed" ) Will be local getMapsPlayed = getAccountData ( getPlayerAcc, "MapsPlayed" ) or 0 Link to comment
Phiilip~* Posted September 13, 2012 Author Share Posted September 13, 2012 Your problem is getAccountData return nil/falsei suggest to try this put (or 0) for every getAccountData Example: This local getMapsPlayed = getAccountData ( getPlayerAcc, "MapsPlayed" ) Will be local getMapsPlayed = getAccountData ( getPlayerAcc, "MapsPlayed" ) or 0 Not working yet Link to comment
TAPL Posted September 13, 2012 Share Posted September 13, 2012 Post all code in file Stats.lua Link to comment
Phiilip~* Posted September 13, 2012 Author Share Posted September 13, 2012 addEvent("onMapStarting", true) addEvent("onPlayerDDDMWin",true) IsNewVersion = "1.2" IsDDDMTrue = nil IsRespawn = false Players = getPlayerCount() Ratio = nil function MapStarting(mapInfo, mapOptions, gameOptions) IsRespawn = (tostring(mapOptions["respawn"]) == "timelimit") for id, player in ipairs(getElementsByType("player")) do local getPlayerAcc = getPlayerAccount ( player ) local getMapsPlayed = getAccountData ( getPlayerAcc, "MapsPlayed" ) local getMapsPlayed2 = tonumber(getMapsPlayed) + 1 setAccountData ( getPlayerAccount(player), "stopget", "false" ) setElementData ( player, "nowin", "true" ) setAccountData ( getPlayerAccount ( player ), "MapsPlayed", getMapsPlayed2 ) setElementData ( player, "data.mapsplayed", getMapsPlayed2 ) end -- Sets True for DM/DD IsDDDMTrue = (mapInfo.modename == "Destruction derby") end addEventHandler("onMapStarting", getRootElement(), MapStarting) function DDDMWin(winner) if IsDDDMTrue then if not isGuestAccount( getPlayerAccount ( winner ) ) then local PlayerName = getPlayerName( winner ) local getPlayerAcc = getPlayerAccount ( winner ) local mapsPlayed = getAccountData ( getPlayerAcc, "MapsPlayed" ) -- Stop setAccountData ( getPlayerAcc, "stopget", "true" ) -- Win local Losers = getAccountData(getPlayerAcc, "Losers") local Wins1 = getAccountData(getPlayerAcc, "Wins") local Wins2 = Wins1 + 1 setAccountData ( getPlayerAcc, "Wins", Wins2 ) setElementData(winner ,"data.wins", Wins2) if mapsPlayed == 0 then Ratio = 0 else Ratio = (tonumber(Wins1)/tonumber(mapsPlayed))*100 end outputChatBox("#00BFFF* #FFFFFF" .. PlayerName .. "#ABCDEF won as last player alive! Total DM/DD won: " .. Wins2 .. " of " .. Losers .. " lost (" .. string.format("%.2f", Ratio) .. "%)!", getRootElement(), 255, 255, 255, true) -- Cash -- local getPlayerCash = getPlayerAccount ( winner ) local Cash1 = getAccountData(getPlayerCash, "Cash") local Cash2 = 100 * Players setAccountData ( getPlayerCash, "Cash", Cash1 + Cash2 ) setElementData ( winner, "data.cash", Cash1 + Cash2 ) -- Points -- local getPlayerPoints = getPlayerAccount ( winner ) local Points1 = getAccountData(getPlayerCash, "Points") local Points2 = 2 * Players setAccountData ( getPlayerPoints, "Points", Points1 + Points2 ) setElementData ( winner, "data.points", Points1 + Points2 ) -- Losers local Losers1 = getAccountData(getPlayerAcc, "Losers") local Losers2 = Losers1 setAccountData (getPlayerAcc, "Losers", Losers2 ) setElementData(source, "data.lost", Losers2) outputChatBox("#00BFFF* #ABCDEFEarned points: " .. string.format("%.2f", Points2) .. " (Total: " .. string.format("%.2f", Points1 + Points2) .. ") Cash earned: " .. string.format("%.2f", Cash2) .. " (Total: " .. string.format("%.2f", Cash1 + Cash2) .. "$)", getRootElement(), 255, 255, 255, true) else outputChatBox("#00BFFF* #FFFFFF" .. getPlayerName( winner ) .. "#ABCDEF won as last player alive!", getRootElement(), 255, 255, 255, true) end end end addEventHandler("onPlayerDDDMWin",getRootElement(),DDDMWin) function DDDMLoser() local getPlayerAcc = getPlayerAccount ( source ) if not isGuestAccount( getPlayerAccount ( source ) ) then local Losers1 = getAccountData(getPlayerAcc, "Losers") local Losers2 = Losers1 + 1 setAccountData ( getPlayerAcc, "Losers", Losers2 ) setElementData( source, "data.lost", Losers2) local StopGet = getAccountData ( getPlayerAcc, "stopget") if StopGet == "false" then local Cash1 = getAccountData(getPlayerAcc, "Cash") local Cash2 = 250 * Players - 200 * Players setAccountData ( getPlayerAcc, "Cash", Cash1 + Cash2 ) setElementData ( source, "data.cash", Cash1 + Cash2 ) local Points1 = getAccountData(getPlayerAcc, "Points") local Points2 = 2 * Players - 1 * Players setAccountData ( getPlayerAcc, "Points", Points1 + Points2 ) setElementData ( source, "data.points", Points1 + Points2 ) outputChatBox("#ABCDEF* You got " .. Points2 .. " points and " .. Cash2 .. " cash!", source, 255, 119, 0, true) UpdateRankDied(source) end end end addEventHandler ( "onPlayerWasted", getRootElement(), DDDMLoser ) function PlayerJoined() setElementData ( source, "nowin", "false" ) end addEventHandler ( "onPlayerJoin", getRootElement(), PlayerJoined ) function AchEarnedDate ( ) local time = getRealTime ( ) -- local year = time.year -- we don't need it cause it's bugged local month = time.month local dates = time.monthday --outputChatBox ( "TestAch:" .. date .. " / " .. month .. " / " .. year ) -- this a test please change it for userpanel return dates .. "/" .. month .. "/2011" end function Logged() local getPlayerAcc = getPlayerAccount ( source ) local FalseAddSQL = getAccountData(getPlayerAcc, "AddSQL") local AddsSQL = getAccountData(getPlayerAcc, "AddSQL") if AddsSQL == IsNewVersion then outputChatBox("#00BFFF* #FFFFFF" .. getPlayerName( source ) .. "#00BFFF has logged in and and he's ready to play!", getRootElement(), 255, 255, 255, true) -- User Panel local PlayerName = getPlayerName(source) local getPlayerAcc = getPlayerAccount ( source ) local Cash = getAccountData(getPlayerAcc, "Cash") -- Cash local Ranking = getAccountData(getPlayerAcc, "Rank") -- Ranking local Points = getAccountData(getPlayerAcc, "Points") -- Points local Exp = getAccountData(getPlayerAcc, "Exp") -- Exp local Wins = getAccountData(getPlayerAcc, "Wins") -- Wins local MapsPlayed = getAccountData(getPlayerAcc, "MapsPlayed") -- Maps Played local Loser = getAccountData(getPlayerAcc, "Losers") -- Losers local AchEarned = getAccountData(getPlayerAcc, "AchEarned") -- Achievements earned local AchPoints = getAccountData(getPlayerAcc, "AchPoints") -- Achievement points local Ach1 = getAccountData(getPlayerAcc, "Ach1") -- Ach #1 local Ach2 = getAccountData(getPlayerAcc, "Ach2") -- Ach #2 local Ach3 = getAccountData(getPlayerAcc, "Ach3") -- Ach #3 local Ach4 = getAccountData(getPlayerAcc, "Ach4") -- Ach #4 local Ach5 = getAccountData(getPlayerAcc, "Ach5") -- Ach #5 local Ach6 = getAccountData(getPlayerAcc, "Ach6") -- Ach #6 local Ach7 = getAccountData(getPlayerAcc, "Ach7") -- Ach #7 local Ach8 = getAccountData(getPlayerAcc, "Ach8") -- Ach #8 local Ach9 = getAccountData(getPlayerAcc, "Ach9") -- Ach #9 local Ach10 = getAccountData(getPlayerAcc, "Ach10") -- Ach #10 local Ach11 = getAccountData(getPlayerAcc, "Ach11") -- Ach #11 local Ach12 = getAccountData(getPlayerAcc, "Ach12") -- Ach #12 local Ach13 = getAccountData(getPlayerAcc, "Ach13") -- Ach #13 local Ach14 = getAccountData(getPlayerAcc, "Ach14") -- Ach #14 local Ach15 = getAccountData(getPlayerAcc, "Ach15") -- Ach #15 local Ach16 = getAccountData(getPlayerAcc, "Ach16") -- Ach #16 local Ach17 = getAccountData(getPlayerAcc, "Ach17") -- Ach #17 local Ach18 = getAccountData(getPlayerAcc, "Ach18") -- Ach #18 local Ach19 = getAccountData(getPlayerAcc, "Ach19") -- Ach #19 local Ach20 = getAccountData(getPlayerAcc, "Ach20") -- Ach #20 local Ach1Time = getAccountData(getPlayerAcc, "Ach1Time") local Ach2Time = getAccountData(getPlayerAcc, "Ach2Time") local Ach3Time = getAccountData(getPlayerAcc, "Ach3Time") local Ach4Time = getAccountData(getPlayerAcc, "Ach4Time") local Ach5Time = getAccountData(getPlayerAcc, "Ach5Time") local Ach6Time = getAccountData(getPlayerAcc, "Ach6Time") local Ach7Time = getAccountData(getPlayerAcc, "Ach7Time") local Ach8Time = getAccountData(getPlayerAcc, "Ach8Time") local Ach9Time = getAccountData(getPlayerAcc, "Ach9Time") local Ach10Time = getAccountData(getPlayerAcc, "Ach10Time") local Ach11Time = getAccountData(getPlayerAcc, "Ach11Time") local Ach12Time = getAccountData(getPlayerAcc, "Ach12Time") local Ach13Time = getAccountData(getPlayerAcc, "Ach13Time") local Ach14Time = getAccountData(getPlayerAcc, "Ach14Time") local Ach15Time = getAccountData(getPlayerAcc, "Ach15Time") local Ach16Time = getAccountData(getPlayerAcc, "Ach16Time") local Ach17Time = getAccountData(getPlayerAcc, "Ach17Time") local Ach18Time = getAccountData(getPlayerAcc, "Ach18Time") local Ach19Time = getAccountData(getPlayerAcc, "Ach19Time") local Ach20Time = getAccountData(getPlayerAcc, "Ach20Time") setElementData(source, "data.rank", Ranking) setElementData(source, "data.wins", Wins) setElementData(source, "data.lost", Loser) setElementData(source, "data.points", Points) setElementData(source, "data.cash", Cash) setElementData(source, "data.exp", Exp) setElementData(source, "data.mapsplayed", MapsPlayed) setElementData(source, "data.achearned", AchEarned) setElementData(source, "data.achpoints", AchPoints) setElementData(source, "data.ach1", Ach1) setElementData(source, "data.ach2", Ach2) setElementData(source, "data.ach3", Ach3) setElementData(source, "data.ach4", Ach4) setElementData(source, "data.ach5", Ach5) setElementData(source, "data.ach6", Ach6) setElementData(source, "data.ach7", Ach7) setElementData(source, "data.ach8", Ach8) setElementData(source, "data.ach9", Ach9) setElementData(source, "data.ach10", Ach10) setElementData(source, "data.ach11", Ach11) setElementData(source, "data.ach12", Ach12) setElementData(source, "data.ach13", Ach13) setElementData(source, "data.ach14", Ach14) setElementData(source, "data.ach15", Ach15) setElementData(source, "data.ach16", Ach16) setElementData(source, "data.ach17", Ach17) setElementData(source, "data.ach18", Ach18) setElementData(source, "data.ach19", Ach19) setElementData(source, "data.ach20", Ach20) -- Anti-Guest setElementData(source, "data.guest", "true") -- Time setAccountData ( getPlayerAcc, "Ach1Time", Ach1Time ) setElementData ( source, "data.ach1time", Ach1Time ) setAccountData ( getPlayerAcc, "Ach2Time", Ach2Time ) setElementData ( source, "data.ach2time", Ach2Time ) setAccountData ( getPlayerAcc, "Ach3Time", Ach3Time ) setElementData ( source, "data.ach3time", Ach3Time ) setAccountData ( getPlayerAcc, "Ach4Time", Ach4Time ) setElementData ( source, "data.ach4time", Ach4Time ) setAccountData ( getPlayerAcc, "Ach5Time", Ach5Time ) setElementData ( source, "data.ach5time", Ach5Time ) setAccountData ( getPlayerAcc, "Ach6Time", Ach6Time ) setElementData ( source, "data.ach6time", Ach6Time ) setAccountData ( getPlayerAcc, "Ach7Time", Ach7Time ) setElementData ( source, "data.ach7time", Ach7Time ) setAccountData ( getPlayerAcc, "Ach8Time", Ach8Time ) setElementData ( source, "data.ach8time", Ach8Time ) setAccountData ( getPlayerAcc, "Ach9Time", Ach9Time ) setElementData ( source, "data.ach9time", Ach9Time ) setAccountData ( getPlayerAcc, "Ach10Time", Ach10Time ) setElementData ( source, "data.ach11time", Ach11Time ) setElementData ( source, "data.ach12time", Ach12Time ) setElementData ( source, "data.ach13time", Ach13Time ) setElementData ( source, "data.ach14time", Ach14Time ) setElementData ( source, "data.ach15time", Ach15Time ) setElementData ( source, "data.ach16time", Ach16Time ) setElementData ( source, "data.ach17time", Ach17Time ) setElementData ( source, "data.ach18time", Ach18Time ) setElementData ( source, "data.ach19time", Ach19Time ) setElementData ( source, "data.ach20time", Ach20Time ) -- Bet setElementData ( source, "betonly1", "false" ) -- Stop get setAccountData ( getPlayerAcc, "stopget", "false" ) else local Rank = "Beginner Level 1" local Wins = 0 local Losers = 0 local Points = 0 local Cash = 0 local Exp = 1 local MapsPlayed = 0 local AchEarned = 0 local AchPoints = 0 local Ach1 = "false" local Ach2 = "false" local Ach3 = "false" local Ach4 = "false" local Ach5 = "false" local Ach6 = "false" local Ach7 = "false" local Ach8 = "false" local Ach9 = "false" local Ach10 = "false" local Ach11 = "false" local Ach12 = "false" local Ach13 = "false" local Ach14 = "false" local Ach15 = "false" local Ach16 = "false" local Ach17 = "false" local Ach18 = "false" local Ach19 = "false" local Ach20 = "false" setAccountData(getPlayerAcc, "Rank", Rank) setAccountData(getPlayerAcc, "Wins", Wins) setAccountData(getPlayerAcc, "Losers", Losers) setAccountData(getPlayerAcc, "Points", Points) setAccountData(getPlayerAcc, "Cash", Cash) setAccountData(getPlayerAcc, "Exp", Exp) setAccountData(getPlayerAcc, "MapsPlayed", MapsPlayed) setAccountData(getPlayerAcc, "AchEarned", AchEarned) -- Achievements earned setAccountData(getPlayerAcc, "AchPoints", AchPoints) -- Achievement points setAccountData(getPlayerAcc, "Ach1", Ach1) -- Ach #1 setAccountData(getPlayerAcc, "Ach2", Ach2) -- Ach #2 setAccountData(getPlayerAcc, "Ach3", Ach3) -- Ach #3 setAccountData(getPlayerAcc, "Ach4", Ach4) -- Ach #4 setAccountData(getPlayerAcc, "Ach5", Ach5) -- Ach #5 setAccountData(getPlayerAcc, "Ach6", Ach6) -- Ach #6 setAccountData(getPlayerAcc, "Ach7", Ach7) -- Ach #7 setAccountData(getPlayerAcc, "Ach8", Ach8) -- Ach #8 setAccountData(getPlayerAcc, "Ach9", Ach9) -- Ach #9 setAccountData(getPlayerAcc, "Ach10", Ach10) -- Ach #10 setAccountData(getPlayerAcc, "Ach11", Ach11) -- Ach #11 setAccountData(getPlayerAcc, "Ach12", Ach12) -- Ach #12 setAccountData(getPlayerAcc, "Ach13", Ach13) -- Ach #13 setAccountData(getPlayerAcc, "Ach14", Ach14) -- Ach #14 setAccountData(getPlayerAcc, "Ach15", Ach15) -- Ach #15 setAccountData(getPlayerAcc, "Ach16", Ach16) -- Ach #16 setAccountData(getPlayerAcc, "Ach17", Ach17) -- Ach #17 setAccountData(getPlayerAcc, "Ach18", Ach18) -- Ach #18 setAccountData(getPlayerAcc, "Ach19", Ach19) -- Ach #19 setAccountData(getPlayerAcc, "Ach20", Ach20) -- Ach #20 -- NO ANYMORE SET STATS ANYMORE setAccountData(getPlayerAcc, "AddSQL", IsNewVersion) outputChatBox("#00BFFF* #FFFFFF" .. getPlayerName( source ) .. "#00BFFF has logged in and he's ready to play for the first time!", getRootElement(), 255, 255, 255, true) -- Anti-Guest setElementData(source, "data.guest", "true") -- Updated setElementData(source, "data.rank", Rank) setElementData(source, "data.wins", Wins) setElementData(source, "data.lost", Losers) setElementData(source, "data.points", Points) setElementData(source, "data.cash", Cash) setElementData(source, "data.exp", Exp) setElementData(source, "data.mapsplayed", MapsPlayed) setElementData(source, "data.achearned", AchEarned) setElementData(source, "data.achpoints", AchPoints) setElementData(source, "data.ach1", Ach1) setElementData(source, "data.ach2", Ach2) setElementData(source, "data.ach3", Ach3) setElementData(source, "data.ach4", Ach4) setElementData(source, "data.ach5", Ach5) setElementData(source, "data.ach6", Ach6) setElementData(source, "data.ach7", Ach7) setElementData(source, "data.ach8", Ach8) setElementData(source, "data.ach9", Ach9) setElementData(source, "data.ach10", Ach10) setElementData(source, "data.ach11", Ach11) setElementData(source, "data.ach12", Ach12) setElementData(source, "data.ach13", Ach13) setElementData(source, "data.ach14", Ach14) setElementData(source, "data.ach15", Ach15) setElementData(source, "data.ach16", Ach16) setElementData(source, "data.ach17", Ach17) setElementData(source, "data.ach18", Ach18) setElementData(source, "data.ach19", Ach19) setElementData(source, "data.ach20", Ach20) -- Time setAccountData ( getPlayerAcc, "Ach1Time", AchEarnedDate() ) setElementData ( source, "data.ach1time", AchEarnedDate() ) setAccountData ( getPlayerAcc, "Ach2Time", AchEarnedDate() ) setElementData ( source, "data.ach2time", AchEarnedDate() ) setAccountData ( getPlayerAcc, "Ach3Time", AchEarnedDate() ) setElementData ( source, "data.ach3time", AchEarnedDate() ) setAccountData ( getPlayerAcc, "Ach4Time", AchEarnedDate() ) setElementData ( source, "data.ach4time", AchEarnedDate() ) setAccountData ( getPlayerAcc, "Ach5Time", AchEarnedDate() ) setElementData ( source, "data.ach5time", AchEarnedDate() ) setAccountData ( getPlayerAcc, "Ach6Time", AchEarnedDate() ) setElementData ( source, "data.ach6time", AchEarnedDate() ) setAccountData ( getPlayerAcc, "Ach7Time", AchEarnedDate() ) setElementData ( source, "data.ach7time", AchEarnedDate() ) setAccountData ( getPlayerAcc, "Ach8Time", AchEarnedDate() ) setElementData ( source, "data.ach8time", AchEarnedDate() ) setAccountData ( getPlayerAcc, "Ach9Time", AchEarnedDate() ) setElementData ( source, "data.ach9time", AchEarnedDate() ) setAccountData ( getPlayerAcc, "Ach10Time", AchEarnedDate() ) setElementData ( source, "data.ach10time", AchEarnedDate() ) setAccountData ( getPlayerAcc, "Ach11Time", AchEarnedDate() ) setAccountData ( getPlayerAcc, "Ach12Time", AchEarnedDate() ) setAccountData ( getPlayerAcc, "Ach13Time", AchEarnedDate() ) setAccountData ( getPlayerAcc, "Ach14Time", AchEarnedDate() ) setAccountData ( getPlayerAcc, "Ach15Time", AchEarnedDate() ) setAccountData ( getPlayerAcc, "Ach16Time", AchEarnedDate() ) setAccountData ( getPlayerAcc, "Ach17Time", AchEarnedDate() ) setAccountData ( getPlayerAcc, "Ach18Time", AchEarnedDate() ) setAccountData ( getPlayerAcc, "Ach19Time", AchEarnedDate() ) setAccountData ( getPlayerAcc, "Ach20Time", AchEarnedDate() ) setElementData ( source, "data.ach11time", AchEarnedDate() ) setElementData ( source, "data.ach12time", AchEarnedDate() ) setElementData ( source, "data.ach13time", AchEarnedDate() ) setElementData ( source, "data.ach14time", AchEarnedDate() ) setElementData ( source, "data.ach15time", AchEarnedDate() ) setElementData ( source, "data.ach16time", AchEarnedDate() ) setElementData ( source, "data.ach17time", AchEarnedDate() ) setElementData ( source, "data.ach18time", AchEarnedDate() ) setElementData ( source, "data.ach19time", AchEarnedDate() ) setElementData ( source, "data.ach20time", AchEarnedDate() ) -- Bet setElementData ( source, "betonly1", "false" ) -- Stop get setAccountData ( getPlayerAcc, "stopget", "false" ) end -- createBlipAttachedTo(source, 0, 2, 255, 0, 0, 255) end addEventHandler("onPlayerLogin", getRootElement(), Logged) function Logouted() setElementData(source, "data.guest", "false") end addEventHandler("onPlayerLogout",getRootElement(),Logouted) function getPlayerWildcardNoColor(namePart) namePart = string.lower(namePart) local bestaccuracy = 0 local foundPlayer, b, e for _,player in ipairs(getElementsByType("player")) do b,e = string.find(string.lower(string.gsub(getPlayerName(player), "#%x%x%x%x%x%x", "")), namePart) if b and e then if e-b > bestaccuracy then bestaccuracy = e-b foundPlayer = player end end end if (foundPlayer) then return foundPlayer else return false end end addCommandHandler("donate", function(source, cmd, player, amount) local target = player local account = getPlayerAccount(source) if not (isGuestAccount(account)) then if (target) then if (amount) then local targetPlayer = getPlayerWildcardNoColor(target) local amount = math.floor(tonumber(amount)) if (targetPlayer) then local targetAccount = getPlayerAccount(targetPlayer) if not (isGuestAccount(targetAccount)) then if not (source == targetPlayer) then if (amount > 0) then local sourceCash = getAccountData(account, "Cash") local targetCash = getAccountData(targetAccount, "Cash") if (tonumber(sourceCash) > amount) then setTimer(outputChatBox,50,1,"#00BFFF* #FFFFFF"..getPlayerName(source).. " #ABCDEFdonated " ..tostring(amount).. "$ to "..getPlayerName(targetPlayer).."#ABCDEF!", getRootElement(), 255, 255, 255, true) setAccountData(account, "Cash", sourceCash-amount) setAccountData(targetAccount, "Cash", targetCash+amount) else outputChatBox("#00BFFF* #ABCDEFSorry but you don't that much money that you want to donate!", source, 255, 255, 255, true) end else outputChatBox("#00BFFF* #ABCDEFInvalid number! Please enter a number > 0!", source, 255, 255, 255, true) end else outputChatBox("#00BFFF* #ABCDEFYour can't donate money to yourself!", source, 255, 255, 255, true) end else outputChatBox("", source, 255, 255, 255, true) end else outputChatBox("#00BFFF* #ABCDEFCould not find player!", source, 255, 255, 255, true) end else outputChatBox("#00BFFF* #ABCDEFError: Please enter an amount! SYNTAX: /donate [player] [amount]", source, 255, 255, 255, true) end else outputChatBox("#00BFFF* #ABCDEFError: Please enter a player name! SYNTAX: /donate [player] [amount]", source, 255, 255, 255, true) end else outputChatBox("", source, 255, 255, 255, true) end end Link to comment
TAPL Posted September 13, 2012 Share Posted September 13, 2012 Where is or 0 ? so this is line 16 local getMapsPlayed2 = tonumber(getMapsPlayed) + 1 i guess getMapsPlayed is return false/nil Change this local getMapsPlayed = getAccountData ( getPlayerAcc, "MapsPlayed" ) to local getMapsPlayed = getAccountData ( getPlayerAcc, "MapsPlayed" ) or 0 Link to comment
Phiilip~* Posted September 13, 2012 Author Share Posted September 13, 2012 Where is or 0 ?so this is line 16 local getMapsPlayed2 = tonumber(getMapsPlayed) + 1 i guess getMapsPlayed is return false/nil Change this local getMapsPlayed = getAccountData ( getPlayerAcc, "MapsPlayed" ) to local getMapsPlayed = getAccountData ( getPlayerAcc, "MapsPlayed" ) or 0 Unsuccessfully Link to comment
TAPL Posted September 13, 2012 Share Posted September 13, 2012 really? What does debugscript 3 say? Link to comment
Phiilip~* Posted September 13, 2012 Author Share Posted September 13, 2012 In 'Achievements.lua' [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:30: Bad argument @ 'getPlayerName' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:31: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:58: Bad argument @ 'getPlayerName' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:59: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:86: Bad argument @ 'getPlayerName' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:87: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:114: Bad argument @ 'getPlayerName' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:115: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:142: Bad argument @ 'getPlayerName' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:143: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:170: Bad argument @ 'getPlayerName' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:171: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:198: Bad argument @ 'getPlayerName' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:199: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:226: Bad argument @ 'getPlayerName' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:227: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:254: Bad argument @ 'getPlayerName' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:255: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:282: Bad argument @ 'getPlayerName' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:283: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:310: Bad argument @ 'getPlayerName' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:311: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:338: Bad argument @ 'getPlayerName' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:339: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:366: Bad argument @ 'getPlayerName' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:367: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:394: Bad argument @ 'getPlayerName' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:395: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:422: Bad argument @ 'getPlayerName' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:423: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:450: Bad argument @ 'getPlayerName' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:451: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:478: Bad argument @ 'getPlayerName' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:479: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:506: Bad argument @ 'getPlayerName' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:507: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:534: Bad argument @ 'getPlayerName' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:535: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:562: Bad argument @ 'getPlayerName' [Expected element at argument 1, got nil] [2012-09-13 12:05:40] WARNING: Userpanel\Achievements.lua:563: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] In 'Player.lua' [2012-09-13 11:58:26] WARNING: Userpanel\Player.lua:110: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [2012-09-13 11:58:26] WARNING: Userpanel\Player.lua:110: Bad argument @ 'isGuestAccount' [Expected account at argument 1, got boolean] [2012-09-13 11:58:26] WARNING: Userpanel\Player.lua:111: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [2012-09-13 11:58:26] WARNING: Userpanel\Player.lua:112: Bad argument @ 'getAccountData' [Expected account at argument 1, got boolean] [2012-09-13 11:58:26] WARNING: Userpanel\Player.lua:113: Bad argument @ 'getAccountData' [Expected account at argument 1, got boolean] [2012-09-13 11:58:26] WARNING: Userpanel\Player.lua:114: Bad argument @ 'getAccountData' [Expected account at argument 1, got boolean] [2012-09-13 11:58:26] WARNING: Userpanel\Player.lua:115: Bad argument @ 'getAccountData' [Expected account at argument 1, got boolean] [2012-09-13 11:58:26] WARNING: Userpanel\Player.lua:116: Bad argument @ 'getAccountData' [Expected account at argument 1, got boolean] [2012-09-13 11:58:26] WARNING: Userpanel\Player.lua:117: Bad argument @ 'getPlayerName' [Expected element at argument 1, got nil] [2012-09-13 11:58:26] ERROR: Userpanel\Player.lua:117: attempt to concatenate a boolean value [2012-09-13 11:58:29] WARNING: Userpanel\Player.lua:110: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [2012-09-13 11:58:29] WARNING: Userpanel\Player.lua:110: Bad argument @ 'isGuestAccount' [Expected account at argument 1, got boolean] [2012-09-13 11:58:29] WARNING: Userpanel\Player.lua:111: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] [2012-09-13 11:58:29] WARNING: Userpanel\Player.lua:112: Bad argument @ 'getAccountData' [Expected account at argument 1, got boolean] [2012-09-13 11:58:29] WARNING: Userpanel\Player.lua:113: Bad argument @ 'getAccountData' [Expected account at argument 1, got boolean] [2012-09-13 11:58:29] WARNING: Userpanel\Player.lua:114: Bad argument @ 'getAccountData' [Expected account at argument 1, got boolean] [2012-09-13 11:58:29] WARNING: Userpanel\Player.lua:115: Bad argument @ 'getAccountData' [Expected account at argument 1, got boolean] [2012-09-13 11:58:29] WARNING: Userpanel\Player.lua:116: Bad argument @ 'getAccountData' [Expected account at argument 1, got boolean] [2012-09-13 11:58:29] WARNING: Userpanel\Player.lua:117: Bad argument @ 'getPlayerName' [Expected element at argument 1, got nil] [2012-09-13 11:58:29] ERROR: Userpanel\Player.lua:117: attempt to concatenate a boolean value And in 'Stats.lua' ERROR: Userpanel\Stats.lua:16: attempt to perform arithmetic on a nil value 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