Raised This Month: $32 Target: $400
 8% 

Divide teams in unbalanced teams.


Post New Thread Reply   
 
Thread Tools Display Modes
TheWhitesmith
Senior Member
Join Date: Oct 2017
Location: Morocco :c
Old 11-21-2017 , 13:44   Re: Divide teams in unbalanced teams.
Reply With Quote #11

This worked for me
PHP Code:
new szPlayers[32], iNum
    get_players
(szPlayersiNum"h")
    if(!
iNum) return;
    
    new 
iShark szPlayers[random(iNum)];
    
    for(new 
iiNumi++) {
        
cs_set_user_team(szPlayers[i], szPlayers[i] == iShark CS_TEAM_T CS_TEAM_CT);
    }

TheWhitesmith is offline
KiLLeR.
Senior Member
Join Date: Jul 2014
Location: Bulgaria
Old 11-21-2017 , 16:24   Re: Divide teams in unbalanced teams.
Reply With Quote #12

Quote:
Originally Posted by Natsheh View Post
PHP Code:
    iNum--;
    
szPlayers[rand] = szPlayers[iNum]; // 
I dont see any problem except if there's not any player heres an optimization
What the heck is this?! I cant think right now cuz i'm tired and i'm going to sleep, but I can't see any logic in this. And yeah, the problem comes from szPlayers which is not array.

Last edited by KiLLeR.; 11-21-2017 at 16:26.
KiLLeR. is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 11-21-2017 , 16:59   Re: Divide teams in unbalanced teams.
Reply With Quote #13

Quote:
Originally Posted by TheWhitesmith View Post
This worked for me
PHP Code:
new szPlayers[32], iNum
    get_players
(szPlayersiNum"h")
    if(!
iNum) return;
    
    new 
iShark szPlayers[random(iNum)];
    
    for(new 
iiNumi++) {
        
cs_set_user_team(szPlayers[i], szPlayers[i] == iShark CS_TEAM_T CS_TEAM_CT);
    }

Thanks, will use this.

Also, would this work then? need to know how to set the bool to true or flase then within the loop whenever he's a shark or not.

This compiles without errors & warnings.

Code:
isShark[szPlayers[i]] = iShark ? true : false
__________________

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

Quote:
Originally Posted by Napoleon_be View Post
Thanks, will use this.

Also, would this work then? need to know how to set the bool to true or flase then within the loop whenever he's a shark or not.

This compiles without errors & warnings.

Code:
isShark[szPlayers[i]] = iShark ? true : false
This gonna set everything to true or false, depends what number holds iShark.
If you want to set true only to player who is iShark then:
Code:
new id = szPlayers[i] if( iShark == id) isShark[id] = true else isShark[id] = false;

Last edited by KiLLeR.; 11-22-2017 at 05:20.
KiLLeR. is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 11-22-2017 , 05:55   Re: Divide teams in unbalanced teams.
Reply With Quote #15

Quote:
Originally Posted by KiLLeR. View Post
What the heck is this?! I cant think right now cuz i'm tired and i'm going to sleep, but I can't see any logic in this. And yeah, the problem comes from szPlayers which is not array.
I'm exluding the shark id from the szPlayers array
It will be alot better than checking if any of the players id matchs the shark
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
KiLLeR.
Senior Member
Join Date: Jul 2014
Location: Bulgaria
Old 11-22-2017 , 06:29   Re: Divide teams in unbalanced teams.
Reply With Quote #16

Quote:
Originally Posted by Natsheh View Post


I'm exluding the shark id from the szPlayers array
It will be alot better than checking if any of the players id matchs the shark
Yeah, now i got it and it's totally better, but I don't think executing time will be a lot different.
KiLLeR. is offline
TheWhitesmith
Senior Member
Join Date: Oct 2017
Location: Morocco :c
Old 11-22-2017 , 09:49   Re: Divide teams in unbalanced teams.
Reply With Quote #17

Quote:
Originally Posted by Napoleon_be View Post
Thanks, will use this.

Also, would this work then? need to know how to set the bool to true or flase then within the loop whenever he's a shark or not.

This compiles without errors & warnings.

Code:
isShark[szPlayers[i]] = iShark ? true : false
PHP Code:
isShark[szPlayers[i]] = szPlayers[i] == iShark true false 
If you are planning to make multiple players Sharks, this would work, if not then you might just do it when you get the random number.
TheWhitesmith is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 11-23-2017 , 05:13   Re: Divide teams in unbalanced teams.
Reply With Quote #18

Quote:
Originally Posted by TheWhitesmith View Post
PHP Code:
isShark[szPlayers[i]] = szPlayers[i] == iShark true false 
If you are planning to make multiple players Sharks, this would work, if not then you might just do it when you get the random number.
The thing is, id is left away with the optimization u gave me. So this is the only way i could think of setting the bool to true if the player is a shark and to false if not.

The only other way i can think of is this:

Code:
if(szPlayers[i] != iShark) {             isShark[szPlayers[i]] = false         }
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
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 16:05.


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