AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved HUD Breaks on spawn (DOD) (https://forums.alliedmods.net/showthread.php?t=335825)

cmndrfello 01-06-2022 16:54

HUD Breaks on spawn (DOD)
 
Hello,
Recently I'm trying to reactivate the client's HUD with the player's pdata though It seems that the offsets I found for DoD's CBasePlayer aren't correct?
dod-offsets-cbaseplayer

When the player spawns in using a custom function, the client-side HUD seems to break and not function correctly. The weapons are in the players inventory though aren't switchable by selecting them with scroll wheel or numbers. plus, the ammo counter and weapon switch HUD aren't seen.

I thought maybe changing the player's pdata related to hiding the HUD will fix though it hasn't worked so far...

PHP Code:

set_pdata_int(id1060020); //m_iHideHUD
set_pdata_int(id1072020); //m_iClientHideHUD
set_pdata_int(id1024120); //m_fInitHUD 

I really can't seem to find any solutions without asking any experienced people about it...
Isn't there a way to catch these kind of pdata changes so debugging could be done?

Shadows Adi 01-06-2022 17:31

Re: HUD Breaks on spawn (DOD)
 
Windows or linux server?

Post the function here

cmndrfello 01-06-2022 17:40

Re: HUD Breaks on spawn (DOD)
 
Here's the code that i am using on a windows server

PHP Code:

register_forward(FM_PlayerPreThink"dod_player_prethink");
RegisterHam(Ham_Spawn"player""dod_player_postspawn"true);

public 
dod_player_prethink(id)
{
    if(
pev(idpev_health) <= && pev(id,pev_team) != && get_pdata_int(id,366) != -1){
        
set_task(0.4"dod_player_spawn"id);
        
set_pev(idpev_deadflagDEAD_RESPAWNABLE);
    }
}

public 
dod_player_spawn(id)
{
    
set_pev(idpev_iuser10);
    
dllfunc(DLLFunc_Spawnid);
}

public 
dod_player_postspawn(id)
{
    
fm_strip_user_weapons(id);

    
giveLoadout(); //Function with give_item() calls

    
set_pdata_int(id1060020);
    
set_pdata_int(id1072020);
    
set_pdata_int(id1024120);

    return 
PLUGIN_CONTINUE;


"dod_player_prethink()" function checks if player is dead and if so will spawn them with dllfunc.
After spawning even without "fm_strip_user_weapons()" still the weapon HUD won't appear.
(health, deathmsgs and chat still appears only weapon related HUD does not)

fysiks 01-07-2022 00:52

Re: HUD Breaks on spawn (DOD)
 
I ran the original plugin that I gave you and it seems to work just fine. I see that you removed some of the things that were in the original plugin, namely the line that has the comment: "I found this is needed to use weapons for a forced spawn.". Seems like that might be important.

I'm running on Linux so I can't be sure it's not a Windows thing but if you can attach your full plugin (or a smaller working plugin that still exhibits the unwanted behavior) so that I can test on my Linux server and see if it happens on Linux also.

cmndrfello 01-07-2022 02:02

Re: HUD Breaks on spawn (DOD)
 
1 Attachment(s)
Here's the source code

cmndrfello 01-07-2022 14:04

Re: HUD Breaks on spawn (DOD)
 
Nevermind! I've found a fix!
Sending a "HideWeapon" message post spawn with written byte as 0 will reset the hidden elements and will fix my issue!
PHP Code:

message_begin(MSG_ONEget_user_msgid("HideWeapon"), {0,0,0}, id);
    
write_byte(0);
message_end(); 



All times are GMT -4. The time now is 11:33.

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