Raised This Month: $59 Target: $400
 14% 

[HELP] Jointeam with HUD


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
laper32
Junior Member
Join Date: Nov 2019
Old 01-13-2020 , 22:38   [HELP] Jointeam with HUD
Reply With Quote #1

My purpose: When a client joins game, apply on HUD setting.
TODO: I hooked command "jointeam", if this client is valid, apply on HUD settings.
PHP Code:
hook command
AddCommandListener
(SpawnOnCommandListenerCallback"jointeam"); 
PHP Code:
public Action SpawnOnCommandListenerCallback(int clientchar[] commandsint params)
{
    if (
IsClientValid(client))
    {
        
HUDOnClientSpawn(client);
    }

    
// Allow cmd
    
return Plugin_Continue;

In HUD module, when initializing this module, if the map has loaded, then apply on hud basic settings, and when client has spawned and death, also apply on hud display info.
PHP Code:
void HUDOnInit()
{
    
// Creates HUD synchonizer objects
    
if (gServerData.LevelSync == null)
    {
        
gServerData.LevelSync CreateHudSynchronizer();
    }
    
    
// Validate loaded map
    
if (gServerData.MapLoaded)
    {
        for (
int client 1client MaxClientsclient++)
        {
            if (
IsClientValid(client))
            {
                
HUDSetClientDisplayInfo(client);
            }
        }
    }
}

void HUDOnClientSpawn(int client)
{
    
// set client HUD
    
HUDSetClientDisplayInfo(client);
}

void HUDOnClientDeath(int client)
{
    
// Set client HUD for spec
    
HUDSetClientDisplayInfo(client);

In HUD display function, it looks like this:
PHP Code:
void HUDSetClientDisplayInfo(int client)
{
    if (!
IsFakeClient(client))
    {
        
delete gClientData[client].LevelTimer;
        
gClientData[client].LevelTimer CreateTimer(1.0HUDSetClientHUDTextTimerCallbackGetClientUserId(client), TIMER_REPEAT TIMER_FLAG_NO_MAPCHANGE);

        
// ---------------------------------------------------------------------------------------------

        
delete gClientData[client].RadarTimer;
        
gClientData[client].RadarTimer CreateTimer(0.1HUDSetClientHUDRadarTimerCallbackGetClientUserId(client), TIMER_REPEAT TIMER_FLAG_NO_MAPCHANGE); 
    }

The function about handle are works correctly, then not post.

Problem: When client joins the game, HUD element is not modify correctly(i.e, HUD text won't display, and radar won't remove).
However, when I use console command "jointeam 3", all of these are works correctly.
Is there any suitable way to make sure that all HUD elements works correctly?
laper32 is offline
Reply


Thread Tools
Display Modes

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 13:05.


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