AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED] Team checking & random transfer players from one team to another (https://forums.alliedmods.net/showthread.php?t=222133)

groofshark 07-30-2013 08:10

[SOLVED] Team checking & random transfer players from one team to another
 
How can I check players in one team, e.g. terrorist team? I mean if players in terrorist team are less than or equal to 5 10 or 15 to perform a function. Also I would like to know how can I transfer randomly players from one team to another(T->CT)? When I understand how, also I would like to combine this 2 functions, e.g. if( terrorists < 5 ) ---> transfer 2 random players from T team in CT team.

YamiKaitou 07-30-2013 08:19

Re: Team checking & random transfer players from one team to another
 
Use get_players to count how many people are on one team. Then you can also use get_players to determine who to send over since you will have a list of players on that team

groofshark 07-30-2013 08:45

Re: Team checking & random transfer players from one team to another
 
Hmm that?
PHP Code:

public func(id)
{
    new 
Players[32], Num
    get_players
(PlayersNum"ae""TERRORIST")
        
    if( 
Num <= 10 )
    {
        new 
id
        id 
Players[random(Num)]
         
        
// is this method right? for transfer 3ts in ct team?
        
cs_set_user_team(idCS_TEAM_CT)
        
cs_set_user_team(idCS_TEAM_CT)
        
cs_set_user_team(idCS_TEAM_CT)
    }



YamiKaitou 07-30-2013 08:48

Re: Team checking & random transfer players from one team to another
 
Yes, except you are sending the same person to CT 3 times

groofshark 07-30-2013 09:37

Re: Team checking & random transfer players from one team to another
 
Hm, how can I send several terrorists in CT team?

YamiKaitou 07-30-2013 09:39

Re: Team checking & random transfer players from one team to another
 
cs_set_user_team(Players[random(Num)], CS_TEAM_CT)
cs_set_user_team(Players[random(Num)], CS_TEAM_CT)
cs_set_user_team(Players[random(Num)], CS_TEAM_CT)

groofshark 07-30-2013 09:42

Re: Team checking & random transfer players from one team to another
 
It is the same. I use:
Code:

id = Players[random(Num)]
and just replace
cs_set_user_team(Players[random(Num)], CS_TEAM_CT) with
cs_set_user_team(id, CS_TEAM_CT)

YamiKaitou 07-30-2013 09:44

Re: Team checking & random transfer players from one team to another
 
It is not the same

groofshark 07-30-2013 09:48

Re: Team checking & random transfer players from one team to another
 
Okay, I want to ask something else. Can you tell me how is the correct if/if else form?

PHP Code:

if( Num <= )
{
    ...
}
else if( 
Num <=10 )
{
    ...
}
else if( 
Num <= 15 )
{
    ...


Is that right?

YamiKaitou 07-30-2013 09:53

Re: Team checking & random transfer players from one team to another
 
That will work, not sure why you don't just test it yourself


All times are GMT -4. The time now is 15:54.

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