Sorry for the alliteration. Couldn't help it.
I'm trying to write a simple mirror damage/tk revenge plugin. There are several issues that I cannot seem to find.
First, the mirror damage simply is not occurring, and I don't see a reason. Perhaps I've stared at it too long?
And the Revenge menu call, menuReact, is not getting passed at all. Where's the inconsistency? Any help at all would be amazing.
Code:
#include <amxmodx>
#include <cstrike>
#include <fun>
#include <amxmisc>
#include <engine>
new killChart[32]
public plugin_init()
{
register_plugin("Collateral Damage","1.0.1","Hoobs")
register_event("DeathMsg", "hook_death", "a", "1>0")
register_event("Damage", "hook_damage", "b")
register_menucmd(register_menuid("Revenge:^n"), 1023, "menuReact" )
return PLUGIN_CONTINUE
}
public hook_death()
{
new Killer = read_data(1)
new Victim = read_data(2)
if( get_user_team( Killer ) == get_user_team( Victim ) )
{
//Team Killed
killChart[Victim] = Killer
ShowPunishMenu( Victim )
}
}
public mirror_damage()
{
new damage = read_data( 2 );
new victim = read_data( 0 );
new attacker = get_user_attacker( victim )
if( get_user_team( victim ) == get_user_team( attacker ) && victim != attacker )
{
new HP = get_user_health( attacker ) - damage
if( HP > 0 )
set_user_health( attacker,( get_user_health( attacker )-damage ) )
else user_kill( attacker )
}
return PLUGIN_CONTINUE
}
public ShowPunishMenu( id ){
new szMenuBody[256]
new keys
new nLen = format( szMenuBody, 255, "Revenge:^n" )
nLen += format( szMenuBody[nLen], 255-nLen, "^n\w1. Slay" )
nLen += format( szMenuBody[nLen], 255-nLen, "^n\w2. Slap for 50 damage" )
nLen += format( szMenuBody[nLen], 255-nLen, "^n\w3. Take to 1 HP" )
nLen += format( szMenuBody[nLen], 255-nLen, "^n\w4. Steal half of killer's money" )
nLen += format( szMenuBody[nLen], 255-nLen, "^n^n\w0. Forgive" )
keys = (1<<0|1<<1|1<<2|1<<3|1<<9)
show_menu( id, keys, szMenuBody, -1 )
return PLUGIN_CONTINUE
}
public menuReact( id, key )
{
new killer = killChart[id]
client_print( 0, print_chat, "EXECUTING" )
//if( is_user_alive( killer ) && is_user_connected( killer ) )
//{
switch( key )
{
case 0:
{
user_kill( killer )
client_print( killer, print_chat, "You have been slain for killing a teammate" )
}
case 1:
{
user_slap( killer, 50 )
client_print( killer, print_chat, "You have been slapped for killing a teammate" )
}
case 2:
{
set_user_health( killer, 1 )
set_user_armor( killer, 0 )
client_print( killer, print_chat, "You have reduced to 1 hp for killing a teammate" )
}
case 3:
{
new amount = floatround( cs_get_user_money( killer ) / 2.0 )
cs_set_user_money( id, cs_get_user_money( id + amount ) )
cs_set_user_money( killer, cs_get_user_money( killer - amount ) )
client_print( killer, print_chat, "You have had half your money stolen for killing a teammate" )
}
case 9:
{
client_print( killer, print_chat, "You have forgiven for killing a teammate" )
}
//}
}
return PLUGIN_CONTINUE
}