Raised This Month: $ Target: $400
 0% 

Setting m_iNumRespawns + Supercede CS_RoundRespawn crashes?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-05-2018 , 05:47   Setting m_iNumRespawns + Supercede CS_RoundRespawn crashes?
Reply With Quote #1

Why does this
PHP Code:
const m_iNumRespawns 365;

public 
plugin_init( )
{
    
RegisterHamHam_CS_RoundRespawn"player""@HamCSRoundRespawn_Pre");
}

public 
client_putinserverid )
{
    
set_pdata_intidm_iNumRespawns);
}

@
HamCSRoundRespawn_Preid )
{
    
log_to_file"Ham.txt""Blocking %d",id );

    return 
HAM_SUPERCEDE;

Crash my game, and this not?
PHP Code:
const m_iNumRespawns 365;

public 
plugin_init( )
{
    
RegisterHamHam_CS_RoundRespawn"player""@HamCSRoundRespawn_Pre");
}

/*public client_putinserver( id )
{
    set_pdata_int( id, m_iNumRespawns, 1 );
}*/

@HamCSRoundRespawn_Preid )
{
    
log_to_file"Ham.txt""Blocking %d",id );

    return 
HAM_SUPERCEDE;

__________________
edon1337 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-05-2018 , 13:53   Re: Setting m_iNumRespawns + Supercede CS_RoundRespawn crashes?
Reply With Quote #2

You are likely using Podbot, right?

Due how a bot in Podbot is created (and how AMXX handles such forwards for a bot), the bot's private data is not yet initialized at this point. So it's not safe.
__________________
Arkshine is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-05-2018 , 14:03   Re: Setting m_iNumRespawns + Supercede CS_RoundRespawn crashes?
Reply With Quote #3

Quote:
Originally Posted by Arkshine View Post
You are likely using Podbot, right?
Yes.

Quote:
Originally Posted by Arkshine View Post
Due how a bot in Podbot is created (and how AMXX handles such forwards for a bot), the bot's private data is not yet initialized at this point. So it's not safe.
So am I supposed to set a delay? Use another forward? Not that I'm really interested in PodBots, just making sure.
__________________
edon1337 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-05-2018 , 14:12   Re: Setting m_iNumRespawns + Supercede CS_RoundRespawn crashes?
Reply With Quote #4

A possible way is to hook the first spawn (there are 2 spawns when you arrive in the server (motd, not alive), and after you choose the team & you get into the game).
It's called in PutInServer after the private data has been initialized.

Basically, Ham_Spawn, as pre, and checking is_user_alive if false or maybe more reliable to check m_bJustConnected offset.
Just give a try anyway.
__________________

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

Quote:
Originally Posted by Arkshine View Post
A possible way is to hook the first spawn (there are 2 spawns when you arrive in the server (motd, not alive), and after you choose the team & you get into the game).
It's called in PutInServer after the private data has been initialized.

Basically, Ham_Spawn, as pre, and checking is_user_alive if false or maybe more reliable to check m_bJustConnected offset.
Just give a try anyway.
Ham_Spawn or Ham_CS_RoundRespawn?

m_bJustConnected value is 500?
__________________
edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-05-2018 , 14:33   Re: Setting m_iNumRespawns + Supercede CS_RoundRespawn crashes?
Reply With Quote #6

The full offset seems to be 480. If you want to use it with get/set_pdata_int divide by 4, and the value is 120. To use the full offset get/set_pdata_bool is needed.

You could always use FPlayerCanRespawn as you did before instead of setting m_iNumSpawns.
__________________

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

Quote:
Originally Posted by HamletEagle View Post
The full offset seems to be 480. If you want to use it with get/set_pdata_int divide by 4, and the value is 120. To use the full offset get/set_pdata_bool is needed.

You could always use FPlayerCanRespawn as you did before instead of setting m_iNumSpawns.
Well, there's no difference in-between both, so adding another signature to the list seems unneeded. There's a difference in offsets when using pdata_int and pdata_bool?
__________________

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

m_bJustConnected is a bool, so naturally get/set_pdata_bool should be used. Unfortunately amxx 1.8.2 does not have such natives, so you either use Connor's stocks or convert the offset so it can be used directly with get/set_pdata_int(when possible).
__________________

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

Quote:
Originally Posted by HamletEagle View Post
(when possible).
This makes me go back to FPlayerCanRespawn, lol. I'll just go with FPlayerCanRespawn, less work.
This is enough to work?
PHP Code:
public OrpheuHookReturn:OnFPlayerCanRespawn(pGameRulesid)  
{  
    
OrpheuSetReturnfalse )  
    return 
OrpheuOverride;  

__________________

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

Is 20 the offset for all mods?
Code:
{
	"name" : "FPlayerCanRespawn",
	"class" : "CGameRules",
	"library" : "mod",
	"return" : 
	{
		"type" : "bool"
	},
	"arguments" : 
	[
		{
			"type" : "CBasePlayer *"
		}
	],
	"indexes" : 
	[
		{
			"os" : "windows",
			"mod" : "SvenCoop",
			"value" : 20
		},
		{
			"os" : "windows",
			"mod" : "cstrike",
			"value" : 20
		},
		{
			"os" : "linux",
			"mod" : "cstrike",
			"value" : 20
		},
		{
			"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
		}
	]
}
__________________
edon1337 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