• Setting a variable unique per player
    36 replies, posted
[QUOTE=bromvlieg;18221294]relax && sarcasm[/QUOTE] Sorry but gmod uses and not && [lua] function Andfunction( ply ) if relax and sarcasm then Ply:goodjob() end hook.Add(Playerspawn, "check", Andfunction) [/lua]
[QUOTE=Infinity1995;18221357]Sorry but gmod uses and not && [lua] function Andfunction( ply ) if relax and sarcasm then Ply:goodjob() end hook.Add(Playerspawn, "check", Andfunction) [/lua][/QUOTE] Unfortunately, you're wrong and that code wouldn't work. Try [lua]function Andfunction(ply) if(relax&&sarcasm)then ply:GoodJob(); end end hook.Add(Playerspawn, "check", Andfunction);[/lua]
WTF, ain't it and
C++ style ftw. You can use either && or and, and || or or in gmod lua. Garry added it so it's not in normal lua. Also your code was missing an end. That code looks refreshing to my eyes Lexic, C++ looks cool, even if that's not exactly what C++ looks like :D
[QUOTE=yakahughes;18222495]C++ style ftw. You can use either && or and, and || or or in gmod lua. Garry added it so it's not in normal lua. Also your code was missing an end. That code looks refreshing to my eyes Lexic, C++ looks cool, even if that's not exactly what C++ looks like :D[/QUOTE] Also he had a capital P in ply. That's not the kind of code I'd usually do, more often I'd write it like [lua]hook.Add(Playerspawn, "check", function(ply) if (relax and sarcasm) then ply:GoodJob(); end end);[/lua], as that's still valid pure Lua while leaving in the ;s and ()s as good practice for C.
The first argument on hook.Add is invalid, by the way.
[QUOTE=DarKSunrise;18223862]The first argument on hook.Add is invalid, by the way.[/QUOTE] Unless of course, Playerspawn is a defined variable... It shouldn't be though ;)
Sorry, you need to Log In to post a reply to this thread.