An if insdie an if?

Can you do an if inside an if? Like this?



if pl:IsUserGroup("donator") then
if pl.hitlimit==false then


Well, yes you can but more like

if pl:IsUserGroup(“donator”) then
if pl.hitlimit==false then

end

end

or
if pl:IsUserGroup(“donator”) && pl.hitlimit==false then

end

ok, just wondered if you could Ty.
So would these chat messages work in the right order?



if pl:IsUserGroup("donator") then
if pl.hitlimit==false then
pl:Give("weapon_glock2")
pl.hitlimit = true
timer.simple(
else pl:ChatPrint("You aren't a donator")
else pl:ChatPrint("You can only do that every 30 seconds!")


[editline]07:49PM[/editline]

ignore the rest I know its incomplete

That’s called a Nested If. You can do them,
[lua]
if pl:IsUserGroup(“donator”) then
–Do things
if pl.hitlimit==false then
–Do things
end
end
[/lua]
Would work.

However, if you merely want to just check for both of those conditions, and your not going to be executing code within the first if, you should use an and statement.
[lua]
if pl:IsUserGroup(“Donator”) and pl.hitlimit == false then
–Do stuff
end
[/lua]
Would work.

Well I want there to be different chat messages depending on which if returned false :slight_smile:

So… exactly what i said…