Raised This Month: $32 Target: $400
 8% 

When someone get kill by knife . Play a troll sound


Post New Thread Reply   
 
Thread Tools Display Modes
yokomo
Surprise Ascot!
Join Date: May 2010
Location: Malaysia
Old 10-10-2014 , 03:19   Re: When someone get kill by knife . Play a troll sound
Reply With Quote #11

Quote:
Originally Posted by zmd94 View Post
By the way, which one is more efficient? Whether to use Ham_Killed or DeathMsg?

;)
Combine both code and add debug chat, see your server console I bet Hamsandwich will win.
__________________
Team-MMG CS1.6 Servers:
✅ MultiMod -- 103.179.44.152:27016
✅ Zombie Plague -- 103.179.44.152:27015
✅ Zombie Escape -- 103.179.44.152:27017
✅ Klassik Kombat -- 103.179.44.152:27018
✅ Boss-Battle -- 103.179.44.152:27019
yokomo is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 10-10-2014 , 03:35   Re: When someone get kill by knife . Play a troll sound
Reply With Quote #12

How we can see which code is more effiecient?

So that, I can learn to improve my knowledge about scripting. ;)

By the way, what do you mean by adding "debug chat"?
zmd94 is offline
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 10-10-2014 , 04:55   Re: When someone get kill by knife . Play a troll sound
Reply With Quote #13

@zmd94
@yokomo

Both versions work fine with no errors.
Krtola is offline
Send a message via Skype™ to Krtola
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 10-10-2014 , 05:00   Re: When someone get kill by knife . Play a troll sound
Reply With Quote #14

Yes thats right, Krtola.

By the way, in term of effieciency, there is a different between both codes. ;)
zmd94 is offline
yokomo
Surprise Ascot!
Join Date: May 2010
Location: Malaysia
Old 10-10-2014 , 08:27   Re: When someone get kill by knife . Play a troll sound
Reply With Quote #15

Quote:
Originally Posted by zmd94 View Post
Yes thats right, Krtola.

By the way, in term of effieciency, there is a different between both codes. ;)
No need to test, just see the code, from what i see your code called 6 amxx natives in Deathmsg hook, while mine called 3 natives in PlayerKilled forward.

So 6 vs 3, which one is faster?
__________________
Team-MMG CS1.6 Servers:
✅ MultiMod -- 103.179.44.152:27016
✅ Zombie Plague -- 103.179.44.152:27015
✅ Zombie Escape -- 103.179.44.152:27017
✅ Klassik Kombat -- 103.179.44.152:27018
✅ Boss-Battle -- 103.179.44.152:27019
yokomo is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 10-10-2014 , 14:06   Re: When someone get kill by knife . Play a troll sound
Reply With Quote #16

Nice. ;)

Just simple math to find the winner!
zmd94 is offline
Xalus
Veteran Member
Join Date: Dec 2009
Location: Belgium
Old 10-10-2014 , 14:58   Re: When someone get kill by knife . Play a troll sound
Reply With Quote #17

Quote:
Originally Posted by yokomo View Post
Hamsandwich method:
PHP Code:
#include <amxmodx>
#include <hamsandwich>

//#define USE_NEW_AMX_183
#define SoundTroll "misc/trollsound.wav"

public plugin_precache()
{
    
precache_sound(SoundTroll)
}

public 
plugin_init()
{
    
register_plugin("Knife Kill Vox""0.0.1""wbyokomo")
    
    
#if defined USE_NEW_AMX_183
    
RegisterHam(Ham_Killed"player""OnPlayerKilled"0true//CSBot support
    #else
    
RegisterHam(Ham_Killed"player""OnPlayerKilled")
    
#endif
}

public 
OnPlayerKilled(victimattacker)
{
    if(!
is_user_connected(attacker)) return;
    if(
get_user_weapon(attacker) != CSW_KNIFE) return;
    
    
client_cmd(victim"spk %s"SoundTroll)

This methode suckx, if you throw a hegrenade you automaticly get another weapon in hand, and bad luck if its a knife..

Quote:
Originally Posted by yokomo View Post
No need to test, just see the code, from what i see your code called 6 amxx natives in Deathmsg hook, while mine called 3 natives in PlayerKilled forward.

So 6 vs 3, which one is faster?
Genius


---------------------


Little update of zmd' code

PHP Code:
#include <amxmodx>

#define CustomSound "misc/YourSoundName.wav"

public plugin_init()
{
    
register_plugin("Custom Sound""1.0""zmd94")
    
    
register_event("DeathMsg""event_DeathMsg""a""1>0")
}

public 
plugin_precache() 
{
    
precache_sound(CustomSound)
}

public 
event_DeathMsg()
{
    static 
iVictimiVictim read_data(2)
    
    if(
is_user_connected(iVictim) && iVictim != read_data(1))
    {
        static 
iWeapon[32]
        
read_data4iWeaponcharsmax(iWeapon))
        
        if(
iWeapon[0] == 'k')
        {
            
client_cmd(iVictim"spk %s"CustomSound)
        }
    }

__________________
Retired.

Last edited by Xalus; 10-10-2014 at 15:04.
Xalus is offline
yokomo
Surprise Ascot!
Join Date: May 2010
Location: Malaysia
Old 10-10-2014 , 16:33   Re: When someone get kill by knife . Play a troll sound
Reply With Quote #18

I know it, then it's good too we can hear the sound on HE grenade kill too.
__________________
Team-MMG CS1.6 Servers:
✅ MultiMod -- 103.179.44.152:27016
✅ Zombie Plague -- 103.179.44.152:27015
✅ Zombie Escape -- 103.179.44.152:27017
✅ Klassik Kombat -- 103.179.44.152:27018
✅ Boss-Battle -- 103.179.44.152:27019

Last edited by yokomo; 10-10-2014 at 16:34.
yokomo is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 10-10-2014 , 21:34   Re: When someone get kill by knife . Play a troll sound
Reply With Quote #19

Xalus, so we can just use the first letter for the weapon name? Or it only for certain weapon only?
zmd94 is offline
Xalus
Veteran Member
Join Date: Dec 2009
Location: Belgium
Old 10-11-2014 , 05:51   Re: When someone get kill by knife . Play a troll sound
Reply With Quote #20

Quote:
Originally Posted by yokomo View Post
I know it, then it's good too we can hear the sound on HE grenade kill too.
Its not what hes asking for...


Quote:
Originally Posted by zmd94 View Post
Xalus, so we can just use the first letter for the weapon name? Or it only for certain weapon only?
There is only one weapon that starts with a 'k', and that knife.
__________________
Retired.

Last edited by Xalus; 10-11-2014 at 05:52.
Xalus 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 19:37.


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