Raised This Month: $ Target: $400
 0% 

Setting m_iNumRespawns + Supercede CS_RoundRespawn crashes?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-05-2018 , 15:12   Re: Setting m_iNumRespawns + Supercede CS_RoundRespawn crashes?
Reply With Quote #1

I don't know about other mods than cstrike, I would need the mod.so file to find out.
__________________
HamletEagle is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-05-2018 , 15:24   Re: Setting m_iNumRespawns + Supercede CS_RoundRespawn crashes?
Reply With Quote #2

Quote:
Originally Posted by HamletEagle View Post
I don't know about other mods than cstrike, I would need the mod.so file to find out.
EDIT: It must be something wrong with my InstallGameRules signature because my other plugin which uses it crashes the server too.

Code:
{
    "name" : "InstallGameRules",
    "library" : "mod",
	"return" :
	{
		"type" : "CGameRules *"
	},
    "identifiers":
    [
        {
            "os" : "windows",
			"mod" : "cstrike",
            "value" : [0x68,"*","*","*","*",0xFF,"*","*","*","*","*",0x83,"*","*",0xFF,"*","*","*","*","*",0xA1,"*","*","*","*",0xD9,"*","*",0xD8,"*","*","*","*","*",0xDF]
        },
        {
            "os" : "linux",
			"mod" : "cstrike",
            "value" : "_Z16InstallGameRulesv"
        }
    ]
}
No need, just wondered if you somehow knew, but it doesn't really matter. This is crashing my server, no error logs just this
Code:
./hlds_run: line 255: 26313 Segmentation fault(core dumped) $HL_CMD

PHP Code:
new g_pGameRules;

public 
plugin_precache( )
OrpheuRegisterHookOrpheuGetFunction"InstallGameRules" ), "OnInstallGameRules"OrpheuHookPost );

public 
plugin_init( )
{
    
OrpheuRegisterHookFromObjectg_pGameRules"FPlayerCanRespawn""CGameRules""@FPlayerCanRespawn" );
}

public 
OnInstallGameRules( )  

    
g_pGameRules OrpheuGetReturn( );  


public 
OrpheuHookReturn:@FPlayerCanRespawn(pGameRulesid)  
{  
    
OrpheuSetReturnfalse )  
    return 
OrpheuOverride;  

Full:
PHP Code:
#include < amxmodx >
#include < cstrike >
#include < hamsandwich >
#include < fakemeta >
#include < engine >
#include < cs_battleroyale_faketeams >
#include < orpheu >
#include < orpheu_stocks >

#define MAX_PLAYERS 32

#if AMXX_VERSION_NUM >= 182
#define CSW_GLOCK 2
#define client_disconnect client_disconnected
#endif

enum _:Tasks ( += 1000 )
{
    
TASK_1 1000,
    
TASK_2,
    
TASK_3
};

enum _:PlayerStats
{
    
Player_Kills,
    
Player_HeadShots,
Float:Player_Damage,

    
Player_StatsCount
};

new 
g_iSyncHudObject;
new 
g_iTime;
new 
g_iDummyResult;

new 
g_iFwRoundStart;
new 
g_iFwTeamDead;
new 
g_iFwRoundWinner;

new 
g_iCvarTimer;
new 
g_iCvarMinPlayers;
new 
g_iCvarSvRestart;

new 
g_pGameRules;

new 
g_iPlayerStatsMAX_PLAYERS ][ Player_StatsCount ];

new 
bool:g_bHasGameStarted;
new 
bool:g_bVictoryBlockAttack33 ];

const 
m_LastHitGroup 75;

const 
g_iSkip = ( << CSW_GLOCK ) | ( << CSW_C4 )

public 
plugin_precache( )
OrpheuRegisterHookOrpheuGetFunction"InstallGameRules" ), "OnInstallGameRules"OrpheuHookPost );

public 
plugin_init( )
{
    
register_plugin"CS Battle Royale Round Manager""2.0""DoNii" );
    
    
OrpheuRegisterHookFromObjectg_pGameRules"FPlayerCanRespawn""CGameRules""@FPlayerCanRespawn" );  
    
    
g_iFwRoundStart  CreateMultiForward"RoundStarted"ET_IGNORE                   );
    
g_iFwTeamDead    CreateMultiForward"TeamDead",     ET_IGNOREFP_CELLFP_CELL );
    
g_iFwRoundWinner CreateMultiForward"RoundWinner",  ET_IGNOREFP_CELL  );
    
    
g_iSyncHudObject CreateHudSyncObj( );
    
    
g_iCvarTimer register_cvar"csbr_round_timer""15" );
    
g_iCvarMinPlayers register_cvar"csbr_min_players""2" );
    
    
g_iCvarSvRestart get_cvar_pointer"sv_restartround" );
    
    
register_logevent"OnNewRound"2"1=Round_Start" );
    
    
RegisterHamHam_Killed"player""@HamKilled_Post");
    
RegisterHamHam_TakeDamage"player""@HamTakeDamage_Pre");
    
RegisterHamHam_CS_RoundRespawn"player""@HamCSRoundRespawn_Pre");
    
    new 
szWeaponName32 ];
    for( new 
CSW_P228<= CSW_P90i++ )
    {
        if( 
g_iSkip & ( << ) )
        continue;
        
        
get_weaponnameiszWeaponNamecharsmaxszWeaponName ) );
        
RegisterHamHam_Weapon_PrimaryAttackszWeaponName"@HamPrimaryAttack_Pre" );
    }
}

public 
plugin_natives( )
{
    
register_library"cs_battleroyale_roundmanager" );

    
register_native"HasGameStarted""OnNativeHasGameStarted");
    
register_native"IsLastTeam""OnNativeIsLastTeam");
    
register_native"GetTeamAlivePlayers""OnNativeGetTeamAlivePlayers");
    
register_native"GetRemainingTeams""OnNativeGetRemainingTeams");
}

public 
client_disconnectid )
{
    
ResetStatsid );

    if( 
GetAlivePlayers( ) < get_pcvar_numg_iCvarMinPlayers ) )
    {
        
RestartRound);
        
client_print0print_chat"Player left, restarting Round due to insufficient players" );
    }
    return 
PLUGIN_CONTINUE;
}

public 
OnInstallGameRules( )  

    
g_pGameRules OrpheuGetReturn( );  


public 
OrpheuHookReturn:@FPlayerCanRespawn(pGameRulesid)  
{  
    
OrpheuSetReturnfalse )  
    return 
OrpheuOverride;  


public @
HamCSRoundRespawn_Preid )
{
    if( 
g_bHasGameStarted || ! GetPlayerTeamid ) )
    return 
HAM_SUPERCEDE;
    
    return 
HAM_IGNORED;
}

@
HamTakeDamage_PreiVictimiInflictoriAttackerFloat:fDamageiDamageBits )
{
    if( ! 
g_bHasGameStarted )
    return 
HAM_SUPERCEDE;
    
    if( ! 
is_user_connectediAttacker ) )
    return 
HAM_IGNORED;
    
    if( ( 
iDamageBits DMG_BULLET ) || ( iDamageBits DMG_GENERIC ) )
    {
        
g_iPlayerStatsiAttacker ][ Player_Damage ] += fDamage;
        
        if( 
get_pdata_intiVictimm_LastHitGroup ) == HIT_HEAD )
        {
            
g_iPlayerStatsiAttacker ][ Player_HeadShots ]++;
        }
    }
    return 
HAM_IGNORED;
}

@
HamPrimaryAttack_PreiEnt )
{
    new 
id peviEntpev_owner );
    
    if( 
g_bVictoryBlockAttackid ] )
    {
        const 
m_bCanShoot 876/4;
        
        
set_pdata_intidm_bCanShootfalse );
        return 
HAM_SUPERCEDE;
    }
    return 
HAM_IGNORED;
}

public 
OnNewRound( )
{
    
EnableShooting( );

    
g_bHasGameStarted false;    
    
CleanTasks( );
    
    
g_iTime get_pcvar_numg_iCvarTimer );

    if( 
get_playersnum( ) < get_pcvar_numg_iCvarMinPlayers ) )
    {        
        
set_task1.0"OnTaskFindPlayers"TASK_2, .flags "b" );
    }
    
    else
    {
        
set_task1.0"OnTaskCountDown"TASK_1, .flags "b" );
    }
}

public 
OnTaskFindPlayers( )
{        
    if( 
GetAlivePlayers( ) >= get_pcvar_numg_iCvarMinPlayers ) )
    {        
        
RestartRound);
        
CleanTasks( );
    }
}

public 
OnTaskCountDown( )
{
    if( 
g_iTime <= )
    {
        
g_bHasGameStarted true;    
        
ExecuteForwardg_iFwRoundStartg_iDummyResult );
        
        
CleanTasks( );
    }
    
    else
    {
        
set_hudmessage025500.350.3500.01.1 )
        
ShowSyncHudMsg0g_iSyncHudObject"%L"LANG_PLAYER"ROUND_STARTS_IN"g_iTime--, ( g_iTime ) ? "s" "" );
    }
}

public @
HamKilled_PostiVictimiAttackeriShouldGib )
{
    if( 
g_bHasGameStarted )
    {
        new 
szClassName32 ];
        
peviAttackerpev_classnameszClassNamecharsmaxszClassName ) );
        
        if( 
GetTeamAlivePlayersGetPlayerTeamiVictim ) ) == )
        {
            
BetterLuckNextTimeiVictimGetPlayerTeamiVictim ) );
        }
        
        if( 
equalszClassName"player" ) && is_user_connectediAttacker ) )
        {
            if( 
iVictim != iAttacker )
            {
                
g_iPlayerStatsiAttacker ][ Player_Kills ]++;
            }
            
            if( 
IsLastTeamGetPlayerTeamiAttacker ) ) )
            {
                
Winner_DirectGetPlayerTeamiAttacker ) );
            }
        }
        
        else if( ! 
equalszClassName"player" ) || ! is_user_connectediAttacker ) )
        {
            if( 
GetRemainingTeams( ) == )
            
Winner_Find( );
        }
    }
    return 
HAM_IGNORED;
}

Winner_Find( )
{
    new 
iWinnerTeam;

    new 
szPlayers32 ], iNum;
    
get_playersszPlayersiNum"ah" );

    new 
iTempID;
    for( new 
iiNumi++ )
    {
        
iTempID szPlayers];

        
ShowMotdiTempID );
        
g_bVictoryBlockAttackiTempID ] = true;
        
        
iWinnerTeam GetPlayerTeamiTempID );
    }

    
iNum 0;
    
szPlayers] = EOS;
    
iTempID 0;

    if( 
GetPlayersInTeamiWinnerTeam ) > )
    {
        
get_playersszPlayersiNum"bh" );

        for( new 
iiNumi++ )
        {
            
iTempID szPlayers];

            
ShowMotdiTempID );
        }
    }
}

Winner_DirectiTeam )
{
    
g_bHasGameStarted false;
    
ExecuteForwardg_iFwRoundWinnerg_iDummyResultiTeam );

    
RestartRound);
    
    
client_print0print_center"%L"LANG_PLAYER"ROUND_WINNER"iTeam );
    
    new 
szPlayers32 ], iNum;
    
get_playersszPlayersiNum"h" );

    new 
iTempID;
    for( new 
iiNumi++ )
    {
        
iTempID szPlayers];

        if( 
GetPlayerTeamiTempID ) == iTeam )
        {
            
ShowMotdiTempID );
            
            if( 
is_user_aliveiTempID ) )
            
g_bVictoryBlockAttackiTempID ] = true;
        }
    }
}

ShowMotdid )
{
    new 
szMotdInfo512 ], szName32 ];
    
get_user_nameidszNamecharsmaxszName ) );

    
formatexszMotdInfocharsmaxszMotdInfo ), "<body bgcolor=^"black^"><font color=^"white^">Player Name: %s <br>Kills: %d <br>Damage: %.1f <br>Headshots: %d<br> <img src=^"https://res.cloudinary.com/teepublic/image/private/s--SOYOT-Oh--/t_Preview/b_rgb:000000,c_limit,f_jpg,h_630,q_90,w_630/v1531417103/production/designs/2883853_0.jpg^" height=^"324^" width=^"324^">", szName, g_iPlayerStats[ id ][ Player_Kills ], g_iPlayerStats[ id ][ Player_Damage ], g_iPlayerStats[ id ][ Player_HeadShots ] );
    
show_motdidszMotdInfo"Stats" );
    
    
ResetStatsid );
}

GetTeamAlivePlayersiTeam )
{
    new 
szPlayers32 ], iNumiTempIDiCount;
    
get_playersszPlayersiNum"ah" );
    
    for( new 
iiNumi++ )
    {
        
iTempID szPlayers];
        
        if( 
GetPlayerTeamiTempID ) == iTeam )
        {
            
iCount++;
        }
    }
    return 
iCount;
}

bool:IsLastTeamiTeam )
{
    new 
bool:bAnnounceWinner;
    
    for( new 
1<= GetMaxTeams( ); i++ )
    {
        if( 
iTeam == )
        continue;
        
        if( 
GetTeamAlivePlayers) <= )
        {
            
bAnnounceWinner true;
            continue;
        }
        
        else
        {
            
bAnnounceWinner false;
            break;
        }
    }
    
    return 
bAnnounceWinner;
}

GetAlivePlayers( )
{
    new 
szPlayers32 ], iNum;
    
get_playersszPlayersiNum"ah" );
    
    return 
iNum;
}

RestartRound( const iTime )
{
    
set_pcvar_numg_iCvarSvRestartiTime );
}  

BetterLuckNextTimeiPlayeriTeam )
{    
    
ExecuteForwardg_iFwTeamDeadg_iDummyResultiPlayeriTeam );

    if( 
GetPlayersInTeamiTeam ) > )
    {
        new 
szPlayers32 ], iNumiTempID;
        
get_playersszPlayersiNum"bh" );
        
        for( new 
iiNumi++ )
        {
            
iTempID szPlayers];
            
            if( ( 
GetPlayerTeamiTempID ) == GetPlayerTeamiPlayer ) ) )
            {
                
client_printiTempIDprint_center"%L"iTempID"YOUR_TEAM_PLACED"GetRemainingTeams( ) + );
            }
        }
    }
    
    else if( 
GetPlayerPerTeam( ) == )
    {
        
client_printiPlayerprint_center"%L"iPlayer"YOUR_TEAM_PLACED"GetRemainingTeams( ) + );
    }
}

GetRemainingTeams( )
{
    new 
iRemainingTeams;

    for( new 
iTeam 1iTeam <= GetMaxTeams( ); iTeam++ )
    {
        if( 
GetTeamAlivePlayersiTeam ) >= )
        {
            
iRemainingTeams++;
        }
    }
    return 
iRemainingTeams;
}

ResetStatsid )
{
    
g_iPlayerStatsid ][ Player_Damage ] = _:0.0;
    
g_iPlayerStatsid ][ Player_HeadShots ] = 0;
    
g_iPlayerStatsid ][ Player_Kills ] = 0;
}


CleanTasks( )
{
    
remove_taskTASK_1 );
    
remove_taskTASK_2 );
    
remove_taskTASK_3 );
}

EnableShooting( )
{
    new 
szPlayers32 ], iNum;
    
get_playersszPlayersiNum"h" );

    new 
iTempID;
    for( new 
iiNumi++ )
    {
        
iTempID szPlayers];

        
g_bVictoryBlockAttackiTempID ] = false;
    }
}

public 
OnNativeHasGameStarted( )
{
    return 
g_bHasGameStarted;
}

public 
OnNativeIsLastTeamiTeam )
{
    return 
IsLastTeamiTeam );
}

public 
OnNativeGetTeamAlivePlayersiTeam )
{
    return 
GetTeamAlivePlayersiTeam );
}

public 
OnNativeGetRemainingTeams( )
{
    return 
GetRemainingTeams( );

Signature
Code:
{
	"name" : "FPlayerCanRespawn",
	"class" : "CGameRules",
	"library" : "mod",
	"return" : 
	{
		"type" : "bool"
	},
	"arguments" : 
	[
		{
			"type" : "CBasePlayer *"
		}
	],
	"indexes" : 
	[
		{
			"os" : "windows",
			"mod" : "SvenCoop",
			"value" : 22
		},
		{
			"os" : "windows",
			"mod" : "cstrike",
			"value" : 22
		},
		{
			"os" : "linux",
			"mod" : "cstrike",
			"value" : 22
		},
		{
			"os" : "windows",
			"mod" : "dod",
			"value" : 20
		},
		{
			"os" : "linux",
			"mod" : "dod",
			"value" : 22
		},
		{
			"os" : "windows",
			"mod" : "valve",
			"value" : 20
		},
		{
			"os" : "linux",
			"mod" : "valve",
			"value" : 22
		},
		{
			"os" : "windows",
			"mod" : "ns",
			"value" : 20
		},
		{
			"os" : "linux",
			"mod" : "ns",
			"value" : 22
		},
		{
			"os" : "windows",
			"mod" : "ts",
			"value" : 19
		},
		{
			"os" : "linux",
			"mod" : "ts",
			"value" : 21
		},
		{
			"os" : "windows",
			"mod" : "tfc",
			"value" : 20
		},
		{
			"os" : "linux",
			"mod" : "tfc",
			"value" : 22
		}
	]
}
EDIT: 20 crashes too
__________________

Last edited by edon1337; 08-05-2018 at 15:50.
edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-05-2018 , 15:53   Re: Setting m_iNumRespawns + Supercede CS_RoundRespawn crashes?
Reply With Quote #3

It should be 20 for both windows and linux.
I'm using the exact same InstallGameRules signature, there must be something else that's responsible for the crash. On linux you can start the server with gdb and once it crashes write "bt full" to get some logs.
__________________

Last edited by HamletEagle; 08-05-2018 at 15:55.
HamletEagle is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-05-2018 , 15:59   Re: Setting m_iNumRespawns + Supercede CS_RoundRespawn crashes?
Reply With Quote #4

Quote:
Originally Posted by HamletEagle View Post
It should be 20 for both windows and linux.
I'm using the exact same InstallGameRules signature, there must be something else that's responsible for the crash. On linux you can start the server with gdb and once it crashes write "bt full" to get some logs.
It is 20 on both linux, windows.
Isn't access to root required to do this? If so, I don't have that kind of access.
https://forums.alliedmods.net/showthread.php?p=1412863
https://forums.alliedmods.net/showthread.php?t=1467
__________________

Last edited by edon1337; 08-05-2018 at 16:18.
edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-05-2018 , 16:27   Re: Setting m_iNumRespawns + Supercede CS_RoundRespawn crashes?
Reply With Quote #5

1.Comment all OrpheuRegisterHooks, see if it still crashes.
2.If not, uncomment and comment the code inside this hooks.
__________________
HamletEagle is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-05-2018 , 16:31   Re: Setting m_iNumRespawns + Supercede CS_RoundRespawn crashes?
Reply With Quote #6

Quote:
Originally Posted by HamletEagle View Post
1.Comment all OrpheuRegisterHooks, see if it still crashes.
2.If not, uncomment and comment the code inside this hooks.
I already knew Orpheu was causing this, and yes, it does. I commented the Orpheu part and it didn't crash.
__________________
edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-05-2018 , 17:10   Re: Setting m_iNumRespawns + Supercede CS_RoundRespawn crashes?
Reply With Quote #7

This doesn't answer. I wanted to know if its the hook itself or the code from the hook.
__________________
HamletEagle is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-05-2018 , 17:13   Re: Setting m_iNumRespawns + Supercede CS_RoundRespawn crashes?
Reply With Quote #8

You mean this?
PHP Code:
OrpheuRegisterHookFromObjectg_pGameRules"FPlayerCanRespawn""CGameRules""OnFPlayerCanRespawn" );  

/*public OrpheuHookReturn:OnFPlayerCanRespawn( pGameRules, id )  
{  
    OrpheuSetReturn( false )  
    return OrpheuOverride;  
}*/ 
__________________

Last edited by edon1337; 08-05-2018 at 17:14.
edon1337 is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-05-2018 , 17:20   Re: Setting m_iNumRespawns + Supercede CS_RoundRespawn crashes?
Reply With Quote #9

I did a step to step debugging thingy, it crashes when FPlayerCanRespawn is hooked, hooking InstallGameRules isnt the problem
__________________

Last edited by edon1337; 08-05-2018 at 17:20.
edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-05-2018 , 17:20   Re: Setting m_iNumRespawns + Supercede CS_RoundRespawn crashes?
Reply With Quote #10

You can not comment the entire function, you' ll get runtime errors. Comment only the code from the function.

Anyway, enough with this back and forth guessing. Give me some code I can test and get a crash(code should be minimal).
__________________

Last edited by HamletEagle; 08-05-2018 at 17:21.
HamletEagle 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 12:34.


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