Raised This Month: $ Target: $400
 0% 

hud message problem !! help plesae


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
vats255
New Member
Join Date: Jun 2009
Old 06-15-2009 , 12:41   hud message problem !! help plesae
Reply With Quote #1

i m starting to develope plugins and as a first step i m doin a very basic plugin which just prints a message to a client just like welcome message..but it doesnt disply..pls help..here;s the code



#include <amxmodx>

//Declare three string variables
new PLUGIN[]="dfdfdf"
new AUTHOR[]="dfdfddfdn"
new VERSION[]="1.00"

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
for (new i = 1; i <= get_maxplayers(); i++)
{
if (is_user_alive(i) && is_user_connected(i) && !is_user_bot(i) && !is_user_hltv(i))
{
client_cmd(i,"echo ur health is critical...")
}
}
}



pls help...
vats255 is offline
znovit
Member
Join Date: Mar 2009
Location: Behind you :=
Old 06-15-2009 , 14:55   Re: hud message problem !! help plesae
Reply With Quote #2

You could do like this =)

PHP Code:
#include <amxmodx>
#include <amxmisc>

new PLUGIN[] "Unknown"
new VERSION[] "1.0"
new AUTHOR[] "Unknown"

#define TASK_DELAY "1.0"

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
set_task(TASK_DELAYconnectmessage); // Im not sure if this is right :p
}

public 
connectmessage(id) {
    
client_print(idprint_chat,"YOUR WELCOME TEXT");
    
client_print(idprint_chat,"YOUR WELCOME TEXT");
    
client_print(idprint_chat,"YOUR WELCOME TEXT");
    

__________________
znovit is offline
tpt
Member
Join Date: Jun 2009
Location: Scripting help section
Old 06-15-2009 , 17:33   Re: hud message problem !! help plesae
Reply With Quote #3

Quote:
Originally Posted by vats255 View Post
i m starting to develope plugins and as a first step i m doin a very basic plugin which just prints a message to a client just like welcome message..but it doesnt disply..pls help..here;s the code


Code:
#include <amxmodx> //Declare three string variables new PLUGIN[]="dfdfdf" new AUTHOR[]="dfdfddfdn" new VERSION[]="1.00" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     for (new i = 1; i <= get_maxplayers(); i++)     {         if (is_user_alive(i) && is_user_connected(i) && !is_user_bot(i) && !is_user_hltv(i))         {          client_cmd(i,"echo ur health is critical...")         }     } }

pls help...
You shouldn't be using get_maxplayers() directly in the loop. Correct way:

Code:
[...] new g_iMaxPlayers [...] public plugin_init() {     g_iMaxPlayers = get_maxplayers() } [...] for( new i = 1; i <= g_iMaxPlayers; i++ ) [...]

Your code could be simple as this:
Code:
#include <amxmodx> public plugin_init()     register_plugin( "connect msg", "1.0", "tpt" ) public client_connect( id )     client_print( 0, print_chat, "(%d) connected to the server.", id )

Try adding something to the script. get_user_name ( index, name[], len ) for example.
tpt is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-15-2009 , 19:16   Re: hud message problem !! help plesae
Reply With Quote #4

They likely won't see it on connect. I would either use putinserver or use putinserver and a task.

PHP Code:
public client_putinserver(id)  // This function is called when the player is put into the server
{
    
client_print(idprint_chat"Welcome")

or

PHP Code:
public client_putinserver(id)  // This function is called when the player is put into the server
{
    
set_task(5.0"welcome_message"id// Call welcome_message function in 5 seconds
}

public 
welcome_message(id)
{
    
client_print(idprint_chat"Welcome"// Print message to chat.

P.S. Use [php][/php] tags around your code when posting code.
__________________

Last edited by fysiks; 06-15-2009 at 19:20. Reason: p.s.
fysiks is offline
vats255
New Member
Join Date: Jun 2009
Old 06-16-2009 , 00:18   Re: hud message problem !! help plesae
Reply With Quote #5

Thank u all for u responses...i have learnt that certain functions like welcome_message is executed when a new player enters teh game etc...So i have anothre great problem..I want some data to be monitored in real time just like health etc , and as it changes it has to measure the variation and accordingly handle data...here i face two problems..take a sample plugin..suppose i want to monitor health and if it comes below 25 i wanna warn that guy (only him) that his health is critical..here i want the health of all the guys to be checked whether it is less than 25 throughout the game and if it is less than 25 , i need it to print it as a hud message which prints on the center of the screen such as that of round nos. etc...I already tried
PHP Code:
Set_task(......,"b"
with little success..pls help..


And about the present suggestions i ll try it out and give u the feedback...Thanks a lot for takin time to answer my queries...
vats255 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-16-2009 , 00:28   Re: hud message problem !! help plesae
Reply With Quote #6

This will show a HUD msg when players health drops below 25. The HUD will not remain on screen, it will show the HUD at each damage that results in health being below 25.

PHP Code:
#include <amxmodx>

public plugin_init() 
{
    
register_plugin"Critical Health" "1.0" "bugsy" )
    
register_event"Health" "fw_Health" "be" );
}

public 
fw_Healthid )
{
    if ( 
read_data) < 25 )
    {
        
set_hudmessage255 , -1.0 0.40 6.0 5.0 );
        
show_hudmessageid "Health at critical level" );
    }    

__________________

Last edited by Bugsy; 06-16-2009 at 00:33.
Bugsy is offline
vats255
New Member
Join Date: Jun 2009
Old 06-16-2009 , 03:15   Re: hud message problem !! help plesae
Reply With Quote #7

register_event( "Health" , "fw_Health" , "be" ); how does it work..???what's be what's health...fw_health is understood as the function...pls explain...
vats255 is offline
vats255
New Member
Join Date: Jun 2009
Old 06-16-2009 , 03:19   Re: hud message problem !! help plesae
Reply With Quote #8

and pls explain the whole program..and also i have a major doubt...does this function fw_Health get executed only once when teh plugin initialises or does it execute each second bcoz it has to monitor the health..and if it monitors constantly how ??u havent given any command for the function to be repeated...and also gimme a general clarification..when we do functions like these how to repeatedlly initialise functions that monitor variable parameters like health..
vats255 is offline
tpt
Member
Join Date: Jun 2009
Location: Scripting help section
Old 06-16-2009 , 09:27   Re: hud message problem !! help plesae
Reply With Quote #9

Quote:
Originally Posted by fysiks View Post
They likely won't see it on connect. I would either use putinserver or use putinserver and a task.

PHP Code:
public client_putinserver(id)  // This function is called when the player is put into the server
{
    
client_print(idprint_chat"Welcome")

or

PHP Code:
public client_putinserver(id)  // This function is called when the player is put into the server
{
    
set_task(5.0"welcome_message"id// Call welcome_message function in 5 seconds
}

public 
welcome_message(id)
{
    
client_print(idprint_chat"Welcome"// Print message to chat.

P.S. Use [php][/php] tags around your code when posting code.
Everyone else will see it and that was short example.

P.S Why use [php][/php] tags when you can use [small][/small] tags?
tpt is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-16-2009 , 10:17   Re: hud message problem !! help plesae
Reply With Quote #10

Quote:
Originally Posted by vats255 View Post
and pls explain the whole program..and also i have a major doubt...does this function fw_Health get executed only once when teh plugin initialises or does it execute each second bcoz it has to monitor the health..and if it monitors constantly how ??u havent given any command for the function to be repeated...and also gimme a general clarification..when we do functions like these how to repeatedlly initialise functions that monitor variable parameters like health..
Take a look at these:
register_event
Half-Life Game Events

Events are fired in the game when particular things occur. The "Health" event is what the game uses when it wants to update your health on the screen. The register_event() function "hooks" the Health event and will call the fw_Health() function every time it is fired by the HL game engine. This will allow you to take action any time the health value for a player changes without the need to do any type of looping to constantly check the value. The "b" flag specifies the event is called on a single player and the "e" flag requires the player to be alive.

If you look at the register_event() function link above, there is an example towards the bottom of the page that shows how to hook the DeathMsg event; this allows you retrieve the killer, victim, if headshot, and weapon-used [via read_data()] when a death occurs.

PHP Code:
register_event"Health" "fw_Health" "be" );

public 
fw_Healthid )
{
    
//If you look at the Health event in the list of events you will see a value 
    //is passed to the event that can be read. This value is the updated
    //amount of health the player has that is used to update the in-game
    //health value HUD. Here we check if the value is < 25 and if so show a
    //HUD.
    
if ( read_data) < 25 )
    {
        
set_hudmessage255 , -1.0 0.40 6.0 5.0 );
        
show_hudmessageid "Health at critical level" );
    }    

__________________

Last edited by Bugsy; 06-16-2009 at 11:54.
Bugsy 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 14:00.


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