AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Teamswitch Bug (https://forums.alliedmods.net/showthread.php?t=221245)

UchihaSkills 07-19-2013 15:56

Teamswitch Bug
 
Hey, on our furienmod when we are 15+ people and teamchanges after win/defuse what ever
people always gets kicked with message "
Reliable Channel Overflowed



and this in log

PHP Code:

Errorserver failed to transmit file 'AY&SYg******************'
Last 32 messages parsed.
71886 0090 TeamInfo
71886 0103 TeamInfo
71886 0109 TeamInfo
71886 0122 TeamInfo
71886 0135 svc_updateuserinfo
71886 0322 svc_updateuserinfo
71886 0494 svc_updateuserinfo
71886 0648 svc_updateuserinfo
71886 0810 svc_updateuserinfo
71886 0994 svc_updateuserinfo
71886 1190 svc_updateuserinfo
71886 1365 svc_updateuserinfo
71886 1541 svc_updateuserinfo
71886 1713 svc_updateuserinfo
71886 1936 svc_updateuserinfo
71886 2101 svc_updateuserinfo
71886 2256 svc_updateuserinfo
71886 2417 svc_updateuserinfo
71886 2578 svc_updateuserinfo
71886 2739 svc_updateuserinfo
71886 2926 svc_updateuserinfo
71886 3122 svc_updateuserinfo
71886 3306 svc_updateuserinfo
71886 3493 svc_updateuserinfo
71886 3689 svc_time
71886 3694 svc_clientdata
71886 3702 svc_deltapacketentities
71886 3747 svc_temp_entity
71894 0008 CurWeapon
71894 0012 CurWeapon
71894 0016 svc_filetxferfailed
BAD
:   27:svc_bad
Host_Error
CL_ParseServerMessageIllegible server message svc_bad 

Teamchange code:
PHP Code:

new iPlayers[32], iNumid
    get_players
(iPlayersiNum"h")

    for(new 
ii<iNumi++)
    {
        
id iPlayers[i]
        switch( 
get_pdata_int(idOFFSET_TEAMXTRA_OFS_PLAYERS) )
        {
            case 
TEAM_T:
            {
                
set_pdata_int(idOFFSET_TEAMTEAM_CTXTRA_OFS_PLAYERS)
            }
            case 
TEAM_CT:
            {
                
set_pdata_int(idOFFSET_TEAMTEAM_TXTRA_OFS_PLAYERS)
            }
        }
    } 

EDIT: Btw we also use alot of models which they get at spawn like, nade models, weapon models, skin models, 2 different knife models if they move and dont move, maybe it overflows cause of too many models?

ConnorMcLeod 07-19-2013 17:16

Re: TeamChange bug, please help
 
Try this and tell me :

PHP Code:

    new players[32], numid;
    
get_players(playersnum"h");

    new 
count;
    for(--
numnum>=0num--)
    {
        
id players[num];
        switch( 
get_pdata_int(idm_iTeam) )
        {
            case 
TEAM_T:
            {
                
set_pdata_int(idm_iTeamTEAM_CT);
                if( ++
count 20 )
                {
                    
dllfunc(DLLFunc_ClientUserInfoChangedidengfunc(EngFunc_GetInfoKeyBufferid));
                }
            }
            case 
TEAM_CT:
            {
                
set_pdata_int(idm_iTeamTEAM_T);
                if( ++
count 20 )
                {
                    
dllfunc(DLLFunc_ClientUserInfoChangedidengfunc(EngFunc_GetInfoKeyBufferid));
                }
            }
        }
    } 


UchihaSkills 07-19-2013 17:17

Re: TeamChange bug, please help
 
I will try it right now, can i also try it with BOTS now? cause we cant get over 16 players now.

ConnorMcLeod 07-19-2013 17:20

Re: TeamChange bug, please help
 
Dunno, i've tested with 31 bots, had crashes with previous code at 23 players, but no kicks.
With actual code; i have no crashes, so would be better if you could test with real players.

UchihaSkills 07-19-2013 17:22

Re: TeamChange bug, please help
 
Ok thx, we will test with bots now and tomorrow with Players, i will reply later or tomorrow if it works. and btw, Why does this bug in the code i use now appears?

UchihaSkills 07-19-2013 19:23

Re: TeamChange bug, please help
 
I get this error Connor
error 017: undefined symbol "m_iModelName"

ConnorMcLeod 07-19-2013 19:51

Re: TeamChange bug, please help
 
Use m_iInternalModel instead.

And try that one :

PHP Code:

#include < amxmodx >
#include < amxmisc >
#include < fakemeta >
#include < cstrike >

#pragma semicolon 1

#define PLUGIN ""
#define VERSION "0.0.1"

#define cm(%0)    ( sizeof(%0) - 1 )

const m_iTeam 114;
const 
m_iModelName 126;

enum _:teamIndexes
{
    
TEAM_UNASSIGNED 0,
    
TEAM_TERRORIST 1,
    
TEAM_CT 2,
    
TEAM_SPECTATOR 3
};

enum _:playerModelIndexes
{
    
CLASS_UNASSIGNED 0,
    
CLASS_URBAN 1,
    
CLASS_TERROR 2,
    
CLASS_LEET 3,
    
CLASS_ARCTIC 4,
    
CLASS_GSG9 5,
    
CLASS_GIGN 6,
    
CLASS_SAS 7,
    
CLASS_GUERILLA 8,
    
CLASS_VIP 9,
    
CLASS_MILITIA 10,
    
CLASS_SPETSNAZ 11
};

new 
g_iTeamModels[][] = 
{
    {
CLASS_TERRORCLASS_LEETCLASS_ARCTICCLASS_GUERILLACLASS_MILITIA},
    {
CLASS_URBANCLASS_GSG9CLASS_GIGNCLASS_SASCLASS_SPETSNAZ}
};

// new g_szTeamModels[][][] = 
// {
    // {"terror", "leet", "arctic", "guerilla", "militia"},
    // {"urban", "gsg9", "gign", "sas", "spetsnaz"}
// };

new g_iMaxModels 4;

new 
gmsgTeamInfo;

public 
plugin_init()
{
    
register_pluginPLUGINVERSION"ConnorMcLeod" );

    
register_logevent("Event_Round_End"2"1=Round_End");

    
gmsgTeamInfo get_user_msgid("TeamInfo");

    if( 
is_running("czero") )
    {
        
g_iMaxModels 5;
    }
}

public 
Event_Round_End()
{
    new 
players[32], numid;
    
get_players(playersnum"h");

    new 
count;
    for(--
numnum>=0num--)
    {
        
id players[num];
        switch( 
get_pdata_int(idm_iTeam) )
        {
            case 
TEAM_TERRORIST:
            {
                if( ++
count )
                {
                    
cs_set_user_team(idTEAM_CTg_iTeamModels[1][random(g_iMaxModels)]);
                }
                else
                {
                    
set_pdata_int(idm_iTeamTEAM_CT);
                    
set_pdata_int(idm_iModelNameg_iTeamModels[1][random(g_iMaxModels)]);
                    
set_task(0.1"SetPlayerModel"id);

                    
message_begin(MSG_ALLgmsgTeamInfo);
                    
write_byte(id);
                    
write_string("CT");
                    
message_end();
                }
            }
            case 
TEAM_CT:
            {
                if( ++
count )
                {
                    
cs_set_user_team(idTEAM_TERRORISTg_iTeamModels[0][random(g_iMaxModels)]);
                }
                else
                {
                    
set_pdata_int(idm_iTeamTEAM_TERRORIST);
                    
set_pdata_int(idm_iModelNameg_iTeamModels[0][random(g_iMaxModels)]);
                    
set_task(0.1"SetPlayerModel"id);
                    
                    
message_begin(MSG_ALLgmsgTeamInfo);
                    
write_byte(id);
                    
write_string("TERRORIST");
                    
message_end();
                }
            }
        }
    }
}

public 
SetPlayerModel(id)
{
    if( 
is_user_connected(id) )
    {
        
dllfunc(DLLFunc_ClientUserInfoChangedidengfunc(EngFunc_GetInfoKeyBufferid));
    }



UchihaSkills 07-19-2013 21:16

Re: TeamChange bug, please help
 
Hey Connor, we tested it and it works fine :).
Why is your code working and the old not? Where was the bug?
And big thanks to you conor you really helped us alot :)
i changed the thread name to xxxxxxx by mistake sorry :P

mottzi 07-19-2013 21:19

Re: TeamChange bug, please help
 
Thanks Connor for that piece, ill surely use that some day!
I have one question: Can you say that in the aspect of Server/Plugins a bot is the same as a player? Ive testet your Code with 31 Bots and it worked fine. Do you think it would also work fine with normal players instead of bots?

ConnorMcLeod 07-20-2013 05:11

Re: Teamswitch Bug
 
No, podbots (dunno for csbots) are setting their model (using set_user_info "model") before the 0.1 task has been executed, but in fine result is the same with that code.

cs_set_user_team is sending userinfochange (that sends set_user_info "model"), so half of players are proceeded like this, the other half is proceeded either on next frame or something like that for podbots, either when task is executed.

]UchihaSkills
In old code, "model" was updated on next frame for bots, and at spawn (new round) for players, so all at same time for bots and all at same time for players, result was that when there are too many bots, or too many players, server was crashing or players were kicked, at round end if too many bots, or at new round if too many players.


All times are GMT -4. The time now is 06:32.

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