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

Knife Kill HP Reward


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BRIGADIER
Member
Join Date: Oct 2008
Old 02-14-2009 , 22:25   Knife Kill HP Reward
Reply With Quote #1

I recently posted a request for not being able to steal a level from a bot with a knife kill in gungame, however I was thinking about this as well. This could work with or without gungame, not gungame specific. The idea is this: get a knife kill, the player's health gets restored to 100. If a knife kill is a headshot, maybe 50hp more (max of 150)? I've searched for this already, and found money rewards and double frags, so I apologize if this already exists and I didn't find it.
__________________
you gonna be sawry
BRIGADIER is offline
anakin_cstrike
Veteran Member
Join Date: Nov 2007
Location: Romania
Old 02-15-2009 , 03:09   Re: Knife Kill HP Reward
Reply With Quote #2

Code:
#include <amxmodx> #include <fakemeta> new g_msghealth; public plugin_init() {     register_event( "DeathMsg", "hook_death", "a", "1!2" );     g_msghealth = get_user_msgid( "Health" ) } public hook_death() {     new k = read_data( 1 );     new w[ 2 ];     read_data( 4, w, 1 );         new hp = get_user_health( k );         if( w[ 0 ] == 'k' )     {         if( hp < 100 )             fm_set_user_health( k, 100 );                 if( read_data( 3 ) )             fm_set_user_health( k, hp+50 );     } } fm_set_user_health( index, health ) {     set_pev( index, pev_health, float( health ) );     message_begin( MSG_ONE, g_msghealth, {0,0,0}, index );     write_byte( health );     message_end(); }
__________________

anakin_cstrike is offline
BRIGADIER
Member
Join Date: Oct 2008
Old 02-15-2009 , 22:50   Re: Knife Kill HP Reward
Reply With Quote #3

That works GREAT! Thank you!
__________________
you gonna be sawry
BRIGADIER is offline
BRIGADIER
Member
Join Date: Oct 2008
Old 05-19-2009 , 22:19   Re: Knife Kill HP Reward
Reply With Quote #4

I've been running this since my last post, however there seems to be a problem where sometimes this plugin won't load (works, map changes doesn't work, map changes again and it works) and sometimes it works but not for everyone. Any clues?
__________________
you gonna be sawry
BRIGADIER is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 05-20-2009 , 09:26   Re: Knife Kill HP Reward
Reply With Quote #5

PHP Code:
register_event"DeathMsg""hook_death""a""1!2" );

--->

register_event"DeathMsg""hook_death""a" ); 
"1!2" means that the killer's id can't be 2...

also, anakin, your code is very unreadable, maybe it's because you hurried or something, but you should use clearer variables' identifiers and such.
another thing, just because the first character of the weapon is 'k', it doesn't mean that it's actually a knife. it could be a custom made weapon or something else.
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 05-20-2009 , 09:48   Re: Knife Kill HP Reward
Reply With Quote #6

Code:
#include <amxmodx> #include <fun>   public plugin_init()         register_event("DeathMsg", "DeathMsgEvent", "a", "1>0");   public DeathMsgEvent() {         new KillerID = read_data(1);           if (!is_user_alive(KillerID))                 return;           new TruncatedWeaponName[16];         read_data(4, TruncatedWeaponName, 15);           if (equal(TruncatedWeaponName, "knife"))                 set_user_health(KillerID, min(150, get_user_health(KillerID) + 50)); }
__________________
hleV 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 14:29.


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