Code: Select all
L 03/31/2012 - 16:07:56: [AMXX] Displaying debug trace (plugin "respawn.amxx")
L 03/31/2012 - 16:07:56: [AMXX] Run time error 4: index out of bounds
L 03/31/2012 - 16:07:56: [AMXX] [0] respawn.sma::eventDeath (line 31)
Code: Select all
#include <amxmodx>
#include <cstrike>
#include <hamsandwich>
#define MAXPLAYERS 31
#define TASK_RESPAWN 7124
new g_iRespawns[MAXPLAYERS + 1] = {0, ...};
new g_pCvar_Time;
new g_pCvar_Respawns;
public plugin_init()
{
register_plugin("DeathRunRespawn", "0.1", "Someone over the rainbow");
register_event("DeathMsg", "eventDeath", "a");
register_event("HLTV", "eventNewRound", "a", "1=0", "2=0");
RegisterHam(Ham_Spawn, "player", "FwdPlayerSpawn_Post", true);
g_pCvar_Time = register_cvar("spawn_delay", "1.0");
g_pCvar_Respawns = register_cvar("spawn_times", "10");
}
public eventDeath()
{
new iVictim = read_data(2);
new Float:flTime = get_pcvar_float(g_pCvar_Time);
if( g_iRespawns[iVictim] < get_pcvar_num(g_pCvar_Respawns) )
{
client_print(iVictim, print_chat, "You have only 10 respawns / round !", flTime);
set_task(flTime, "Respawn", iVictim + TASK_RESPAWN);
}
else
{
remove_task(iVictim + TASK_RESPAWN);
client_print(iVictim, print_chat, "You have respawned the maximum amount of times this round.");
}
}
public eventNewRound()
{
new iPlayers[32], iNum, id;
get_players(iPlayers, iNum);
for( new i = 0; i < iNum; i++ )
{
id = iPlayers[i];
if( is_user_connected(id) )
{
g_iRespawns[id] = 0;
}
}
}
public FwdPlayerSpawn_Post(id)
{
if( is_user_alive(id) )
{
remove_task(id + TASK_RESPAWN);
}
}
public client_disconnect(id)
{
remove_task(id + TASK_RESPAWN);
}
public Respawn(id)
{
id -= TASK_RESPAWN;
ExecuteHamB(Ham_CS_RoundRespawn, id);
g_iRespawns[id]++;
}