AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Weapon Name (https://forums.alliedmods.net/showthread.php?t=232876)

daNzEt 01-06-2014 05:09

Weapon Name
 
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.

Blizzard_87 01-06-2014 05:39

Re: Weapon Name
 
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 );

daNzEt 01-06-2014 07:43

Re: Weapon Name
 
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 ...

fysiks 01-06-2014 07:52

Re: Weapon Name
 
%d is for decimal (base10) numbers.
%s is for strings. Use this.

daNzEt 01-06-2014 08:32

Re: Weapon Name
 
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"


Blizzard_87 01-06-2014 17:27

Re: Weapon Name
 
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.

fysiks 01-06-2014 22:37

Re: Weapon Name
 
Quote:

Originally Posted by Blizzard_87 (Post 2082195)
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.

Blizzard_87 01-06-2014 23:50

Re: Weapon Name
 
Code:
new szWeapon[ 32 ], iWeapon = get_user_weapon( index ); get_weaponname( iWeapon, szWeapon, charsmax( szWeapon ) ); replace( szWeapon, charsmax( szWeapon ), "weapon_", "" );

daNzEt 01-07-2014 03:09

Re: Weapon Name
 
Thanks it's works also this error cand be solved?

PHP Code:

[AMXXRun time error 10native error (native "get_user_weapon"


Blizzard_87 01-07-2014 05:39

Re: Weapon Name
 
Quote:

Originally Posted by daNzEt (Post 2082347)
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.


All times are GMT -4. The time now is 20:36.

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