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

Solved edit weapon in player_death event


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FroGeX
Senior Member
Join Date: Aug 2020
Old 09-07-2020 , 05:50   edit weapon in player_death event
Reply With Quote #1

How to correctly edit weapon in player_death event?

e.g. from ak47 to m4a1 for show m4a1 icon in kill feed

Last edited by FroGeX; 09-11-2020 at 12:49.
FroGeX is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 09-07-2020 , 06:55   Re: edit weapon in player_death event
Reply With Quote #2

Hook player_death with EventHookMode_Pre

PHP Code:
public void OnPluginStart()
{
    
HookEvent("player_death"Event_PlayerDeath_PreEventHookMode_Pre);
}

public 
void Event_PlayerDeath_Pre(Event event, const char[] namebool dontBroadcast
{
        
char weapon[128];
        
event.GetString("weapon"weaponsizeof(weapon));
        
        if (
StrEqual(weapon"ak47"true))
        {
            
event.SetString("weapon""m4a1"); // or m4a4, idk
        
}

__________________
Ilusion9 is offline
stephen473
Senior Member
Join Date: Jan 2017
Location: somewhere on earth
Old 09-11-2020 , 11:05   Re: edit weapon in player_death event
Reply With Quote #3

Quote:
Originally Posted by Ilusion9 View Post
Hook player_death with EventHookMode_Pre

PHP Code:
public void OnPluginStart()
{
    
HookEvent("player_death"Event_PlayerDeath_PreEventHookMode_Pre);
}

public 
void Event_PlayerDeath_Pre(Event event, const char[] namebool dontBroadcast
{
        
char weapon[128];
        
event.GetString("weapon"weaponsizeof(weapon));
        
        if (
StrEqual(weapon"ak47"true))
        {
            
event.SetString("weapon""m4a1"); // or m4a4, idk
        
}


probably you need to use
PHP Code:
return Plugin_Changed
__________________
Also known as Hardy`.

Feel free to contact me if you have a private plugin request!

My Steam Profile | Discord: Hardy`#3792
stephen473 is offline
FroGeX
Senior Member
Join Date: Aug 2020
Old 09-11-2020 , 12:48   Re: edit weapon in player_death event
Reply With Quote #4

Quote:
Originally Posted by Ilusion9 View Post
Hook player_death with EventHookMode_Pre

PHP Code:
public void OnPluginStart()
{
    
HookEvent("player_death"Event_PlayerDeath_PreEventHookMode_Pre);
}

public 
void Event_PlayerDeath_Pre(Event event, const char[] namebool dontBroadcast
{
        
char weapon[128];
        
event.GetString("weapon"weaponsizeof(weapon));
        
        if (
StrEqual(weapon"ak47"true))
        {
            
event.SetString("weapon""m4a1"); // or m4a4, idk
        
}

Ty works

Quote:
Originally Posted by stephen473 View Post
probably you need to use
PHP Code:
return Plugin_Changed
not needed but ty
FroGeX is offline
Reply


Thread Tools
Display Modes

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 14:05.


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