Raised This Month: $ Target: $400
 0% 

Can't teamswap dead players


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 11-05-2022 , 10:16   Re: Can't teamswap dead players
Reply With Quote #1

Never faced such problem, what version of amx are you using? Anyway, here are some corrections to your code.

Code:
public SwapTeams()
{
    new players[32];
    new playercount;
    get_players(players, playercount, "h"); // 'h' to not include hltv
    
    new i, id // do not create vars inside a loop
    for (i=0; i<playercount; i++)
    {
        id = players[i]

        if (cs_get_user_team(id) != CS_TEAM_SPECTATOR && cs_get_user_team(id) != CS_TEAM_UNASSIGNED) // You also check if he hasn't chosen any team yet, ie "unassigned".
        {
            cs_set_user_team(id, (cs_get_user_team(id) == CS_TEAM_T) ? CS_TEAM_CT : CS_TEAM_T)
        }
    }
}
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/
iceeedr is offline
Send a message via Skype™ to iceeedr
GoldNux
Senior Member
Join Date: Mar 2018
Old 11-05-2022 , 10:23   Re: Can't teamswap dead players
Reply With Quote #2

Quote:
Originally Posted by iceeedr View Post
Never faced such problem, what version of amx are you using? Anyway, here are some corrections to your code...
I use the latest version.
This worked for some reason:
Obviously not pretty..

Thanks for your reply.
I will test the code and try some more.
PHP Code:
public SwapTeams()
{
    new 
players[32];
    new 
playercount;
    
get_players(playersplayercount);
    
    new 
i
    
for (i=0i<playercounti++)
    {
        if (
cs_get_user_team(players[i]) == CS_TEAM_T)
        {
            
cs_set_user_team(players[i], CS_TEAM_CT)
        }
        else if (
cs_get_user_team(players[i]) == CS_TEAM_T)
        {
            
cs_set_user_team(players[i], CS_TEAM_T)
        }
    }


Last edited by GoldNux; 11-05-2022 at 10:24.
GoldNux 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 04:21.


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