Jump to content

getPlayerTeam pointer


-Jigsaw

Recommended Posts

I know it may be a silly question, but I am a bit confused..

I have this:

function checkForTeam() 
    if getPlayerTeam(player) == nil then 
        --Output some stuff 
    end 
end 
  
function ResourceStart() 
    local players = getElementsByType("player") 
    for k,v in ipairs(players) do 
        setPlayerTeam (v, nil) 
        bindKey(v, "F1", "down", checkForTeam) 
    end 
end 
  
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), ResourceStart) 

The problem is that when I press the 'F1' key, I get this error:

Bad argument @ 'getPlayerTeam' 

Ty in advance

Link to comment

It still being nil. Use source instead.

Well, I tried this one
if not getPlayerTeam(player) then 

and it woked as I wanted it to..

My bad I didn't think of it before opening the topic :)

This works cuz getPlayerTeam(player) => false, player => nil.

Your condition is the same of:

if( getPlayerTeam( player ) == false ) then 

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