Raised This Month: $ Target: $400
 0% 

Weapon Name


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
daNzEt
Senior Member
Join Date: Sep 2010
Location: Romania
Old 01-06-2014 , 05:09   Weapon Name
Reply With Quote #1

How can i read the weapon name in a plugin to show in chat weapon name and not weapon string (10,30,100,19 ...) for message Player killed you with weapon name.
daNzEt is offline
Send a message via Yahoo to daNzEt Send a message via Skype™ to daNzEt
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 01-06-2014 , 05:39   Re: Weapon Name
Reply With Quote #2

Code:
new szWeapon[ 32 ], iWeapon = get_user_weapon( index ); get_weaponname( iWeapon, szWeapon, charsmax( szWeapon ) ); client_print( index, print_chat, "Player ? Has Weapon %s", szWeapon );
__________________

Last edited by Blizzard_87; 01-06-2014 at 05:41.
Blizzard_87 is offline
daNzEt
Senior Member
Join Date: Sep 2010
Location: Romania
Old 01-06-2014 , 07:43   Re: Weapon Name
Reply With Quote #3

Thanks!

But look what server print in my chat:

[IMG]http://s28.************/5caqodp5p/img.png[/IMG]

PHP Code:
public event_DeathMsg(id)
{
    new 
iKiller read_data(1
    new 
iVictim    read_data(2)     
    
    if(
iKiller == iVictim
    { 
        return 
PLUGIN_HANDLED
    } 
    
    else 
    {     
        new 
name[32];
        
get_user_name(iKillername31)
        
        new 
szWeapon32 ], iWeapon get_user_weaponiKiller );
        
get_weaponnameiWeaponszWeaponcharsmaxszWeapon ) );
         
        new 
health get_user_health(iKiller); 
         
        
chat_color(iVictim"!nKilled by !t%s !nwith !g%d !nand remained with !g%d !nhp"nameszWeaponhealth
    } 
    
    return 
PLUGIN_HANDLED

As i said i need to print weapon name not weapon string ...

Last edited by daNzEt; 01-06-2014 at 07:45.
daNzEt is offline
Send a message via Yahoo to daNzEt Send a message via Skype™ to daNzEt
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-06-2014 , 07:52   Re: Weapon Name
Reply With Quote #4

%d is for decimal (base10) numbers.
%s is for strings. Use this.
__________________
fysiks is offline
daNzEt
Senior Member
Join Date: Sep 2010
Location: Romania
Old 01-06-2014 , 08:32   Re: Weapon Name
Reply With Quote #5

Done:

PHP Code:
public event_DeathMsg(id)
{
    new 
iKiller read_data(1
    new 
iVictim    read_data(2)     
    
    if(
iKiller == iVictim
    { 
        return 
PLUGIN_HANDLED
    } 
    
    else 
    {     
        new 
name[32];
        
get_user_name(iKillername31)
        
        new 
szWeapon32 ], iWeapon get_user_weaponiKiller );
        
get_weaponnameiWeaponszWeaponcharsmaxszWeapon ) );
         
        new 
health get_user_health(iKiller); 
         
        
chat_color(iVictim"!nKilled by !t%s !nwith !g%s !nand remained with !g%d !nhp"nameszWeaponhealth
    } 
    
    return 
PLUGIN_HANDLED

Good now but how can i eliminate

weapon_ (only m4a1) etc

[IMG]http://s23.************/cu1yqamd7/imgkill.png[/IMG]

Also on this line:

PHP Code:
new szWeapon32 ], iWeapon get_user_weaponiKiller ); 
PHP Code:
[AMXXDisplaying debug trace (plugin "statsx.amxx")
L 01/06/2014 18:40:45: [AMXXRun time error 10native error (native "get_user_weapon"

Last edited by daNzEt; 01-06-2014 at 12:38.
daNzEt is offline
Send a message via Yahoo to daNzEt Send a message via Skype™ to daNzEt
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 01-06-2014 , 17:27   Re: Weapon Name
Reply With Quote #6

To fix the weapon_ in the name you need to use the
Replace or replace_all native not sure which one on top of head as im at work.
__________________
Blizzard_87 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-06-2014 , 22:37   Re: Weapon Name
Reply With Quote #7

Quote:
Originally Posted by Blizzard_87 View Post
To fix the weapon_ in the name you need to use the
Replace or replace_all native not sure which one on top of head as im at work.
The difference should be obvious. Since it is guaranteed that "weapon_" will only exist once, you can use the former.
__________________
fysiks is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 01-06-2014 , 23:50   Re: Weapon Name
Reply With Quote #8

Code:
new szWeapon[ 32 ], iWeapon = get_user_weapon( index ); get_weaponname( iWeapon, szWeapon, charsmax( szWeapon ) ); replace( szWeapon, charsmax( szWeapon ), "weapon_", "" );
__________________
Blizzard_87 is offline
daNzEt
Senior Member
Join Date: Sep 2010
Location: Romania
Old 01-07-2014 , 03:09   Re: Weapon Name
Reply With Quote #9

Thanks it's works also this error cand be solved?

PHP Code:
[AMXXRun time error 10native error (native "get_user_weapon"
daNzEt is offline
Send a message via Yahoo to daNzEt Send a message via Skype™ to daNzEt
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 01-07-2014 , 05:39   Re: Weapon Name
Reply With Quote #10

Quote:
Originally Posted by daNzEt View Post
Thanks it's works also this error cand be solved?

PHP Code:
[AMXXRun time error 10native error (native "get_user_weapon"
show your full code so i can check error myself.
__________________
Blizzard_87 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 20:36.


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