AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   General (https://forums.alliedmods.net/forumdisplay.php?f=7)
-   -   How to use Hud Instead of Print. (https://forums.alliedmods.net/showthread.php?t=334642)

NTARIS 10-10-2021 10:28

How to use Hud Instead of Print.
 
Guys i have this code in zp extra item bazooka


Code:

public rk_sound(player) {

        if (!rksound[player])
        {
                engfunc(EngFunc_EmitSound, player, CHAN_WEAPON, getrocket, 1.0, ATTN_NORM, 0, PITCH_NORM)
                client_print(player, print_center, "[Bazooka] Reloaded")
                rksound[player] = true
        }
        else if (rksound[player])
        {
               
        }
       
}


How to convert that into hud message instead of a printed message.But the hud to be alligned in
center too.




Thanks in advance.

fysiks 10-10-2021 18:03

Re: How to use Hud Instead of Print.
 
set_hudmessage() and show_hudmessage(). Look at how other plugins do it if you're unsure of how to use them.

NTARIS 10-11-2021 04:20

Re: How to use Hud Instead of Print.
 
Fysiks i know these commands.But i dont know how to replace the above structure with hud message.Because the hud message must appear when the bazooka is reloaded along with the sound.I have tried but i cant figure it out.Would you mind if you know,which part i should remove from the code above and which part of hud message to add so it can work.To help you i just want the hud to be centered and have a visible color hud message.

fysiks 10-11-2021 22:36

Re: How to use Hud Instead of Print.
 
It's quite simple. Replace the client_print() function with both of the aforementioned functions with the arguments filled in. If you read the documentation, you'll notice that you use a -1.0 for x and y to set the text position to center. In fact, it looks like all arguments have a default value so you don't even need to supply any arguments as a quick test. If you're unsure how to use those functions, look up how other plugins use them. If you tried to write code, post it here and we can help you with it.

NTARIS 10-12-2021 07:52

Re: How to use Hud Instead of Print.
 
Ok,I Figured it out.

I just replaced the below code:

Code:

public rk_sound(player) {

        if (!rksound[player])
        {
                engfunc(EngFunc_EmitSound, player, CHAN_WEAPON, getrocket, 1.0, ATTN_NORM, 0, PITCH_NORM)
                client_print(player, print_center, "[Bazooka] Reloaded")
                rksound[player] = true
        }
        else if (rksound[player])
        {
               
        }
       
}


With this code:

Code:

public rk_sound(player) {

        if (!rksound[player])
        {
                engfunc(EngFunc_EmitSound, player, CHAN_WEAPON, getrocket, 1.0, ATTN_NORM, 0, PITCH_NORM)
                {
set_dhudmessage( 0, 160, 0, -1.0, 0.25, 2, 6.0, 3.0, 0.1, 1.5 );
show_dhudmessage( player, "[BAZOOKA], Reloaded Shoot!!!");
}
                rksound[player] = true
        }
        else if (rksound[player])
        {
       
        }
       
}

Also...
1)I downloaded the dhudmessage include file and placed it under scripting/include folder.
2)Then added at top of .sma file the below code:

Code:

#include <dhudmessage>

Thats all,thanks for giving me ideas.

HamletEagle 10-12-2021 09:03

Re: How to use Hud Instead of Print.
 
You can use regular hud messages, just saying.

NTARIS 10-12-2021 11:48

Re: How to use Hud Instead of Print.
 
Thanks for that too.Because the one i make was like Titan Message Size.


All times are GMT -4. The time now is 06:08.

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