I'm not sure if its necessary, but here's another example of how to use return - both to end a function, and to actually return something.
[lua]function ParseValue(val)
if val < 5 then
return -- End the function if "val" is less than 5.
end
if (val>5) and (val<10) then
return "Between 5 and 10"
end
if (val>10) then
return "Over 10"
end
end
print(ParseValue(2)) -- Returns nil (nothing happened)
print(ParseValue(7)) -- Returns "between 5 and 10"
print(ParseValue(11)) -- Returns "over 10"
[/lua]
[QUOTE=Drakehawke;22151369]I understand all that apart from
[lua]
ply:ConCommand("donator "..string.Right(text, string.len(text)-8))
[/lua][/QUOTE]
It was just an example of where to use it. Chat commands.
OHHHHH
I get it, so in that example, if the first 8 letters of the string the player typed in the chat were "!donator", it returns as an empty string, therefore not showing up in the chat?
[QUOTE=Drakehawke;22152440]OHHHHH
I get it, so in that example, if the first 8 letters of the string the player typed in the chat were "!donator", it returns as an empty string, therefore not showing up in the chat?[/QUOTE]
Yeah, and running that console command which you were confused about.