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

[CSGO] ShowHudText not working


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bruxo00
Junior Member
Join Date: Jan 2015
Old 04-19-2019 , 22:00   [CSGO] ShowHudText not working
Reply With Quote #1

Hello! I'm new to SourceMod, and I'm trying to create a hud message that will appear in the middle of the screen. I've tried this to test it out, but it's not working:

PHP Code:
        for (int i 1<= MaxClientsi++)
        {
            if (
IsClientInGame(i)) {
                
SetHudTextParams(-1.0, -1.05.02550025500.251.01.0);
                
//SetHudTextParams(-1.0, 0.45, 2.0, 255, 235, 20, 200, 1);
                
ShowHudText(i5"This is a test %d"i);
            }
        } 
What am I doing wrong? Tried both of text params, neither worked.
bruxo00 is offline
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 04-20-2019 , 07:39   Re: [CSGO] ShowHudText not working
Reply With Quote #2

Try to use different channel number (from 0 to 4-6) for ShowHudText(i, 5, "This is a test %d", i);
OR
Create global Handle variable for Hud Sync object via CreateHudSynchronizer() and then use ShowSyncHudText(i, YOUR_SYNC_OBJECT, "This is a test %d", i);
__________________
MAGNAT2645 is offline
bruxo00
Junior Member
Join Date: Jan 2015
Old 04-20-2019 , 08:07   Re: [CSGO] ShowHudText not working
Reply With Quote #3

Quote:
Originally Posted by MAGNAT2645 View Post
Try to use different channel number (from 0 to 4-6) for ShowHudText(i, 5, "This is a test %d", i);
OR
Create global Handle variable for Hud Sync object via CreateHudSynchronizer() and then use ShowSyncHudText(i, YOUR_SYNC_OBJECT, "This is a test %d", i);
I've tried all the channels, also -1 which is supposed to pick a valid one automatically... I'm gonna try the sync one, thanks!
bruxo00 is offline
bruxo00
Junior Member
Join Date: Jan 2015
Old 04-20-2019 , 08:51   Re: [CSGO] ShowHudText not working
Reply With Quote #4

Tried the Sync one, didn't work either...

PHP Code:
Handle g_HudText;

g_HudText CreateHudSynchronizer(); // OnPluginStart

        
for (int i 1<= MaxClientsi++)
        {
            if (
IsClientInGame(i)) {
                
ClearSyncHud(ig_HudText);
                
SetHudTextParams(-1.00.452.0255235202001);
                
ShowSyncHudText(ig_HudText"This is a test %d"i);
            }
        } 
bruxo00 is offline
CliptonHeist
Senior Member
Join Date: Feb 2016
Old 04-20-2019 , 23:28   Re: [CSGO] ShowHudText not working
Reply With Quote #5

At what point are you trying to do this?
CliptonHeist is offline
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 04-20-2019 , 23:48   Re: [CSGO] ShowHudText not working
Reply With Quote #6

Yeah, what function or forward uses this loop? Maybe your function just don't calls at all?

Also, i think that you shouln't clear sync hud at same object that will show your hud again. (Just because your function can call many times)
__________________

Last edited by MAGNAT2645; 04-20-2019 at 23:51.
MAGNAT2645 is offline
bruxo00
Junior Member
Join Date: Jan 2015
Old 04-21-2019 , 08:48   Re: [CSGO] ShowHudText not working
Reply With Quote #7

@CliptonHeist

I'm using the retakes plugin, I'm calling this to announce the bombsite in the middle of the screen.


@MAGNAT2645

The function it's beeing called, I've made some debugging and it's all working, except the HudText... Also, I tried without the ClearSyncHud, but it's the same....
bruxo00 is offline
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 04-21-2019 , 09:04   Re: [CSGO] ShowHudText not working
Reply With Quote #8

Can you post more code before loop? Also, try to debug loop to see that it's working.
__________________
MAGNAT2645 is offline
bruxo00
Junior Member
Join Date: Jan 2015
Old 04-21-2019 , 09:13   Re: [CSGO] ShowHudText not working
Reply With Quote #9

Sure man, thanks for trying to help me!

PHP Code:
public Action Event_RoundPostStart(Event event, const char[] namebool dontBroadcast) {
    if (!
Retakes_Live()) {
        return;
    }

    if (!
g_EditMode) {
        
GameRules_SetProp("m_iRoundTime"g_hRoundTime.IntValue40true);
        
Retakes_MessageToAll("%t""RetakeSiteMessage"SITESTRING(g_Bombsite), g_NumTg_NumCT);

        for (
int i 1<= MaxClientsi++)
        {
            if (
IsClientInGame(i)) {
                
SetHudTextParams(-1.00.452.0255235202001);
                
ShowSyncHudText(ig_HudText"This is a test %d"i);
            }
        }
    }

    
g_bombPlanted false;

bruxo00 is offline
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 04-21-2019 , 10:32   Re: [CSGO] ShowHudText not working
Reply With Quote #10

You can also check your error logs because function may abort code below (i mean before loop) if there is runtime errors.
__________________

Last edited by MAGNAT2645; 04-21-2019 at 10:32.
MAGNAT2645 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:35.


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