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

get_user_weapon2()


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 03-22-2009 , 04:05   get_user_weapon2()
Reply With Quote #1

get_user_weapon2

PHP Code:
public get_user_weapon2id ) {
    new 
szWeapon20 ];
    
get_weaponnameget_user_weaponid ), szWeaponcharsmaxszWeapon ) );
    
    return 
szWeapon[7];

.: Description :.
Do you even wanted to return weapon name in format like: usp, knife?
This simple stock returns you weapon name like: usp, knife, awp ;)
.: Example usage #1 :.
PHP Code:
    client_printidprint_chat"* Your weapon is %s!"get_user_weapon2(id) ); 
.: Example usage #2 :.
PHP Code:
    new szWeapon[20];
    
szWeapon get_user_weapon2id );

    if( 
equal(szWeapon"knife") ) {
        
client_printidprint_chat"* You have knife, some cool stuff!" );
    } 
__________________

Last edited by xPaw; 07-10-2009 at 03:21.
xPaw is offline
M1R0n,M'
Senior Member
Join Date: Jan 2009
Location: Lithuania
Old 03-22-2009 , 04:09   Re: get_user_weapon2()
Reply With Quote #2

good
__________________
PHP Code:
#include <hambeer>
RegisterHamBeer(HamBeer_Spawn"player""GivePlayerBeer"1);
public 
GivePlayerBeer(Pl){
    if(!
is_user_alive(Pl)){
        
ham_give_beer(Pl5)
        
client_print(Plprint_chat"Go Go Go"){

M1R0n,M' is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-22-2009 , 05:08   Re: get_user_weapon2()
Reply With Quote #3

szWeapon size is too small to contain "weapon_smokegrenade"
You don't need this badly named var szWeaponCSW ( <- it's an integer so iWeaponCSW would have been better if the var had been needed)

PHP Code:
stock get_user_weapon2id )
{
    new 
szWeapon[20]; // weapon_smokegrenade = 19
    
get_weaponname(get_user_weapon(id), szWeaponcharsmax(szWeapon));
    
replace(szWeaponcharsmax(szWeapon), "weapon_""");

    return 
szWeapon;

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 03-22-2009 , 05:16   Re: get_user_weapon2()
Reply With Quote #4

updated
__________________
xPaw is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 03-22-2009 , 06:30   Re: get_user_weapon2()
Reply With Quote #5

To avoid to use replace() ; using szWeapon[7] directly should work.

[edit] Arg, it will give an error "Array must be indexed" for the #2. Not good. Though, using szWeapon[0] to get should work, but not sure if it's a good idea.

Last edited by Arkshine; 03-22-2009 at 06:40.
Arkshine is offline
alan_el_more
Veteran Member
Join Date: Jul 2008
Location: amxmodx-es.com
Old 03-22-2009 , 07:35   Re: get_user_weapon2()
Reply With Quote #6

GJ
__________________
alan_el_more is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-22-2009 , 08:10   Re: get_user_weapon2()
Reply With Quote #7

I've always used szWeapon[7] to solve this. It would be cool to have this implemented into the core though.
__________________
Bugsy is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 03-22-2009 , 08:40   Re: get_user_weapon2()
Reply With Quote #8

Quote:
Originally Posted by Bugsy View Post
I've always used szWeapon[7] to solve this. It would be cool to have this implemented into the core though.
Natives can't return arrays.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-22-2009 , 12:54   Re: get_user_weapon2()
Reply With Quote #9

Shouldn't the function's name be more appropriate, such as get_user_weaponname()?
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
minimiller
Veteran Member
Join Date: Aug 2007
Location: United Kingdom
Old 03-22-2009 , 13:25   Re: get_user_weapon2()
Reply With Quote #10

i thought there allready was a get_user_weaponname?
It returns "weapon_"

EDIT:
My bad
its just get_weaponname(index)
__________________

Last edited by minimiller; 03-22-2009 at 13:26. Reason: EDIT
minimiller is offline
Send a message via MSN to minimiller
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 16:32.


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