AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Respawn message fix (https://forums.alliedmods.net/showthread.php?t=223431)

Wolddal[A] 08-13-2013 13:03

Respawn message fix
 
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("Dr.Respawn""1.2""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" )
    
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_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"Modul respawn este dezactivat!")
    }
}

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'
        {
            
remove_task(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"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_counterszNum31)
    }
    if(
g_counter == get_pcvar_num(g_Time_Interval))
    {
        
g_counter 0
    
}


The problem is that if the server restarts, the message rewrites.(So the initial message doesn't dissapear, and I want when the server restarts to reset the message with counting seconds too)

Black Rose 08-13-2013 14:09

Re: Respawn message fix
 
I don't understand the problem. When the server is restarted the plugins will be reset aswell.

Wolddal[A] 08-13-2013 15:33

Re: Respawn message fix
 
Quote:

Originally Posted by Black Rose (Post 2012292)
I don't understand the problem. When the server is restarted the plugins will be reset aswell.

Lol, I dint explain well.

So, when the round starts, the countdown it starting [in hud message], but if the round restarts, another countdown appears and it overlaps with the other one.
I want if the round restarts, the initial countdown to dissapear, and remain just one.

Black Rose 08-13-2013 17:02

Re: Respawn message fix
 
use kill_task() when the round ends or when a new begins.

EDIT: I meant remove_task() of course.

devWaleed 08-13-2013 17:15

Re: Respawn message fix
 
I think you're saying that. 1 task shows, but on new round another task show + old task.

On new round or on round end use remove_task(task_id);

Will this work?

Wolddal[A] 08-13-2013 17:30

Re: Respawn message fix
 
Quote:

Originally Posted by devWaleed (Post 2012462)
I think you're saying that. 1 task shows, but on new round another task show + old task.

On new round or on round end use remove_task(task_id);

Will this work?

It works, thanks, but now when the countdown is over, it starts over again [even though a new round hasn't started]


All times are GMT -4. The time now is 15:47.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.