Hello everyone, I found this plugin that makes a player to revive a teammate by approaching the corpse and holding CTRL + E, a bar will appear and when you complete that bar the player revives where he died, the problem with this is that you have to get close to the exact point where he died and it is very difficult to find the exact point. Someone could make it possible to revive the partner over a certain radio and have a cvar of that (so it would be easier to revive it) please? ... ths in advance
PHP Code:
/*
- Credits:
# Alucard (Get_origin)
# Black Rose (Check buttoms)
*/
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#include <fun>
#include <cstrike>
#define PLUGIN "CPR Revive"
#define VERSION "1.0"
#define AUTHOR "wiD"
new Float:fOrigin[33][3] // Poss of victim
new gCheck[33]
new Float:fPoss[33][3] // Poss of reviver
new checkid
new g_msgBarTime;
new gMessage[33]
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("DeathMsg", "event_DeathMsg", "a")
register_forward(FM_CmdStart, "OnCmdStart", false)
g_msgBarTime = get_user_msgid( "BarTime" );
}
public get_origin(id)
{
new Float:fDeath[3]
pev(id , pev_origin , fDeath)
fOrigin[id][0] = fDeath[0]
fOrigin[id][1] = fDeath[1]
fOrigin[id][2] = fDeath[2]
return PLUGIN_HANDLED
}
public event_DeathMsg()
{
new attacker = read_data(1)
new victim = read_data(2)
if (!(is_user_connected(attacker)) || (attacker == victim))
return;
get_origin(victim)
}
public OnCmdStart(id, uc_handle, seed)
{
if (!is_user_alive(id))
return;
static buttons;
buttons = get_uc(uc_handle, UC_Buttons);
if ((buttons & IN_DUCK) && (buttons & IN_USE))
{
if (!gCheck[id] && CheckOrigin(id))
{
set_task(10.0, "RevivePlayer", id)
gCheck[id] = true;
if(!gMessage[id])
{
startBar(id)
gMessage[id] = true
}
}
}
else
{
stopBar(id)
remove_task(id);
gCheck[id] = false;
gMessage[id] = false;
}
return;
}
public CheckOrigin(id)
{
new bool:checking
new Float:fPosition[3]
pev(id , pev_origin , fPosition)
fPoss[id][0] = fPosition[0]
fPoss[id][1] = fPosition[1]
fPoss[id][2] = fPosition[2]
for(new i = 1; i <= get_maxplayers( ); i++ )
{
if((fOrigin[i][0] == fPoss[id][0]) && (fOrigin[i][1] == fPoss[id][1]) && (fOrigin[i][2] == fPoss[id][2]) && (cs_get_user_team(id) == cs_get_user_team(i)))
{
checking = true
checkid = i
break;
}
}
return checking;
}
public RevivePlayer(id)
{
ExecuteHamB(Ham_CS_RoundRespawn, checkid)
new Float:fSetOrigin[3]
fSetOrigin[0] = fPoss[id][0]
fSetOrigin[1] = fPoss[id][1]
fSetOrigin[2] = fPoss[id][2]
set_user_origin(checkid, fSetOrigin)
client_print(0, print_chat, "[CPR] User %s respawned target %s", id, checkid)
}
public startBar(id)
{
message_begin( MSG_ONE , g_msgBarTime , {0,0,0} , id );
write_short( 10 );
message_end();
}
public stopBar(id)
{
message_begin(MSG_ONE, g_msgBarTime, _, id)
write_short(0)
message_end()
}