I want to make an elimination plugin. It's a respawning plugin that respawns a player only after his killer is dead.
I modified Wrecked's version (I haven't test it) to cover more situations. It doesn't work all the time and the messages apear too many times. I must admit that I didn't quite understood his method.
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <cstrike>
#define ADVERTISE_TIME 30.0
new Killed[33][31]
new KillIndex[33] // to keep count
public plugin_init()
{
register_plugin( "Elimination", "1.5, "whatever" )
register_event( "DeathMsg", "eDeathMsg", "a" );
set_task( ADVERTISE_TIME, "TaskAdvertise", .flags="b" )
}
public eDeathMsg()
{
new iKiller = read_data(1);
new iVictim = read_data(2);
static sWeapon[16];
read_data( 4, sWeapon, sizeof( sWeapon ) - 1 );
if( iKiller == iVictim && equal( sWeapon, "world", 5 ) ) //suicide
{
set_task( 3.0, "TaskRespawn", iVictim )
ChatColor( iVictim, "!gVei fi respawnat in 3 secunde." )
}
if( !iKiller && equal( sWeapon, "world", 5 ) ) //fall
{
set_task( 3.0, "TaskRespawn", iVictim )
ChatColor( iVictim, "!gVei fi respawnat in 3 secunde." )
}
if( !iKiller && equal( sWeapon, "door", 4 ) ) //door
{
set_task( 3.0, "TaskRespawn", iVictim )
ChatColor( iVictim, "!gVei fi respawnat in 3 secunde." )
}
if( !iKiller && equal( sWeapon, "trigger_hurt", 12 ) ) //trigger
{
set_task( 3.0, "TaskRespawn", iVictim )
ChatColor( iVictim, "!gVei fi respawnat in 3 secunde." )
}
if( cs_get_user_team( iKiller ) == cs_get_user_team( iVictim ) )
{
set_task( 3.0, "TaskRespawn", iVictim )
ChatColor( iVictim, "!gVei fi respawnat in 3 secunde." )
}
new i
new vname[32]
get_user_name( iVictim, vname, 31 )
while( Killed[iVictim][++i] )
{
if( !is_user_alive( i ) )
{
ExecuteHamB( Ham_CS_RoundRespawn, i )
ChatColor( i, "!g%s A murit! Vei fi respawnat.", vname )
}
}
arrayset( Killed[iVictim], 0, 31 )
KillIndex[iVictim] = 0
new kname[32]
get_user_name( iKiller, kname, 31 )
ChatColor( iVictim, "!gVei fi respawnat cand %s moare.", kname )
Killed[iKiller][KillIndex[iKiller]++] = iVictim
}
public TaskAdvertise()
{
ChatColor( 0, "!gJoci GunGame Elimination - Vei fi respawnat doar atunci cand cel ce te-a ucis moare." )
}
public TaskRespawn( id )
{
if( !is_user_alive( id ) )
{
ExecuteHamB( Ham_CS_RoundRespawn, id )
}
}
ChatColor( id, const input[], any:... )
{
new count = 1;
new players[32];
static msg[191];
vformat(msg, 190, input, 3);
replace_all(msg, 190, "!g", "^4"); // Green Color
replace_all(msg, 190, "!y", "^1"); // Default Color
if (id)
players[0] = id;
else
get_players(players, count, "ch");
for (new i = 0; i < count; i++)
{
if (is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}