Raised This Month: $51 Target: $400
 12% 

[Help] Weapon name


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
WForce
Junior Member
Join Date: Jan 2012
Old 03-26-2012 , 15:10   [Help] Weapon name
Reply With Quote #1

Hi all. That's a problem ...

When I get the name of the weapon as follows:

decl String: g_szWeapon [32];
GetEdictClassname (weapon, g_szWeapon, sizeof (g_szWeapon))

g_szWeapon then it looks like this: weapon_N where N is the name of the weapon.

How do I handle this line to have only N?

Last edited by WForce; 03-26-2012 at 15:23.
WForce is offline
Impact123
Veteran Member
Join Date: Oct 2011
Location: Germany
Old 03-26-2012 , 15:31   Re: [Help] Weapon name
Reply With Quote #2

There are at least 3 ways afaik, i'm sure it's not the best way, but in your example i would write something like this:
PHP Code:
new String:weapon[] = "weapon_weaponname";
new 
len = ( StrContains(weapon"weapon_"true) + strlen("weapon_") );

PrintToServer("Weapon: %s"weapon[len]); 
Yours sincerely
Impact
__________________

Last edited by Impact123; 03-26-2012 at 15:31.
Impact123 is offline
Doodil
Senior Member
Join Date: Mar 2012
Old 03-26-2012 , 15:31   Re: [Help] Weapon name
Reply With Quote #3

Code:
ReplaceString(g_szWeapon,sizeof(g_szWeapon),"weapon_","");
Replaces every occurance of "weapon_" with "" (meaning nothing).
Doodil is offline
TheAvengers2
BANNED
Join Date: Jul 2011
Old 03-26-2012 , 15:36   Re: [Help] Weapon name
Reply With Quote #4

If you're confident that it's a weapon, then you could simply use it as g_szWeapon[7] or do something like:

PHP Code:
strcopy(g_szWeaponsizeof(g_szWeapon), g_szWeapon[7]); 
There's really a lot of ways to go about this, like Impact123 said.

Last edited by TheAvengers2; 03-26-2012 at 15:36.
TheAvengers2 is offline
WForce
Junior Member
Join Date: Jan 2012
Old 03-26-2012 , 15:39   Re: [Help] Weapon name
Reply With Quote #5

Thank you all, you can close the topic.
WForce is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:58.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode