Making functions
How do i make functions with values that are not neccearly need to be defined for example get_user_aiming ( index, &id, &body, [ distance ] ).
You don't have to specifiy a distance if you dont want to.. How do i make my own functions like that, how about strings? |
I'm assuming are you talking about like creating amx natives? Like creating a module? Or actually just writing a function in small?
|
Function in small
|
From what Twilight has told me, public functions cannot have default values, but stocks can. An example would be:
Code:
This makes the default value of param3 as 5. You can then call it as "functionname(7,2)" for example, and param3 will be 5 since you didn't define it. Note that stock functions aren't evaluated by the compiler unless you use them. So all of the code inside of functionname could be totally crappy and not even Small and it would compile fine unless you use it in your script. I could be wrong, but I don't think it will evaluate it if you call it via a set_task, I think you have to call it directly. |
Quote:
A perfect example is the set_task() function that accepts the name of a public function as a parameter, and is later called by AMXX in the set amount of time.. |
| All times are GMT -4. The time now is 19:25. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.