View Single Post
Amine Belokda
Senior Member
Join Date: Oct 2015
Location: ML_NOT_FOUND
Old 05-04-2017 , 14:09   Re: request auto revive with no wopen
Reply With Quote #12

Edit This
PHP Code:
#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_pCvarRespawnTimeg_pCvarRespawnDelayg_pCvarMaxHealth;

public 
plugin_init()
{
    
register_plugin("Auto Respawn""1.0""Amine Belokda"); 
    
RegisterHam(Ham_Killed"player""fwdPlayerKilledPost"1); // Player Killed
    
RegisterHam(Ham_Spawn"player""fwdPlayerSpawnPost"1); // Player Spawned
    
register_event("TeamInfo""eTeamInfo""a"); // Team Info
    
register_logevent"LogEventRoundStart"2"1=Round_Start" // Round Start
    
g_pCvarRespawnTime register_cvar("amx_respawn_tickets""5"); // 0 = Unlimited Respawn 
    
g_pCvarRespawnDelay register_cvar("amx_respawn_delay""1"); // Delay to respawn
    
g_pCvarMaxHealth register_cvar("amx_max_health""100"); // Health on respawn
    
g_Time_Interval register_cvar("amx_max_time""5"); // Time Left to respawn
    
set_msg_blockget_user_msgid"ClCorpse" ), BLOCK_SET );
    
    
g_SyncRestartTimer CreateHudSyncObj()
    
g_SyncGameStart CreateHudSyncObj()
    
}

public 
LogEventRoundStart()
{
    
RoundStartTime get_gametime()
    
    new 
iPlayers[32]
    new 
iNum
    
    get_players
iPlayersiNum )
    
    for( new 
0iNumi++ )
    {
        
g_iRespawn[iPlayers[i]] = true
    
}
    
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 
Runda_Terminata()
{
    if(
RoundStartTime)
    {
        
set_hudmessage255000.090.0010.51.00.515.0, -1)
        
ShowSyncHudMsg0g_SyncGameStart"Respawn plugin is disabled!")
    }
}

public 
fwdPlayerKilledPost(iVictimiKilleriShoudlGib)
{
    if(
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(iClientpev_healthget_pcvar_float(g_pCvarMaxHealth));
    }
}

public 
taskRespawnPlayer(id)
{
    if(
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_RoundRespawnid)
        
g_iRespawn[id] = false
        
return PLUGIN_HANDLED;
    }
    return 
PLUGIN_HANDLED;
}  

public 
eTeamInfo() 

    new 
iClient read_data(1);
    new 
szTeam[2];
    
read_data(2szTeamcharsmax(szTeam));
    switch(
szTeam[0])
    {
        case 
'T'
        {
            if(
g_TeamInfoCounter[iClient] == || g_iPlayerTeam[iClient] == CS_TEAM_SPECTATOR)
            {
                
set_task(get_pcvar_float(g_pCvarRespawnDelay), "taskRespawnPlayer",  iClient);
            }
            
g_iPlayerTeam[iClient] = CS_TEAM_T;
        }
        case 
'C'
        {
            if(
g_TeamInfoCounter[iClient] == || 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() 
{
    
g_counter++
    
    new 
Float:iRestartTime get_pcvar_float(g_Time_Interval) - g_counter
    
new Float:fSec
    fSec 
iRestartTime 
    
    set_hudmessage
255000.090.010.01.00.00.0, -1)
    
ShowSyncHudMsg0g_SyncRestartTimer"Remaining %d seconds of 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_counterszNum31)
    }
    if(
g_counter == get_pcvar_num(g_Time_Interval))
    {
        
g_counter 0
    
}

__________________
Amine Belokda is offline
Send a message via MSN to Amine Belokda