Moderators IIYAMA Posted August 31, 2013 Moderators Share Posted August 31, 2013 (edited) Server only client -- the client that called the event btw what will this be? a userdata? can I check with this, if the one that did send it, is still in the server? Edited September 11, 2013 by Guest Link to comment
myonlake Posted October 8, 2013 Share Posted October 8, 2013 Server only client -- the client that called the event btw what will this be? a userdata? can I check with this, if the one that did send it, is still in the server? Just to answer the question: it will return the client that called the event. If you trigger some server-side event from client-side, the client will be the player who triggered the server-side event. This is useful for checking element data hacks and similiar. Quite a helpful thing with security. Link to comment
Moderators IIYAMA Posted October 9, 2013 Moderators Share Posted October 9, 2013 @ myonlake thank you very much Link to comment
Gallardo9944 Posted April 26, 2014 Share Posted April 26, 2014 I would personally recommend adding global vars like ROOTELEMENT, RESROOTELEMENT, LOCALPLAYER (upper case) so most of the text editors light them up as constants. Link to comment
Spajk Posted June 13, 2014 Share Posted June 13, 2014 There are certain rules in the programming communities when it comes to variable names. Link to comment
Max+ Posted June 22, 2014 Share Posted June 22, 2014 Kenix is there any update for the varibles ? or just these ? Link to comment
Kenix Posted June 22, 2014 Author Share Posted June 22, 2014 We don't have any updates in predefined variables as far i know. Link to comment
Arran Posted May 27, 2017 Share Posted May 27, 2017 You're missing 'arg'. 'arg' is a predefined Lua variable in functions which use '...' as an argument. Example: crun function a(...) outputChatBox(tostring(arg.n)) end a(10, 20, 30) -- "3" (arg.n returns 3 because there were 3 arguments in ...) crun function a(...) outputChatBox(tostring(arg[2])) end a(10, 20, 30) -- "20" (arg[2] returns 20 because the second argument in ... is 20.) Link to comment
iMr.WiFi..! Posted September 24, 2017 Share Posted September 24, 2017 On ٢٧/٥/٢٠١٧ at 11:52, Arran said: You're missing 'arg'. 'arg' is a predefined Lua variable in functions which use '...' as an argument. Example: crun function a(...) outputChatBox(tostring(arg.n)) end a(10, 20, 30) -- "3" (arg.n returns 3 because there were 3 arguments in ...) crun function a(...) outputChatBox(tostring(arg[2])) end a(10, 20, 30) -- "20" (arg[2] returns 20 because the second argument in ... is 20.) You'r wrong .. You Should Define "arg" by yourself to get the results , and 'arg.n' its wrong , the Correct is '#arg' the examples will be : function a(...) local arg = { ... }; outputChatBox(tostring(#arg)) end a(10, 20, 30) -- "3" (arg.n returns 3 because there were 3 arguments in ...) function a(...) local arg = { ... }; outputChatBox(tostring(arg[2])) end a(10, 20, 30) -- "20" (arg[2] returns 20 because the second argument in ... is 20.) 1 Link to comment
Addlibs Posted September 24, 2017 Share Posted September 24, 2017 1 hour ago, iMr.WiFi..! said: You'r wrong .. You Should Define "arg" by yourself to get the results , and 'arg.n' its wrong , the Correct is '#arg' the examples will be : function a(...) local arg = { ... }; outputChatBox(tostring(#arg)) end a(10, 20, 30) -- "3" (arg.n returns 3 because there were 3 arguments in ...) function a(...) local arg = { ... }; outputChatBox(tostring(arg[2])) end a(10, 20, 30) -- "20" (arg[2] returns 20 because the second argument in ... is 20.) Actually, arg is indeed predefined, and does contain a key-value pair of n which lists the number of arguments. Quote The three dots (...) in the parameter list indicate that the function has a variable number of arguments. When this function is called, all its arguments are collected in a single table, which the function accesses as a hidden parameter named arg. Besides those arguments, the arg table has an extra field, n, with the actual number of arguments collected. -- https://www.lua.org/pil/5.2.html You can check it yourself using the following function (perhaps on HTTP runcode): function hey(...) return inspect(arg) end --then call hey(553, 674, "test", "foobar") -- This will return a formatted table containing all the arguments you've inputted, without actually defining the variable "arg", and there's also the "n" key in there. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now