Lua problem...

I wanna make an if then statement in player.lua to only allow certain classes to be accessed by certain ulx usergroups.

This is what I have:


if t == TEAM_PC and self:IsUserGroup("silver") or t == TEAM_PC and self:IsUserGroup("admin") or t == TEAM_PC and self:IsUserGroup("superadmin") or t == TEAM_PC and self:IsUserGroup("gold") or t == TEAM_PC and self:IsUserGroup("platinum") 
then 
Notify(self, 1, 4, "Access Granted")
end

if t == TEAM_PC and not self:IsUserGroup("silver") then
Notify(self, 1, 4, "You must be at least a Silver Donator to become this class!")
return
end

The only problem is that for some reason, When you are one of the allowed user groups, it displays “Access Granted” and then right after displays “You must be at least a Silver Donator to become this class!”
But your job doesn’t change. When I remove:


or t == TEAM_PC and self:IsUserGroup("admin") or t == TEAM_PC and self:IsUserGroup("superadmin") or t == TEAM_PC and self:IsUserGroup("gold") or t == TEAM_PC and self:IsUserGroup("platinum") 

from my code, It works just fine for only the “silver” usergroup.


(User was banned for this post ("Undescriptive thread title / wrong section" - mahalis))

This thread will probably be closed due to the non descriptive thread title, however the reason it is notifying ranks that are higher than silver is because in the second if statement, you just check if the player is silver. If not, you notify them.

Use an else instead, as follows:

[lua]if (t == TEAM_PC and (self:IsUserGroup(“silver”) or t == TEAM_PC and self:IsUserGroup(“admin”) or t == TEAM_PC and self:IsUserGroup(“superadmin”) or t == TEAM_PC and self:IsUserGroup(“gold”) or t == TEAM_PC and self:IsUserGroup(“platinum”)))
then
Notify(self, 1, 4, “Access Granted”)
else
Notify(self, 1, 4, “You must be at least a Silver Donator to become this class!”)
return
end[/lua]

You already made a thread about this. I replied to the other one in Newbie Questions section.

Where would I put the brackets then

The main problem is your code, not the brackets. See my post.

Neither of your sugestions worked.

Cloudhunter’s didnt work because when it goes to else, it looped if the job wasnt PC tech.

_nonSENSE’s didnt work. It only worked for the silver class
none of teh other ones. When it was another one that was the “or” it displays access granted and then displays “You must be at least a Silver Donator” and yoru job doesnt change.

[editline]11:51PM[/editline]

I have an idea on how to do it, but Im not sure how


if (t == TEAM_PC and self:IsUserGroup("silver")) or (t == TEAM_PC and self:IsUserGroup("admin")) or (t == TEAM_PC and self:IsUserGroup("superadmin")) or (t == TEAM_PC and self:IsUserGroup("gold")) or (t == TEAM_PC and self:IsUserGroup("platinum"))   
then   
Notify(self, 1, 4, "Access Granted")
return  
end  

Ok.

This I s what i want to do. If the statement is true, I want it to ignore the return at the end of the block. How can I do this?

Use an else statement. “if the statement is true, do something, else return”

he says it doesnt work because it returns on everything else lol

Are you fucking stupid? when you put else, it returns to the beginning of the block if the user is not a PC_TECH. Meaning, you can only use the pc tech job then

Are you fucking stupid? If the statement isn’t true it ends.

NO, if the statement isnt true, it returns to the beginning of the block and doesnt allow the user to become a pc tech