Return an array in stock
Hey. First of all, thank you for explaining in details why should I use cstrike/fun/engine modules instead of converting them. I really did get the point and appreceate that you dealt with my narrow-mindness till the end :D
I wanted to ask some help regarding stocks. I want to create a stock that would do the following: Code:
But this does not work. Could you please tell me how can I achieve the wanted result? |
Re: Return an array in stock
The stock already does what you want it to do (trust me, try it). Remove the return rgb; line and you're good to go.
|
Re: Return an array in stock
The important thing to understand here is that arrays are passed by reference aka 'byref' in this language.
That means that when you manipulate an array variable inside your function, it actually changes the variable in the calling code which was provided as the argument. |
Re: Return an array in stock
In amxx it is not possible to return an array or a string (basically in amxx string is an array of integers that actually can also be understood as chars).
So in this case you have just to use the function with an empty array as input. And then function will just save the rgb values directly in that array. This will your stock look like: PHP Code:
PHP Code:
|
Re: Return an array in stock
Understood! Thank you
|
Re: Return an array in stock
Quote:
|
Re: Return an array in stock
But returning a string is bad best is to copy it byref
|
Re: Return an array in stock
Quote:
|
Re: Return an array in stock
Yeah, I know it's possible to return string, but still I can't understand why is not a good idea?! Can anyone explain please? :p
|
Re: Return an array in stock
Quote:
|
All times are GMT -4. The time now is 20:15. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.