Raised This Month: $51 Target: $400
 12% 

ShowHudText only showing for Spectators


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bu0y
New Member
Join Date: Jun 2023
Old 06-02-2023 , 20:05   ShowHudText only showing for Spectators
Reply With Quote #1

Hi, was hoping someone could help.

I have a duel plugin with different gamemodes which uses

public Action Example(Handle timer) {
for(int i = 1; i <= MaxClients; i++) {
if(IsValidClient(i)){
ShowHudText(i, -1, "%t", text);
}
}
}

stock bool IsValidClient(int client)
{
if (client <= 0) return false;
if (client > MaxClients) return false;
if (!IsClientConnected(client)) return false;
return IsClientInGame(client);
}

to draw text displaying the gamemode that is being played to all players. this has been working fine, but when the same code is used for a Custom Round plugin

public void OnPluginStart() {
HookEvent("round_start", Event_RoundStart);
}

public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast) {
for(int i = 1; i <= MaxClients; i++) {
ShowHudText(i, -1, "%t", text);
}
}

stock bool IsValidClient(int client)
{
if (client <= 0) return false;
if (client > MaxClients) return false;
if (!IsClientConnected(client)) return false;
return IsClientInGame(client);
}

the text is ONLY visible to spectators. Is there any solution to this? We have tried moving ShowHudText out of OnRoundStart but it seems as long as it is called within that event, the text will only work for spectators

Thanks in advance
bu0y is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 06-04-2023 , 09:31   Re: ShowHudText only showing for Spectators
Reply With Quote #2

PHP Code:
Handle hHUD;

public 
void OnPluginStart()
{
    if(!(
hHUD CreateHudSynchronizer())) SetFailState("Unable use HUD text.");

    
HookEvent("round_start"Event_RoundStartEventHookMode_PostNoCopy);
}

public 
void Event_RoundStart(Event event, const char[] namebool dontBroadcast)
{
    static const 
float x = -1.0= -1.0time 3.0;
    static const 
int r 0127255;
    
SetHudTextParams(xytimergb255_0.00.00.0);

    
char text[PLATFORM_MAX_PATH];
    for(
int i 1<= MaxClientsi++) if(IsClientInGame(i) && !IsFakeClient(i)) ShowSyncHudText(ihHUD"%t"text);

__________________
Grey83 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 07:37.


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