[SOLVED] Problem with a native that returns a string
PHP Code:
I'm using furien_get_weaponname("weapon_mp5navy"). I have no idea how I'm getting the last sound that was played, instead of the weapon's name, which in this case is "Balrog Ethereal". |
Re: [Help ASAP] Problem with a native that returns a string
Don't do that, pass string by reference.
|
Re: [Help ASAP] Problem with a native that returns a string
By reference? Could you please explain, since I have no idea what that means?
|
Re: [Help ASAP] Problem with a native that returns a string
Don't return a string, this was said 1000th times already, I am not sure why people keep doing this. It just stupid.
You have some natives called get_string/set_string, search for them. Also the loop looks silly, instead of it check if g_szModels[0] is the name that you get from the native(get_string) and use set_string with g_szModels[1]. Keep in mind that you are working with natives registered with style 0, so they don't pass the parameters. They only pass the plugin index and the param num. You have to use specific natives to get the params value(get_param/get_string etc). |
Re: [Help ASAP] Problem with a native that returns a string
PHP Code:
|
Re: [Help ASAP] Problem with a native that returns a string
I told you, you don't have any of the native params passed in the function header(public _furien_get_weaponname(szWeapon[], szString) should be _furien_get_weaponname(PluginIndex, PluginParams)).
So this is wrong: PHP Code:
But, what do you want to do ? The loop does not make sense. You want to return only the weapon name associated with weapon_* ? |
Re: [Help ASAP] Problem with a native that returns a string
I want to get the weapon name that corresponds to the given weapon, so if the weapon is "weapon_mp5navy", I would get "Balrog Ethereal". Ignore the other things in the array, because this isn't the full code of the plugin.
So, I changed it like this now: PHP Code:
PHP Code:
PHP Code:
This is what I'm trying to do - http://i.imgur.com/RS7k4sa.jpg I made the image with a simple array of strings in the same plugin, but I want to add the name in my other plugin, where all the weapon models are. |
Re: [Help ASAP] Problem with a native that returns a string
PluginParams is the number of parameters. You pass the weapon name as the first argument, so it should be get_string(1,....).
|
Re: [Help ASAP] Problem with a native that returns a string
It works now. Thank you!
|
| All times are GMT -4. The time now is 22:06. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.