• self:Team() isn't actually checking
    6 replies, posted
[LUA]if PS.Config.PointsOverTime then timer.Create('PS_PointsOverTime_' .. self:UniqueID(), PS.Config.PointsOverTimeDelay * 60, 0, function() if !IsValid(self) or !self:Team() == TEAM_HUNTERS or !self:Team() == TEAM_PROPS then return end self:PS_GivePoints(PS.Config.PointsOverTimeAmount) self:PS_Notify("You've been given ", PS.Config.PointsOverTimeAmount, " ", PS.Config.PointsName, " for playing on the server!") end) end[/LUA] Am I using an incorrect notation or something? Players that are not TEAM_HUNTERS or TEAM_PROPS are still getting points. Thanks.
Have you tried adding print statements to see where the issue lies
[LUA]if !IsValid(self) or !self:Team() == TEAM_HUNTERS or !self:Team() == TEAM_PROPS then return end[/LUA] Added a print on this line and got nothing back.
Pretty sure you shouldn't be doing [code]!this == that[/code] You should be doing [code]this != that[/code] or [code]!(this == that)[/code]
[QUOTE=Mista Tea;50491446]Pretty sure you shouldn't be doing [code]!this == that[/code] You should be doing [code]this != that[/code] or [code]!(this == that)[/code][/QUOTE] Made that change in my code and now no-one gets points :pudge:
It should be: [CODE]if !IsValid(self) or (self:Team() != TEAM_HUNTERS and self:Team() != TEAM_PROPS) then return end[/CODE] or [CODE]if !IsValid(self) or !(self:Team() == TEAM_HUNTERS or self:Team() == TEAM_PROPS) then return end[/CODE] In your original code, you're doing !self:Team() which gets the team ID and then turns it to false (because the 'not' of something that isn't nil or false is false). Then you are checking if that is equal to TEAM_HUNTERS (and TEAM_PROPS) which are numbers, but TEAM_HUNTERS and TEAM_PROPS aren't false, so the if statement isn't successful and continues to give the points.
[QUOTE=TW1STaL1CKY;50492371]It should be: [CODE]if !IsValid(self) or (self:Team() != TEAM_HUNTERS and self:Team() != TEAM_PROPS) then return end[/CODE] or [CODE]if !IsValid(self) or !(self:Team() == TEAM_HUNTERS or self:Team() == TEAM_PROPS) then return end[/CODE] In your original code, you're doing !self:Team() which gets the team ID and then turns it to false (because the 'not' of something that isn't nil or false is false). Then you are checking if that is equal to TEAM_HUNTERS (and TEAM_PROPS) which are numbers, but TEAM_HUNTERS and TEAM_PROPS aren't false, so the if statement isn't successful and continues to give the points.[/QUOTE] Works perfect, thanks mate.
Sorry, you need to Log In to post a reply to this thread.