Raised This Month: $ Target: $400
 0% 

Last player replace (on disconnect) without round end?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LNATIC
Junior Member
Join Date: Sep 2012
Location: cstrike.h
Old 07-23-2014 , 21:01   Last player replace (on disconnect) without round end?
Reply With Quote #1

Hi all, as the title says.. how can I do this?

I have this code, but it does't work (the round ends anyway):
PHP Code:
public client_disconnect(id)  if(is_user_alive(id))     check_round(); // call check round function

check_round(){
    if(
g_bRoundEnd) return; // round ending bool (false on round start, true on round end)
    
static szName[32], randomplayerrandomplayer fnGetRandomPlayer();
    if(
fnGetTeamPlayers(1) == 1){
        
cs_set_user_team(randomplayerCS_TEAM_T); // change team
        
get_user_name(randomplayerszName31 ); // get the name
        
client_print(0,print_chat,"The last TT left, %s is the new TT",szName); // advertise which player
        
ExecuteHamB(Ham_CS_RoundRespawnrandomplayer); // respawn the new last player
    
}
}
fnGetTeamPlayers(team) {
    static 
iiPls;
    for (
0g_iMaxpli++){
        if (
is_user_connected(i)){
            switch(
team){
                case 
1:if (cs_get_user_team(i) == CS_TEAM_T)    iPls++;
                case 
2:if (cs_get_user_team(i) == CS_TEAM_CT)    iPls++;
            }
        }
    }
    return 
iPls;
}
fnGetRandomPlayer(){
    new 
iPlayers[32], iNum
    get_players
(iPlayersiNum"h")
    if( 
iNum <= )    return iPlayers[0]
    new 
iRandomNum random(iNum)
    new 
iRandomPlayer iPlayersiRandomNum ]
    if( 
iRandomPlayer == g_iLastChoosenPlayer ){
        
iPlayersiRandomNum ] = iPlayers[ --iNum ]
        
iRandomPlayer iPlayersrandom(iNum) ]
    }
    
g_iLastChoosenPlayer  iRandomPlayer
    
return iRandomPlayer

LNATIC is offline
Eagle07
Veteran Member
Join Date: May 2014
Location: Morocco :D
Old 07-23-2014 , 22:59   Re: Last player replace (on disconnect) without round end?
Reply With Quote #2

Try
PHP Code:
public client_disconnect(id)

    if(!
g_bRoundEnd)
    static 
szName[32], randomplayer
    
new new_terr players[random(pnum)]
    if(
fnGetTeamPlayers(1) == 1){ 
        
cs_set_user_team(new_terrCS_TEAM_T);
        
get_user_name(new_terrszName31 ); // get the name 
        
client_print(0,print_chat,"The last TT left, %s is the new TT",szName); // advertise which player 
        
ExecuteHamB(Ham_CS_RoundRespawnnew_terr); // respawn the new last player 
    


fnGetTeamPlayers(team) { 
    static 
iiPls
    for (
0g_iMaxpli++){ 
        if (
is_user_connected(i)){ 
            switch(
team){ 
                case 
1:if (cs_get_user_team(i) == CS_TEAM_T)    iPls++; 
                case 
2:if (cs_get_user_team(i) == CS_TEAM_CT)    iPls++; 
            } 
        } 
    } 
    return 
iPls

__________________
Eagle07 is offline
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 07-24-2014 , 04:01   Re: Last player replace (on disconnect) without round end?
Reply With Quote #3

Really?

PHP Code:
0is_user_connected(i)
32 /*maxplayers*/ // what about player #32 
Plus, iPls value is statically declared and will never reset.
__________________

Last edited by claudiuhks; 07-24-2014 at 04:03.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
LNATIC
Junior Member
Join Date: Sep 2012
Location: cstrike.h
Old 07-24-2014 , 15:14   Re: Last player replace (on disconnect) without round end?
Reply With Quote #4

Quote:
Originally Posted by claudiuhks View Post
Really?

PHP Code:
0is_user_connected(i)
32 /*maxplayers*/ // what about player #32 
Plus, iPls value is statically declared and will never reset.
Oops haha I missed it, thanks for your answer and sorry

EDIT: Thank you too Eagle07, your code works

Last edited by LNATIC; 07-24-2014 at 16:21. Reason: Solved
LNATIC is offline
Old 07-24-2014, 17:55
Eagle07
This message has been deleted by YamiKaitou. Reason: pointless posts
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 13:15.


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