Jump to content

Function Dont Work


Newbie

Recommended Posts

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

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

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