Kod: Tümünü seç
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <cstrike>
new g_counter
new g_SyncRestartTimer
new g_SyncGameStart
new Float:RoundStartTime
new g_Time_Interval;
const MAX_PLAYERS = 32;
new g_iRespawn[MAX_PLAYERS+1], g_TeamInfoCounter[MAX_PLAYERS+1], CsTeams:g_iPlayerTeam[MAX_PLAYERS+1];
new g_pCvarRespawnTime, g_pCvarRespawnDelay, g_pCvarMaxHealth;
new bool:g_bRoundActive = false;
public plugin_init()
{
register_plugin("Dr.Respawn", "1.3", "Vicious Vixen");
RegisterHam(Ham_Killed, "player", "fwdPlayerKilledPost", 1);
RegisterHam(Ham_Spawn, "player", "fwdPlayerSpawnPost", 1);
register_event("TeamInfo", "eTeamInfo", "a");
register_logevent("LogEventRoundStart", 2, "1=Round_Start")
register_logevent("LogEventRoundEnd", 2, "1=Round_End")
g_pCvarRespawnTime = register_cvar("amx_respawn_tickets", "0"); //Set to 0 for unlimited respawns
g_pCvarRespawnDelay = register_cvar("amx_respawn_delay", "1");
g_pCvarMaxHealth = register_cvar("amx_max_health", "100");
g_Time_Interval = register_cvar("amx_max_time", "30");
set_msg_block(get_user_msgid("ClCorpse"), BLOCK_SET);
g_SyncRestartTimer = CreateHudSyncObj()
g_SyncGameStart = CreateHudSyncObj()
}
public LogEventRoundStart()
{
RoundStartTime = get_gametime()
g_bRoundActive = true;
g_counter = 0;
new iPlayers[32], iNum
get_players(iPlayers, iNum)
for(new i = 0; i < iNum; i++)
{
g_iRespawn[iPlayers[i]] = true
}
remove_task(123456);
set_task(1.0, "TimeCounter", 123456, _, _, "a", get_pcvar_num(g_Time_Interval))
set_task(get_pcvar_float(g_Time_Interval), "Runda_Terminata", 789123)
}
public LogEventRoundEnd()
{
g_bRoundActive = false;
remove_task(123456);
remove_task(789123);
ClearSyncHud(0, g_SyncRestartTimer);
ClearSyncHud(0, g_SyncGameStart);
}
public Runda_Terminata()
{
if(g_bRoundActive)
{
set_hudmessage(255, 0, 0, 0.09, 0.00, 1, 0.5, 1.0, 0.5, 15.0, -1)
ShowSyncHudMsg(0, g_SyncGameStart, "Modul respawn este dezactivat!")
}
}
public fwdPlayerKilledPost(iVictim, iKiller, iShoudlGib)
{
if(g_bRoundActive && (g_iRespawn[iVictim]++ < get_pcvar_num(g_pCvarRespawnTime) || get_pcvar_num(g_pCvarRespawnTime) == 0))
{
set_task(get_pcvar_float(g_pCvarRespawnDelay), "taskRespawnPlayer", iVictim);
}
return HAM_IGNORED;
}
public fwdPlayerSpawnPost(iClient)
{
if(is_user_alive(iClient))
{
set_pev(iClient, pev_health, get_pcvar_float(g_pCvarMaxHealth));
}
}
public taskRespawnPlayer(id)
{
if(g_bRoundActive && is_user_connected(id) && RoundStartTime + get_pcvar_num(g_Time_Interval) >= get_gametime() && g_iRespawn[id] && !is_user_alive(id) && cs_get_user_team(id) != CS_TEAM_SPECTATOR) {
ExecuteHamB(Ham_CS_RoundRespawn, id)
g_iRespawn[id] = false
return PLUGIN_HANDLED;
}
return PLUGIN_HANDLED;
}
public eTeamInfo()
{
new iClient = read_data(1);
new szTeam[2];
read_data(2, szTeam, charsmax(szTeam));
switch(szTeam[0])
{
case 'T':
{
remove_task(iClient);
g_iPlayerTeam[iClient] = CS_TEAM_T;
}
case 'C':
{
if(g_TeamInfoCounter[iClient] == 2 || g_iPlayerTeam[iClient] == CS_TEAM_SPECTATOR)
{
set_task(get_pcvar_float(g_pCvarRespawnDelay), "taskRespawnPlayer", iClient);
}
g_iPlayerTeam[iClient] = CS_TEAM_CT;
}
case 'S':
{
remove_task(iClient);
g_iPlayerTeam[iClient] = CS_TEAM_SPECTATOR;
}
}
}
public TimeCounter()
{
if(!g_bRoundActive) return;
g_counter++
new Float:iRestartTime = get_pcvar_float(g_Time_Interval) - g_counter
new Float:fSec
fSec = iRestartTime
set_hudmessage(255, 0, 0, 0.09, 0.0, 1, 0.0, 1.0, 0.0, 0.0, -1)
ShowSyncHudMsg(0, g_SyncRestartTimer, "Au mai ramas %d secunde de respawn", floatround(fSec))
if(get_pcvar_num(g_Time_Interval) - g_counter < 11 && get_pcvar_num(g_Time_Interval) - g_counter !=0)
{
static szNum[32]
num_to_word(get_pcvar_num(g_Time_Interval) - g_counter, szNum, 31)
}
if(g_counter == get_pcvar_num(g_Time_Interval))
{
remove_task(123456);
}
}