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

Can't teamswap dead players


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GoldNux
Senior Member
Join Date: Mar 2018
Old 11-05-2022 , 09:39   Can't teamswap dead players
Reply With Quote #1

It swaps players that are alive but non dead.
Not sure why, I have tried many different ways.

PHP Code:
public SwapTeams()
{
    new 
players[32];
    new 
playercount;
    
get_players(playersplayercount);
    
    new 
i
    
for (i=0i<playercounti++)
    {
        new 
id players[i]
        if (!
is_user_hltv(id) && cs_get_user_team(id) != CS_TEAM_SPECTATOR)
        {
            
cs_set_user_team(id, (cs_get_user_team(id) == CS_TEAM_T) ? CS_TEAM_CT CS_TEAM_T)
        }
    }

GoldNux is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 11-05-2022 , 10:16   Re: Can't teamswap dead players
Reply With Quote #2

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 #3

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
Old 11-05-2022, 10:32
GoldNux
This message has been deleted by GoldNux.
GoldNux
Senior Member
Join Date: Mar 2018
Old 11-05-2022 , 11:03   Re: Can't teamswap dead players
Reply With Quote #4

Adding user_silentkill(id) solved this problem for me!
edit: nvm it did not.. wtf

There seems to be something wrong with cs_get_user_team when player is dead.

This works:
cs_set_user_team(id, CS_TEAM_CT)

This does not:
cs_set_user_team(id, (cs_get_user_team(id) == CS_TEAM_T) ? CS_TEAM_CT : CS_TEAM_T)

I printed the value of cs_get_user_team and got: thrun_crash_future
Then I ran it again and it printed: ngelevel_mapname

get_players(players, playercount, "he", "T") Does also not seem to be working properly.
Damn, I'm lost.

For some reason I could use this:
cs_set_user_team(id, (cs_get_user_team(id) == CS_TEAM_T) ? CS_TEAM_CT : CS_TEAM_T)

in a function triggered by the Ham_Killed...

Last edited by GoldNux; 11-05-2022 at 13:36.
GoldNux is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 11-06-2022 , 08:17   Re: Can't teamswap dead players
Reply With Quote #5

What amxx compiler version are you using?
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 11-06-2022 at 08:29.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
GoldNux
Senior Member
Join Date: Mar 2018
Old 11-06-2022 , 09:41   Re: Can't teamswap dead players
Reply With Quote #6

Quote:
Originally Posted by Natsheh View Post
What amxx compiler version are you using?
I installed AMX Mod X Full Installer v1.8.2
GoldNux is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 11-06-2022 , 11:24   Re: Can't teamswap dead players
Reply With Quote #7

That's why you've problems in your plugins because you're using an old compiler probably using compiler version 1.8.1
__________________
@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
GoldNux
Senior Member
Join Date: Mar 2018
Old 11-07-2022 , 11:41   Re: Can't teamswap dead players
Reply With Quote #8

Quote:
Originally Posted by Natsheh View Post
That's why you've problems in your plugins because you're using an old compiler probably using compiler version 1.8.1
I am now using 1.8.3 and it still does not transfer dead players.
I am using the map spawns editor, do you think it might affect my plugin?
GoldNux is offline
GoldNux
Senior Member
Join Date: Mar 2018
Old 11-07-2022 , 12:02   Re: Can't teamswap dead players
Reply With Quote #9

I tried this stupid solution but it crashed my server:
I also tried calling the function from:

register_logevent( "SwapAlivePlayers", 2, "1=Round_End" );

Instead of:

register_event("SendAudio", "SwapAlivePlayers", "a", "2&%!MRAD_terwin")
register_event("SendAudio", "SwapAlivePlayers", "a", "2&%!MRAD_ctwin")

Still does not work so seems to be an issue with seting dead players.
Can someone test on their system? :S

PHP Code:
public SwapAlivePlayers()
{
    new 
players[32];
    new 
playercount;
    
get_players(playersplayercount"h");
    
    new 
iid
    
for (i=0i<playercounti++)
    {
        
id players[i];
        new 
playerTeam cs_get_user_team(id);
        if (
playerTeam != CS_TEAM_SPECTATOR && playerTeam != CS_TEAM_UNASSIGNED)
        {
            if (
playerTeam == CS_TEAM_T)
            {
                
engclient_cmd(id"jointeam""2");
                
engclient_cmd(id"joinclass""5");
            }
            else
            {
                
engclient_cmd(id"jointeam""1");
                
engclient_cmd(id"joinclass""5");
            }
        }
    }


Last edited by GoldNux; 11-07-2022 at 12:18.
GoldNux is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 11-07-2022 , 13:51   Re: Can't teamswap dead players
Reply With Quote #10

use the same amxx compiler version as your amxx mod in your server.
also use the latest amxx version which is 1.10 or 1.9
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 11-07-2022 at 13:51.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Reply


Thread Tools
Display Modes

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 03:23.


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