Jump to content

Help with Ipairs


Gtagasje

Recommended Posts

I got a script for paycheck on team ect. but it shows the folowing error message in console : "WARNING: Core/copspaycheck.lua:2: Bad argument @ 'getPlayersInTeam'."

and: "ERROR: Core/copspaycheck.lua:3: bad argument #1 to 'ipairs' (table expected, got boolean)"

I don't know how to fix those things..

This is the script:

  
function allPlayersPayDay() 
  local allPlayers = getPlayersInTeam( "Police" ) 
  for index,value in ipairs(allPlayers) do 
    givePlayerMoney ( value, 5000 ) 
    outputChatBox ( "PayTime! You have been given 5K! Enjoy!", value ) 
  end 
end 
  
function onResourceStart(thisResource) 
  setTimer ( allPlayersPayDay, 1000, 0 ) 
end 
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), onResourceStart ) 
  

Regards, Gtagasje

Link to comment

That's because you put a string as team, but it requires a team element.

function allPlayersPayDay() 
  local allPlayers = getPlayersInTeam( getTeamFromName( "Police" ) ) 
  for index,value in ipairs(allPlayers) do 
    givePlayerMoney ( value, 5000 ) 
    outputChatBox ( "PayTime! You have been given 5K! Enjoy!", value ) 
  end 
end 
  
function onResourceStart(thisResource) 
  setTimer ( allPlayersPayDay, 1000, 0 ) 
end 
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), onResourceStart ) 

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