I have a shove plugin in which i want to add a message for death shove .
For Example , When i shove someone and he dies than a message should be displayed .
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <cstrike>
#define PLUGIN "Shove Mod"
#define VERSION "2.5"
#define AUTHOR "Styles"
new cShove, cCooldown, cInUse, cTeam, cOnAir
new gLastShove[32]
new shove[32]
new const TASK_ID_COOLDOWN = 9462748;
new tTemp;
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /shove", "shovePlayer")
register_clcmd("say /shoveme", "ClCmd_On")
register_clcmd("say /dontshove", "ClCmd_Off")
register_clcmd("say /dontshoveme", "ClCmd_Off")
cShove = register_cvar("shove_force", "800")
cCooldown = register_cvar("shove_cooldown", "5")
cInUse = register_cvar("shove_allow_inuse", "1")
cTeam = register_cvar("shove_team_shove", "0")
cOnAir = register_cvar("shove_on_air", "0")
register_forward(FM_PlayerPreThink, "Forward_PlayerPreThink")
register_logevent("RoundNew", 2, "1=Round_Start");
}
public Forward_PlayerPreThink(id)
{
if(!get_pcvar_num(cInUse))
{
return PLUGIN_HANDLED
}
if(pev( id, pev_button ) & IN_USE && !(pev( id, pev_oldbuttons ) & IN_USE ) & !is_user_bot(id))
{
shovePlayer(id)
}
return PLUGIN_CONTINUE
}
public client_authorized(id)
{
shove[id] = true
}
public ClCmd_On(id)
{
if(shove[id])
{
c_print(id, "!g[SHOVE] !nShove is already enabled!g!")
return PLUGIN_HANDLED
}
else
{
shove[id]=true
c_print(id, "!g[SHOVE] !nYou have successfully enabled shove!g!")
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}
public ClCmd_Off(id)
{
if(!shove[id])
{
c_print(id, "!g[SHOVE] !nShove is already disabled!g!")
return PLUGIN_HANDLED
}
else
{
shove[id]=false;
c_print(id, "!g[SHOVE] !nYou have successfully disabled shove!g!")
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}
public client_disconnect(id)
{
shove[id] = false;
}
public shovePlayer(id)
{
if(!is_user_alive(id))
return PLUGIN_HANDLED
if(get_systime() - gLastShove[id] < get_pcvar_num(cCooldown))
{
return PLUGIN_HANDLED
}
new Index,Body, pName[64], tName[64]
get_user_aiming(id,Index,Body,200)
if(!Index || !is_user_alive(Index))
return PLUGIN_HANDLED
new Float:size[3]
pev(id, pev_size, size)
if(size[2] < 72.0)
{
c_print(id, "!g[SHOVE] !nYou can't shove somebody while doing that action!g!")
return PLUGIN_HANDLED
}
if(get_pcvar_num(cTeam) && cs_get_user_team(id) == cs_get_user_team(Index))
{
c_print(id, "!g[SHOVE] !nYou can't shove your own teammate!g!")
return PLUGIN_HANDLED
}
if(get_pcvar_num(cOnAir) && !(pev(Index, pev_flags) & FL_ONGROUND))
{
c_print(id, "!g[SHOVE] !nYou cannot shove someone on air!g!")
return PLUGIN_HANDLED
}
get_user_name(id, pName, charsmax(pName))
get_user_name(Index, tName, charsmax(tName))
if(!shove[id]||!shove[Index])
{
if(!shove[id] && !shove[Index])
{
c_print(id, "!g[SHOVE] !nBoth users has disabled shove!g!")
return PLUGIN_HANDLED
}
else if(!shove[Index])
{
c_print(id, "!g[SHOVE] !nThat user has disabled shove!g!")
return PLUGIN_HANDLED
}
else
{
c_print(id, "!g[SHOVE] !nSay !g/shoveme !nto enable shove!g!")
return PLUGIN_HANDLED
}
}
new Float:velocity[3], Float:shover[3], Float:shovee[3]
pev(id, pev_origin, shover)
pev(Index, pev_origin, shovee)
for(new Count;Count < 3;Count++)
velocity[Count] = (shovee[Count] - shover[Count]) * get_pcvar_float(cShove)
set_pev(Index, pev_velocity, velocity)
c_print(id, "!g[SHOVE] !nYou just shoved !t%s!g!", tName)
c_print(Index, "!g[SHOVE] !nYou have been shoved by !t%s!g!", pName)
gLastShove[id] = get_systime()
tTemp = get_pcvar_num( cCooldown );
set_task( 1.0, "TASK_SHOW_COOLDOWN", id + TASK_ID_COOLDOWN, _, _, "b" );
return PLUGIN_HANDLED
}
public TASK_SHOW_COOLDOWN(id)
{
id -= TASK_ID_COOLDOWN;
set_hudmessage( 0, 150, 0, _, 0.15, 0, 0.5, 1.0, 0.1, 0.1, -1 );
show_hudmessage( id, "shove cooldown %d seconds", tTemp );
tTemp--;
if( tTemp <= 0 ) {
if( task_exists( id + TASK_ID_COOLDOWN ) ) {
remove_task( id + TASK_ID_COOLDOWN );
return;
}
}
}
stock c_print(id, String[ ], any:... )
{
new szMsg[ 190 ]
vformat( szMsg, charsmax( szMsg ), String, 3 )
replace_all( szMsg, charsmax( szMsg ), "!n", "^1" )
replace_all( szMsg, charsmax( szMsg ), "!t", "^3" )
replace_all( szMsg, charsmax( szMsg ), "!g", "^4" )
static msgSayText = 0
static fake_user
if( !msgSayText )
{
msgSayText = get_user_msgid( "SayText" )
fake_user = get_maxplayers( ) + 1
}
message_begin( id ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, msgSayText, _, id )
write_byte( id ? id : fake_user )
write_string( szMsg )
message_end( )
}