Kód: 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", "3"); g_pCvar_Respawns = register_cvar("spawn_times", "2"); }
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 will respawn in %s seconds!", 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]++; }
|