Raised This Month: $64 Target: $400
 16% 

Divide teams in unbalanced teams.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Napoleon_be
AlliedModders Donor
Join Date: Jul 2011
Location: Belgium
Old 11-21-2017 , 11:33   Divide teams in unbalanced teams.
Reply With Quote #1

Hi there,

I'm currently making a new plugin. The part where i choose a random player from all the players is already done. The only thing i need to know is how to get all the other players and put them into the other team? This is what i got so far.

Code:
        new szPlayers, iNum     get_players(szPlayers, iNum, "h")         new iShark = szPlayers[random(iNum)]         cs_set_user_team(iShark, CS_TEAM_T)

This is what i've got for setting the rest into the other team, i just don't know if it's gonna work, i can't test it.

Code:
for(new i; i < iNum; i++) {         id = szPlayers[i]     }         if(id != iShark) {         cs_set_user_team(id, CS_TEAM_CT)     }
__________________

Last edited by Napoleon_be; 11-21-2017 at 11:35.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
KiLLeR.
Senior Member
Join Date: Jul 2014
Location: Bulgaria
Old 11-21-2017 , 11:52   Re: Divide teams in unbalanced teams.
Reply With Quote #2

The 2nd code must do that... What is the problem?
KiLLeR. is offline
Napoleon_be
AlliedModders Donor
Join Date: Jul 2011
Location: Belgium
Old 11-21-2017 , 12:05   Re: Divide teams in unbalanced teams.
Reply With Quote #3

Quote:
Originally Posted by KiLLeR. View Post
The 2nd code must do that... What is the problem?
Well the problem is that i can't test it... I've tried podbot plugin to add bots to the server but that plugin isn't working...

https://forums.alliedmods.net/showthread.php?t=51745
__________________

Last edited by Napoleon_be; 11-21-2017 at 12:06.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Natsheh
Veteran Member
Join Date: Sep 2012
Location: Muslim and proud!
Old 11-21-2017 , 12:16   Re: Divide teams in unbalanced teams.
Reply With Quote #4

PHP Code:
    new szPlayers[32], iNumrand;
    
get_players(szPlayersiNum"h")
    if(!
iNum) return;
    new 
iShark szPlayers[(rand=random(iNum))];
    
iNum--;
    
szPlayers[rand] = szPlayers[iNum]; 
    
    for(new 
iiNumi++) cs_set_user_team(szPlayers[i], CS_TEAM_CT);
    
cs_set_user_team(iSharkCS_TEAM_T
I dont see any problem except if there's not any player heres an optimization
__________________
@Jailbreak API MODE 100% done !
@User Tag Prefix 100% done !
@Mystery Box 100% done !

@Arena Mod 90% done !


Donate for more

Last edited by Natsheh; 11-21-2017 at 13:21.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Napoleon_be
AlliedModders Donor
Join Date: Jul 2011
Location: Belgium
Old 11-21-2017 , 12:19   Re: Divide teams in unbalanced teams.
Reply With Quote #5

Quote:
Originally Posted by Natsheh View Post
PHP Code:
    new szPlayersiNumrand;
    
get_players(szPlayersiNum"h")
    if(!
iNum) return;
    new 
iShark szPlayers[(rand=random(iNum))];
    
iNum--;
    
szPlayers[rand] = szPlayers[iNum]; 
    
    for(new 
iiNumi++) cs_set_user_team(szPlayers[i], CS_TEAM_CT);
    
cs_set_user_team(iSharkCS_TEAM_T
I dont see any problem except if there's not any player heres an optimization
The check to see if there are any players in the server is at client_putinserver & client_disconnect so that shouldn't be a problem.
__________________

Last edited by Napoleon_be; 11-21-2017 at 12:20.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
TheWhitesmith
Senior Member
Join Date: Oct 2017
Location: Morocco :c
Old 11-21-2017 , 13:21   Re: Divide teams in unbalanced teams.
Reply With Quote #6

I dont see a problem, should work correctly!
TheWhitesmith is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Location: Muslim and proud!
Old 11-21-2017 , 13:22   Re: Divide teams in unbalanced teams.
Reply With Quote #7

I just found out the problem that szPlayers is not an array of 32 slot
__________________
@Jailbreak API MODE 100% done !
@User Tag Prefix 100% done !
@Mystery Box 100% done !

@Arena Mod 90% done !


Donate for more
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
TheWhitesmith
Senior Member
Join Date: Oct 2017
Location: Morocco :c
Old 11-21-2017 , 13:23   Re: Divide teams in unbalanced teams.
Reply With Quote #8

I actually made a stock to test such things when I dont have players in my server, here is it:
PHP Code:
stock CreateBot(CsTeams:team, const szBotName[], bool:god) {

        if(
find_player("a"szBotName) > 0) {
            
log_to_file("BotSpawner.log""This bot's name is already taken! (%s)"szBotName)
            return -
1
        
}
        
        if(
team != CS_TEAM_CT && team != CS_TEAM_T) {
            
log_to_file("BotSpawner.log""Could not create bot, unknown team!")
            return -
1
        
}
        
        
            new 
id engfuncEngFunc_CreateFakeClientszBotName );
            if( 
pev_validid ) ) {
                
engfuncEngFunc_FreeEntPrivateDataid );
                
dllfuncMetaFunc_CallGameEntity"player"id );
                
set_user_infoid"rate""3500" );
                
set_user_infoid"cl_updaterate""25" );
                
set_user_infoid"cl_lw""1" );
                
set_user_infoid"cl_lc""1" );
                
set_user_infoid"cl_dlmax""128" );
                
set_user_infoid"cl_righthand""1" );
                
set_user_infoid"_vgui_menus""0" );
                
set_user_infoid"_ah""0" );
                
set_user_infoid"dm""0" );
                
set_user_infoid"tracker""0" );
                
set_user_infoid"friends""0" );
                
set_user_infoid"*bot""1" );
                
set_pevidpev_flagspevidpev_flags ) | FL_FAKECLIENT );
                
set_pevidpev_colormapid );
                
                new 
szMsg128 ];
                
dllfuncDLLFunc_ClientConnectidszBotName"127.0.0.1"szMsg );
                
dllfuncDLLFunc_ClientPutInServerid );
                
                
cs_set_user_teamidteam );
                
ExecuteHamBHam_CS_RoundRespawnid );
                
set_user_godmode(idgod 0)
                
set_pevidpev_effectspevidpev_effects ) | EF_NODRAW );
                
set_pevidpev_solidSOLID_NOT );
                
dllfuncDLLFunc_Thinkid );
                
                return 
id
            
}
            
    return -
1
        

returns id of bot created if success, else returns -1

Last edited by TheWhitesmith; 11-21-2017 at 13:24. Reason: removed something unnecessary in the code
TheWhitesmith is offline
TheWhitesmith
Senior Member
Join Date: Oct 2017
Location: Morocco :c
Old 11-21-2017 , 13:25   Re: Divide teams in unbalanced teams.
Reply With Quote #9

Quote:
Originally Posted by Natsheh View Post
I just found out the problem that szPlayers is not an array of 32 slot
Oh yeah, I didnt expect this
TheWhitesmith is offline
Napoleon_be
AlliedModders Donor
Join Date: Jul 2011
Location: Belgium
Old 11-21-2017 , 14:23   Re: Divide teams in unbalanced teams.
Reply With Quote #10

Well yea i tried to compile and stumbled across the problem you guys mentioned, this is already fixed.

Also TheWhitesmith, i'll try out your solution.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Reply


Thread Tools
Display Modes

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 09:19.


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