Raised This Month: $ Target: $400
 0% 

Respawn message fix


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Wolddal[A]
Member
Join Date: Sep 2010
Old 08-13-2013 , 13:03   Respawn message fix
Reply With Quote #1

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)
Wolddal[A] is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 08-13-2013 , 14:09   Re: Respawn message fix
Reply With Quote #2

I don't understand the problem. When the server is restarted the plugins will be reset aswell.
__________________

Last edited by Black Rose; 08-13-2013 at 14:10.
Black Rose is offline
Wolddal[A]
Member
Join Date: Sep 2010
Old 08-13-2013 , 15:33   Re: Respawn message fix
Reply With Quote #3

Quote:
Originally Posted by Black Rose View Post
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.
Wolddal[A] is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 08-13-2013 , 17:02   Re: Respawn message fix
Reply With Quote #4

use kill_task() when the round ends or when a new begins.

EDIT: I meant remove_task() of course.
__________________

Last edited by Black Rose; 08-13-2013 at 18:19.
Black Rose is offline
devWaleed
Member
Join Date: Apr 2013
Location: Karachi, Pakistan
Old 08-13-2013 , 17:15   Re: Respawn message fix
Reply With Quote #5

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?

Last edited by devWaleed; 08-13-2013 at 17:15.
devWaleed is offline
Send a message via Skype™ to devWaleed
Wolddal[A]
Member
Join Date: Sep 2010
Old 08-13-2013 , 17:30   Re: Respawn message fix
Reply With Quote #6

Quote:
Originally Posted by devWaleed View Post
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]
Wolddal[A] is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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