Newbie Posted April 17, 2014 Share Posted April 17, 2014 function DestructionWin( ) local alivePlayers = getAlivePlayers( ) if #alivePlayers == 1 then local account = getPlayerAccount( alivePlayers[1] ) if account then if isGuestAccount( account ) then return end setAccountData( account,"Wins",tostring( getAccountData( account,"Wins" ) or 0 )+1 ) setAccountData( account,"Cash",tostring( getAccountData( account,"Cash" ) or 0 )+ 250 ) setAccountData( account,"EXP",tostring( getAccountData( account,"EXP" ) or 0 )+math.random(2,3) ) outputChatBox("#FF0000={#FFFFFFWin#FF0000}= #FFFFFFYou have earned #FF0000250 #FFFFFF$ and some EXP!", source, 255, 255, 255, true) end end end Link to comment
Mr_Moose Posted April 17, 2014 Share Posted April 17, 2014 And the errors would be the following: "Attempt to perform arithmetic on a string value" or something like that which can be seen by reading the code. The solution is simple however, on line 7, 8 and 9: Replace: tostring( ) with: tonumber( ) Link to comment
Saml1er Posted April 17, 2014 Share Posted April 17, 2014 Well getAlivePlayers( ) sometimes gets the players who have just recently joined so if you use race resource then do something like this: function getAlivePlayers2() local pp = { } for _,v in pairs (getElementsByType("player") ) do local state = getElementData (v, "state") if state and state == "alive" then pp [#pp + 1] = v end end return pp end function DestructionWin( ) local alivePlayers = getAlivePlayers2() if #alivePlayers == 1 then local account = getPlayerAccount( alivePlayers[1] ) if account then if isGuestAccount( account ) then return end setAccountData( account,"Wins",(tostring( getAccountData( account,"Wins" )) or 0) +1 setAccountData( account,"Cash",(tostring( getAccountData( account,"Cash" )) or 0 )+ 250 local randVal = math.random(2,3) setAccountData( account,"EXP",(tostring( getAccountData( account,"EXP" ) ) or 0 )+ randVal outputChatBox("#FF0000={#FFFFFFWin#FF0000}= #FFFFFFYou have earned #FF0000250 #FFFFFF$ and some EXP!", source, 255, 255, 255, true) end end end 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