Raised This Month: $ Target: $400
 0% 

scripting help team divide


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
r0ck
Senior Member
Join Date: Jun 2011
Location: India
Old 07-16-2011 , 00:08   Re: scripting help team divide
Reply With Quote #1

PHP Code:
public team_up(id
{

    if (
cs_get_user_team(id) == CS_TEAM_CT && is_user_alive(id))
    {
        
        new 
playerCount
        
new Players[32
            
        
get_players(PlayersplayerCount"ae""TERRORIST"
        
        new 
iExtraPlayers playerCount 2
        
        
if (iExtraPlayers
        {
            
ColorChat(idRED"[JailBreak]^x04 Cannot Divide the^x03 Team^x04")
        }
        else
        {
            for(new 
squadplayer0playerCounti++)
            {
                
player Players[i];
                
squad random_num(01);

                
entity_set_int(playerEV_INT_skinsquad)
                
color_view(player)

                
ColorChat(0RED"[JailBreak]^x04 %s Divided^x03 The team^x04",id)
            }    
        }
    }

Thanks its working
r0ck is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 07-16-2011 , 10:27   Re: scripting help team divide
Reply With Quote #2

Either get ColorChat() out of the loop or use player instead of 0, because it will repeat.
__________________
Hunter-Digital is offline
r0ck
Senior Member
Join Date: Jun 2011
Location: India
Old 07-16-2011 , 11:09   Re: scripting help team divide
Reply With Quote #3

Quote:
Originally Posted by Hunter-Digital View Post
Either get ColorChat() out of the loop or use player instead of 0, because it will repeat.
ya already fixed it and thanks
r0ck is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-16-2011 , 19:23   Re: scripting help team divide
Reply With Quote #4

Also, "id" is the player index.
If you wanted to print the name, you would have to use get_user_name() and pass the string result.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
r0ck
Senior Member
Join Date: Jun 2011
Location: India
Old 07-17-2011 , 09:02   Re: scripting help team divide
Reply With Quote #5

Quote:
Originally Posted by Exolent[jNr] View Post
Also, "id" is the player index.
If you wanted to print the name, you would have to use get_user_name() and pass the string result.
actualy i removed that line not needed ...
PHP Code:
public team_up(id
{

    if (
cs_get_user_team(id) == CS_TEAM_CT && is_user_alive(id))
    {
        
        new 
playerCount
        
new Players[32
            
        
get_players(PlayersplayerCount"ae""TERRORIST"
        
        new 
iExtraPlayers playerCount 2
        
        
if (iExtraPlayers
        {
            
ColorChat(idRED"^x04[JailBreak]^x01 Cannot Divide the^x03 Team due to odd number of Terrorists^x04")
        }
        else
        {
            for(new 
squadplayer0playerCounti++)
            {
                
player Players[i];
                
squad random_num(01);

                
entity_set_int(playerEV_INT_skinsquad)
                
color_view(player)
            }
        }
    }

1 more error its not dividing into equall its ramdom some times it does equal division sometimes no i want half of them ev_int_skin to be 0 and half of them ev_int_skin to be 1 but its totally ramdom
r0ck is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 07-17-2011 , 15:12   Re: scripting help team divide
Reply With Quote #6

To keep the randomization process but make the squads equal:
Code:
for(new maxPerSquad = (playerCount / 2), squads[2], squad, player, i = 0; i < playerCount; i++)
{
    player = Players[i]
    squad = random_num(0, 1)

    if(squads[squad] >= maxPerSquad)
       squad = !squad
    else
       squads[squad]++

    entity_set_int(player, EV_INT_skin, squad)
    color_view(player)
}
Basically this randomizes squad numbers until one squad has half of the terrorists, when that happens, the rest of players are assigned to the other squad which has less players.

You can create those variables outside of the loop if you need them further in the code tough.
__________________

Last edited by Hunter-Digital; 07-17-2011 at 15:14.
Hunter-Digital is offline
r0ck
Senior Member
Join Date: Jun 2011
Location: India
Old 07-18-2011 , 08:40   Re: scripting help team divide
Reply With Quote #7

Quote:
Originally Posted by Hunter-Digital View Post
To keep the randomization process but make the squads equal:
Code:
for(new maxPerSquad = (playerCount / 2), squads[2], squad, player, i = 0; i < playerCount; i++)
{
    player = Players[i]
    squad = random_num(0, 1)

    if(squads[squad] >= maxPerSquad)
       squad = !squad
    else
       squads[squad]++

    entity_set_int(player, EV_INT_skin, squad)
    color_view(player)
}
Basically this randomizes squad numbers until one squad has half of the terrorists, when that happens, the rest of players are assigned to the other squad which has less players.

You can create those variables outside of the loop if you need them further in the code tough.
THANKS!!! working
r0ck 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 00:57.


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