H3DG3H0G Posted April 10, 2017 Share Posted April 10, 2017 Hello guys! Today i'm here to ask a simple question which i have been looking for everywhere. Why should we put something inside of () after function? I mean function simpleTask(ammo, killer, bodypart, money). And if it's like an extension how many of them exist? Is there any list of things we should put inside of () after function and usage of them? Link to comment
Administrators Lpsd Posted April 10, 2017 Administrators Share Posted April 10, 2017 The '()' after a function is a parameter list. Parameters are basically variables, which are used when you need to pass data through to a function. You can have as many parameters as you like. Here's a small example. function add(x, y) --define your parameters, in this example they are "x" and "y" local sum = x + y return sum end local myVar = add(1, 3) --we pass through 2 arguments into the "x" and "y" slots of the add() function. x = 1, y = 3 In the example above, "myVar" would now contain the value "4". Once we have passed the arguments through to the add() function, we can refer to them as x and y thereon. In this example, it's useful because we can keep using the add() function, but passing new values through each time it is called. Hope this makes sense, anything else just ask. 1 Link to comment
_DrXenon Posted April 10, 2017 Share Posted April 10, 2017 and those parameters change when you change the event of the function. (When there's an event called to directly trigger the function) One more thing, if the second argument or parameters is 'ammo' then it would always be 'ammo' no matter what you call it. So even if you called the second parameter 'killer', killer will be the 'ammo' parameter and not the 'killer' parameter. (Idk, how clear I was here.) Link to comment
Ayush Rathore Posted April 12, 2017 Share Posted April 12, 2017 (edited) On 4/10/2017 at 21:34, H3DG3H0G said: Hello guys! Today i'm here to ask a simple question which i have been looking for everywhere. Why should we put something inside of () after function? I mean function simpleTask(ammo, killer, bodypart, money). And if it's like an extension how many of them exist? Is there any list of things we should put inside of () after function and usage of them? if you need any scripting help you should go to this link https://wiki.multitheftauto.com/ for a proper understanding on how we pass Parameter in Mta functions Edited April 12, 2017 by Ayush Rathore 1 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