Raised This Month: $ Target: $400
 0% 

CS_TerminateRound and Round_end problem


Post New Thread Reply   
 
Thread Tools Display Modes
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 08-26-2013 , 21:58   Re: CS_TerminateRound and Round_end problem
Reply With Quote #11

PHP Code:
public Action:CS_OnTerminateRound(&Float:delay, &CSRoundEndReason:reason

    
//This has priority, it won't fire unless the round is starting or something bad happened and it has to restart the round. 
    
if(reason == CSRoundEnd_GameStart
        return 
Plugin_Continue
     
     
PrintToChatAll("CS_OnTerminateRound.Debug: Reason? %d"reason);
    
//Was a reason other than CT win passed? If so, we gotta fix that shit. 
    
if(reason != CSRoundEnd_CTWin
    { 
        new 
iLivingBlues
        for(new 
1<= MaxClientsi++) 
        { 
            
//Not ingame? Don't care. Not on CT? Don't care. Dead? Don't care. 
            
if(!IsClientInGame(i) || GetClientTeam(i) != CS_TEAM_CT || !IsPlayerAlive(i)) 
                continue; 
                 
            
iLivingBlues++; 
        }
        
PrintToChatAll("CS_OnTerminateRound.Debug: LivingCT? %d"iLivingBlues);
         
        
//If there are any living CTs, make them the winner 
        
if(iLivingBlues)
        {
            
reason CSRoundEnd_CTWin
 return 
Plugin_Changed;
}
    } 

    return 
Plugin_Continue

You should get in the habit of doing basic debugging such as this. See what gets printed.
__________________

Last edited by thetwistedpanda; 08-26-2013 at 22:53.
thetwistedpanda is offline
XHeadHunterX
Member
Join Date: Aug 2013
Old 08-26-2013 , 22:03   Re: CS_TerminateRound and Round_end problem
Reply With Quote #12

Maybe there could be an easier way with mp_ignore_round_win_conditions 1? But I guess CS_OnTerminateRound won't apply since the round doesn't end, and it would probably be the same for round_end.

Edit : Didn't see your reply, will check it now

Last edited by XHeadHunterX; 08-26-2013 at 22:04.
XHeadHunterX is offline
XHeadHunterX
Member
Join Date: Aug 2013
Old 08-26-2013 , 22:12   Re: CS_TerminateRound and Round_end problem
Reply With Quote #13

It gives reason = 12 and livingct = 1 at first round and reason = 9 and livingct = 1 next round. What I find extremely weird is why the round changes from 30 sec to 3 min at the third round. Maybe it would be better if use the mp_ignore_round_win_conditions 1 as I said and force the round ending with either CSRoundEnd_CTWin or CSRoundEnd_TerroristWin
XHeadHunterX is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 08-26-2013 , 22:22   Re: CS_TerminateRound and Round_end problem
Reply With Quote #14

From cstrike.inc. Increase by one for each entry.
PHP Code:
enum CSRoundEndReason
{
    
CSRoundEnd_TargetBombed 0,           // Target Successfully Bombed!
    
CSRoundEnd_VIPEscaped,                 // The VIP has escaped!
    
CSRoundEnd_VIPKilled,                  // VIP has been assassinated!
    
CSRoundEnd_TerroristsEscaped,          // The terrorists have escaped!
    
CSRoundEnd_CTStoppedEscape,            // The CTs have prevented most of the terrorists from escaping!
    
CSRoundEnd_TerroristsStopped,          // Escaping terrorists have all been neutralized!
    
CSRoundEnd_BombDefused,                // The bomb has been defused!
    
CSRoundEnd_CTWin,                      // Counter-Terrorists Win!
    
CSRoundEnd_TerroristWin,               // Terrorists Win!
    
CSRoundEnd_Draw,                       // Round Draw!
    
CSRoundEnd_HostagesRescued,            // All Hostages have been rescued!
    
CSRoundEnd_TargetSaved,                // Target has been saved!
    
CSRoundEnd_HostagesNotRescued,         // Hostages have not been rescued!
    
CSRoundEnd_TerroristsNotEscaped,       // Terrorists have not escaped!
    
CSRoundEnd_VIPNotEscaped,              // VIP has not escaped!
    
CSRoundEnd_GameStart,                  // Game Commencing!
    
    // The below only exist on CS:GO
    
CSRoundEnd_TerroristsSurrender,        // Terrorists Surrender
    
CSRoundEnd_CTSurrender,                // CTs Surrender
}; 
So 12 = CSRoundEnd_HostagesNotRescued and 9 = CSRoundEnd_Draw. :X

Edit: Make sure you're using the edited version where return Plugin_Changed is used. I forgot it twice. Drifter found it >.<.
__________________

Last edited by thetwistedpanda; 08-26-2013 at 22:55.
thetwistedpanda is offline
XHeadHunterX
Member
Join Date: Aug 2013
Old 08-30-2013 , 19:06   Re: CS_TerminateRound and Round_end problem
Reply With Quote #15

I tried the updated code and it works, thanks! The only thing is it doesn't add a point to the ct team. Does that mean that changing the reason does not add points but only shows a different win panel?
XHeadHunterX is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 08-30-2013 , 19:34   Re: CS_TerminateRound and Round_end problem
Reply With Quote #16

You can just manually increase the team count with SetTeamScore or whatever it's called. You're only changing the reason, it likely doesn't call anything else within the engine that would have been called for a natural CT win, or it does so too late. That's beyond me.
__________________

Last edited by thetwistedpanda; 08-30-2013 at 19:34.
thetwistedpanda is offline
Dr!fter
The Salt Boss
Join Date: Mar 2007
Old 08-30-2013 , 22:01   Re: CS_TerminateRound and Round_end problem
Reply With Quote #17

Quote:
Originally Posted by XHeadHunterX View Post
I tried the updated code and it works, thanks! The only thing is it doesn't add a point to the ct team. Does that mean that changing the reason does not add points but only shows a different win panel?
Quote:
Originally Posted by thetwistedpanda View Post
You can just manually increase the team count with SetTeamScore or whatever it's called. You're only changing the reason, it likely doesn't call anything else within the engine that would have been called for a natural CT win, or it does so too late. That's beyond me.

Just to expand on what panda said, before terminate round the game already adds a round to the team that won. So you have to make sure to subtract one from the terrorists if they won. CS_SetTeamScore is what you want.
Dr!fter is offline
XHeadHunterX
Member
Join Date: Aug 2013
Old 09-01-2013 , 13:55   Re: CS_TerminateRound and Round_end problem
Reply With Quote #18

The weird thing is, if the ct win the first round, it adds a point to the terrorist team, but if ct wins again, it won't add points to any team, and if ct lose, then they receive the points they should have had. That is what happens with this code

PHP Code:
public Action:CS_OnTerminateRound(&Float:delay, &CSRoundEndReason:reason

    
//This has priority, it won't fire unless the round is starting or something bad happened and it has to restart the round. 
    
if(reason == CSRoundEnd_GameStart
        return 
Plugin_Continue

    
//Was a reason other than CT win passed? If so, we gotta fix that shit. 
    
if(reason != CSRoundEnd_CTWin
    { 
        new 
iLivingBlues
        for(new 
1<= MaxClientsi++) 
        { 
            
//Not ingame? Don't care. Not on CT? Don't care. Dead? Don't care. 
            
if(!IsClientInGame(i) || GetClientTeam(i) != CS_TEAM_CT || !IsPlayerAlive(i)) 
                continue; 
            
            
iLivingBlues++; 
        }
            
        
//If there are any living CTs, make them the winner 
        
if(iLivingBlues)
        {
            
reason CSRoundEnd_CTWin
            
CS_SetTeamScore(3,CS_GetTeamScore(3)+1)
            return 
Plugin_Changed;
        }
    }
    return 
Plugin_Continue

Maybe it would be easier if I just ignore the round win conditions and start a timer each round and force the reason of win at the end of the timer

Last edited by XHeadHunterX; 09-01-2013 at 13:57.
XHeadHunterX 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 02:20.


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