AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   scripting help team divide (https://forums.alliedmods.net/showthread.php?t=162101)

r0ck 07-15-2011 01:47

scripting help team divide
 
i wanted to know how can we divide a team say terrorists to two groups ? like half of terrorist's model be terror and half be guerilla ? like if admins say /team_up ? dont need full plugin just that part of script if number are odd then error like teams cannot be made due to odd number of terrorists

thanks

Hunter-Digital 07-15-2011 03:59

Re: scripting help team divide
 
Code:

new iPlayers = 11
new iExtraPlayers = iPlayers % 2

if(iExtraPlayers)
{
    // players can't be equally divided
}
else
{
    // players can be divided
}


r0ck 07-15-2011 08:05

Re: scripting help team divide
 
can you explain a bit more ?

Hunter-Digital 07-15-2011 09:13

Re: scripting help team divide
 
You said:
Quote:

Originally Posted by r0ck (Post 1510953)
dont need full plugin just that part of script if number are odd then error like teams cannot be made due to odd number of terrorists

And that code does that, asign "iPlayers" as the number of terrorists or whatever you need and the "iExtraPlayers" would be 0 if the number of terrorists can be divided by 2.
In the example code it can't be divided, so "iExtraPlayers" is 1.

r0ck 07-15-2011 13:07

Re: scripting help team divide
 
what am i doing wrong i want that even number of t's divide and 1 groups entity should have entity_set_int(Players[i], EV_INT_skin, random_num, 0) and other group entity_set_int(Players[i], EV_INT_skin, random_num, 1)

Exolent[jNr] 07-15-2011 13:18

Re: scripting help team divide
 
Quote:

Originally Posted by r0ck (Post 1511313)
PHP Code:

        new iExtraPlayers playerCount 2
        
        get_players
(PlayersplayerCount"ae""TERRORIST"

what am i doing wrong

You are checking player count before you get players.

r0ck 07-15-2011 13:31

Re: scripting help team divide
 
Quote:

Originally Posted by Exolent[jNr] (Post 1511318)
You are checking player count before you get players.


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
        {
            
entity_set_int(Players[i], EV_INT_skinrandom_num(01))
            
color_view(Players[i])
        }
    }



Exolent[jNr] 07-15-2011 13:33

Re: scripting help team divide
 
You have to loop through players. Your code is only affecting first player.

Hunter-Digital 07-15-2011 15:14

Re: scripting help team divide
 
Code:

for(new squad, player, i = 0; i < playerCount; i++)
{
    player = Players[i];
    squad = random_num(0, 1);

    entity_set_int(player, EV_INT_skin, squad)
    color_view(player)

    ColorChat(player, RED, "[JailBreak]^x04 You are now part of^x03 squad %d", (squad + 1))
}

And remove "i" variable from the external creation

r0ck 07-16-2011 00:08

Re: scripting help team divide
 
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 :)


All times are GMT -4. The time now is 00:57.

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