Jump to content

Error In my Reward Script


rbb27

Recommended Posts

Hi. When You kill on zombie you should win your reward or you malus depending on your team but i have all the time error =(

Can you show me my error?

addEvent( "onZombieWasted" ); 
addEventHandler( "onZombieWasted", getRootElement(), 
       function( killer ) 
            
local playerTeam = getPlayerTeam ( killer ) 
if ( playerTeam == Army) then 
            setAccountData (killer,"zombieKills",zombieKills+2) 
        givePlayerMoney( killer, math.random( 80, 110 ) )    
    elseif ( playerTeam == Scientific) then 
        setAccountData (killer,"zombieKills",zombieKills-1) 
        outputChatBox ( "You Don't Kill Zombies! -1 EXP", killer, 0, 0, 255 ) 
  
    else 
    outputChatBox ( "Error", killer, 0, 0, 255 ) 
    end          
end 
) 
  

Thank,Rbb27

Link to comment

i Try That but still error =(

  
function zkill() 
for i,v in pairs(getElementsByType("player")) do 
local playerTeam = getPlayerTeam(v) 
if ( playerTeam == Army) then 
            setAccountData (v,"zombieKills",zombieKills+2) 
        givePlayerMoney(v, math.random( 80, 110 ) )  
    elseif ( playerTeam == Scientific) then 
        setAccountData (v,"zombieKills",zombieKills-1) 
        outputChatBox ( "You Don't Kill Zombies! -1 EXP", v, 0, 0, 255 ) 
  
    else 
    outputChatBox ( "Error", v, 0, 0, 255 ) 
    end  
  
end 
end 
  
  
  
addEventHandler("onZombieWasted", getRootElement(), zkill) 
  

Link to comment

Are you sure that 'Army' and 'Scientific' are declared somewhere? You should also check if the player is logged in.

Ah and you can't use setAccountData with a player element. It must be:

setAccountData (getPlayerAccount(v),"zombieKills",zombieKills+2) 

Also where is the 'zombieKills' variable declared?

Link to comment

Don't double post, use the edit button.

addEvent( "onZombieWasted" ) 
addEventHandler( "onZombieWasted", root, 
      function ( killer ) 
            
local playerTeam = getPlayerTeam ( killer ) 
if ( playerTeam == Army) then 
        local account = getPlayerAccount ( killer ) 
            setAccountData (account,"zombieKills",getAccountData ( account , "zombiekills" ) + 2 ) 
        givePlayerMoney( killer, math.random( 80, 110 ) )    
    elseif ( playerTeam == Scientific) then 
        setAccountData (account,"zombieKills",getAccountData ( account , "zombiekills" )-1) 
        outputChatBox ( "You Don't Kill Zombies! -1 EXP", killer, 0, 0, 255 ) 
  
    else 
    outputChatBox ( "Error", killer, 0, 0, 255 ) 
    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...