-Jigsaw Posted July 13, 2012 Share Posted July 13, 2012 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
AMARANT Posted July 13, 2012 Share Posted July 13, 2012 I suppose that there is no 'nil' team. And in your script you're trying to set player's team to nil. Link to comment
-Jigsaw Posted July 13, 2012 Author Share Posted July 13, 2012 Uhm, so how would I check if the player is not in a team? Whould something like this work: if not getPlayerTeam(player) then Link to comment
AMARANT Posted July 13, 2012 Share Posted July 13, 2012 I think you could check it like this: if getPlayerTeam(player)==false then EDIT: Your example is supposed to be the same. Link to comment
-Jigsaw Posted July 13, 2012 Author Share Posted July 13, 2012 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 Link to comment
DarkLink Posted July 13, 2012 Share Posted July 13, 2012 player on your checkForTeam function is not defined mate.. change to this: function checkForTeam(player) if getPlayerTeam(player) == nil then --Output some stuff end end Link to comment
Anderl Posted July 13, 2012 Share Posted July 13, 2012 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
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