AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Setting m_iNumRespawns + Supercede CS_RoundRespawn crashes? (https://forums.alliedmods.net/showthread.php?t=309723)

edon1337 08-05-2018 05:47

Setting m_iNumRespawns + Supercede CS_RoundRespawn crashes?
 
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;



Arkshine 08-05-2018 13:53

Re: Setting m_iNumRespawns + Supercede CS_RoundRespawn crashes?
 
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.

edon1337 08-05-2018 14:03

Re: Setting m_iNumRespawns + Supercede CS_RoundRespawn crashes?
 
Quote:

Originally Posted by Arkshine (Post 2608334)
You are likely using Podbot, right?

Yes.

Quote:

Originally Posted by Arkshine (Post 2608334)
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.

Arkshine 08-05-2018 14:12

Re: Setting m_iNumRespawns + Supercede CS_RoundRespawn crashes?
 
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.

edon1337 08-05-2018 14:22

Re: Setting m_iNumRespawns + Supercede CS_RoundRespawn crashes?
 
Quote:

Originally Posted by Arkshine (Post 2608342)
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?

HamletEagle 08-05-2018 14:33

Re: Setting m_iNumRespawns + Supercede CS_RoundRespawn crashes?
 
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.

edon1337 08-05-2018 14:38

Re: Setting m_iNumRespawns + Supercede CS_RoundRespawn crashes?
 
Quote:

Originally Posted by HamletEagle (Post 2608355)
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?

HamletEagle 08-05-2018 14:44

Re: Setting m_iNumRespawns + Supercede CS_RoundRespawn crashes?
 
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).

edon1337 08-05-2018 14:46

Re: Setting m_iNumRespawns + Supercede CS_RoundRespawn crashes?
 
Quote:

Originally Posted by HamletEagle (Post 2608360)
(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;  



edon1337 08-05-2018 15:00

Re: Setting m_iNumRespawns + Supercede CS_RoundRespawn crashes?
 
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
                }
        ]
}



All times are GMT -4. The time now is 12:34.

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