Raised This Month: $12 Target: $400
 3% 

Solved Team swap causes server crash


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
RaZ_HU
Senior Member
Join Date: May 2015
Location: Hungary
Old 12-30-2017 , 16:03   Team swap causes server crash
Reply With Quote #1

Hey guys!

I have a strange problem with a really simple team swapper plugin.
If I use the command !forceswap then the server crashes at the end of the round.
In console.log the following message appears only:
Quote:
Segmentation fault
I have disabled every other plugin (both AMXX and metamod) but is still crashes.
This happens only on linux dedicated servers, BUT only on 2 server from the 4.
On my PC it doesn't crashes on Windows server (set up for testing).

Servers are all:
ReHLDS build 1210
ReGameDLL 5.3.0.218-dev
Metamod-r version 1.3.0.104

AMXX versions:
Tried both 1.8.3-dev+5117 and latest 1.8.3-dev+5151.

The plugin itself:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>

new bool:g_forcetrans
new g_iMaxPlayers

public plugin_init()
{
    
register_plugin"Chat Teamswap","0.1","Genesis, RaZ_HU" )

    
register_clcmd"say !forceswap""massive_transfer",ADMIN_BAN )

    
register_event"SendAudio""endRound""a""2=%!MRAD_terwin""2=%!MRAD_ctwin""2=%!MRAD_rounddraw" )
    
g_iMaxPlayers get_maxplayers()
}

public 
plugin_cfg()
{
    
g_forcetrans false
}

public 
endRound()
{
    if(
g_forcetrans == true)
    {
        for( new 
1g_iMaxPlayersi++ )
        {
            if( 
is_user_connected(i) )
            {
                if( 
cs_get_user_team(i) == CS_TEAM_CT )
                {
                    
cs_set_user_team(iCS_TEAM_T )
                }
                else if( 
cs_get_user_team(i) == CS_TEAM_T )
                {
                    
cs_set_user_team(iCS_TEAM_CT)
                }
            }
        }
        
g_forcetrans false
    
}

    return 
PLUGIN_HANDLED
}

public 
massive_transferid,level,cid )
{
    if (!
cmd_access(id,level,cid,0))
        return 
PLUGIN_HANDLED

    g_forcetrans 
true

    client_print_color
0,0,"^4[Information] ^3Teams will be^1swapped ^3in the next round!" )

    return 
PLUGIN_HANDLED


Any help appreciated

Last edited by RaZ_HU; 12-31-2017 at 14:26.
RaZ_HU is offline
soumyadip77
Senior Member
Join Date: Jul 2017
Location: INDIA,KOLKATA
Old 12-30-2017 , 21:05   Re: Team swap causes server crash
Reply With Quote #2

If you explain me what you need i can make it for you with reapi because whole team swap is possible in reapi useing less code so describe me
soumyadip77 is offline
Send a message via Skype™ to soumyadip77
WhiteFang1319
Senior Member
Join Date: Jan 2017
Old 12-31-2017 , 01:08   Re: Team swap causes server crash
Reply With Quote #3

Since you use ReHLDS and ReGameDLL it's better that you use ReAPI.
Here's one based on ReAPI.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <reapi>

new bool:g_forcetrans

public plugin_init()
{
    
register_plugin"Chat Teamswap","0.1","Genesis, RaZ_HU" )
    
register_clcmd"say !forceswap""massive_transfer",ADMIN_BAN )
    
register_event"SendAudio""endRound""a""2=%!MRAD_terwin""2=%!MRAD_ctwin""2=%!MRAD_rounddraw" )
}

public 
plugin_cfg()
{
    
g_forcetrans false
}

public 
endRound()
{
    if(
g_forcetrans == true)
    {
        
rg_swap_all_players() // Swaps all players
        
g_forcetrans false
    
}

    return 
PLUGIN_HANDLED
}

public 
massive_transferid,level,cid )
{
    if (!
cmd_access(id,level,cid,0))
        return 
PLUGIN_HANDLED

    g_forcetrans 
true

    client_print_color
0,0,"^4[Information] ^3Teams will be^1swapped ^3in the next round!" )

    return 
PLUGIN_HANDLED

Tested on ReHLDS 3.3.0.629 and ReGameDLL 5.3.0.279

Last edited by WhiteFang1319; 12-31-2017 at 01:10.
WhiteFang1319 is offline
RaZ_HU
Senior Member
Join Date: May 2015
Location: Hungary
Old 12-31-2017 , 05:28   Re: Team swap causes server crash
Reply With Quote #4

soumyadip77:
I wanted to do a simple team swap handled by admins if necessary (uneven team "skills" for example).
I know about PTB and balancers, but I don't need them, just a simple swap.


WhiteFang1319:
Thank you sir, I'm going to test it.

Edit:
Servers do still crash with segfault, no detailed error shown.
The problem is on the 2 server with the same server provider, while the other 2 are on diffrent ones.

Last edited by RaZ_HU; 12-31-2017 at 06:41.
RaZ_HU is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 12-31-2017 , 07:56   Re: Team swap causes server crash
Reply With Quote #5

https://forums.alliedmods.net/showthread.php?t=163555
__________________
Relaxing is offline
RaZ_HU
Senior Member
Join Date: May 2015
Location: Hungary
Old 12-31-2017 , 11:08   Re: Team swap causes server crash
Reply With Quote #6

Quote:
Originally Posted by Relaxing View Post
It works as it should, thank you.


Hero of the last day of 2017
RaZ_HU is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 12-31-2017 , 11:45   Re: Team swap causes server crash
Reply With Quote #7

Quote:
Originally Posted by RaZ_HU View Post
It works as it should, thank you.


Hero of the last day of 2017
Yaaaw me
__________________
Relaxing is offline
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 17:35.


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