Moderators IIYAMA Posted August 31, 2013 Moderators 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 Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
myonlake Posted October 8, 2013 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. If I helped you, please click the like button on the right Thanks!
Moderators IIYAMA Posted October 9, 2013 Moderators Posted October 9, 2013 @ myonlake thank you very much Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Gallardo9944 Posted April 26, 2014 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. Code Debugger - Minimalistic MTA debug line replacement
Spajk Posted June 13, 2014 Posted June 13, 2014 There are certain rules in the programming communities when it comes to variable names.
Max+ Posted June 22, 2014 Posted June 22, 2014 Kenix is there any update for the varibles ? or just these ? - New , Kill System - New, GameMode Intro - Leve / Exp System - New nametag showing style - New , Hud For Players - Skin Selection from SA-MP - Money System / Buy Weapons - Drop Weapons - New, Flood System - New , Group Assign - Gun license For Weapons - Random Rule System For Money
Kenix Posted June 22, 2014 Author Posted June 22, 2014 We don't have any updates in predefined variables as far i know. http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Arran Posted May 27, 2017 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.)
iMr.WiFi..! Posted September 24, 2017 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 Experienced MTA developer for 4 years. | MTA خبرة 4 سنين في برمجة ليس عليك اسعاد الجميع , ولكن عليك بإن لا تؤذي أحداً =========You do not have to make everyone happy, But you should not hurt anyone Want to contact with me? Discord: JustCarry#2616 (Always there)Skype: Live:JustCarry10 (Not always)
Addlibs Posted September 24, 2017 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. Previously known as MrTasty.
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