AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Health Display (https://forums.alliedmods.net/showthread.php?t=183577)

mattiiias93 04-23-2012 12:47

Health Display
 
Hi i need a plugin that display name and health with hudmessage! Like this. Can someone help me ?

formatex(sMessage, 63, "Friend: %s^nHealth: %i", sName, get_user_health(target));
} else {
formatex(sMessage, 63, "Enemy: %s", sName);
}

Napoleon_be 04-23-2012 13:13

Re: Health Display
 
set_hudmessage() // 20.1 Secs
show_hudmessage(id, sMessage)

set_task(20.0, "FUNCTION-WHERE-DISPLAY-HUD", id)

Bilal Pro 04-23-2012 13:17

Re: Health Display
 
Napoleon, he means that if you aim at the person not random hud message :D

Liverwiz 04-23-2012 13:36

Re: Health Display
 
Code:

new p_target, p_bodyPart      // p_target == target
get_user_aiming(id, p_target, p_bodyPart)

if(get_user_team(p_target) == get_user_team(id))
    // your code here


mattiiias93 04-24-2012 10:30

Re: Health Display
 
Liverwiz yes you understand me if someone aim on a person it will display. I had a code but not the start code can someone fix it? Thanks

new target, body;
get_user_aiming(id, target, body, 9999);

if( 0 < target <= gMaxPlayers && is_user_alive(target))
{
new sName[32], sMessage[64];
get_user_name(target, sName, 31);

if( cs_get_user_team(target) == cs_get_user_team(id) )
{
formatex(sMessage, 63, "Friend: %s^nHealth: %i", sName, get_user_health(target));
} else {
formatex(sMessage, 63, "Enemy: %s", sName);
}

if(cs_get_user_team(target) == CS_TEAM_CT)
set_hudmessage()// HUDMESSAGE_COLOR
} else if(cs_get_user_team(target) == CS_TEAM_T){
set_hudmessage()// HUDMESSAGE_COLOR
}
show_hudmessage(id, "%s", sMessage);
}

Liverwiz 04-24-2012 11:52

Re: Health Display
 
Quote:

Originally Posted by mattiiias93 (Post 1695623)
Liverwiz yes you understand me if someone aim on a person it will display. I had a code but not the start code can someone fix it? Thanks

new target, body;
get_user_aiming(id, target, body, 9999);

if( 0 < target <= gMaxPlayers && is_user_alive(target))
{
new sName[32], sMessage[64];
get_user_name(target, sName, 31);

if( cs_get_user_team(target) == cs_get_user_team(id) )
{
formatex(sMessage, 63, "Friend: %s^nHealth: %i", sName, get_user_health(target));
} else {
formatex(sMessage, 63, "Enemy: %s", sName);
}

if(cs_get_user_team(target) == CS_TEAM_CT)
set_hudmessage()// HUDMESSAGE_COLOR
} else if(cs_get_user_team(target) == CS_TEAM_T){
set_hudmessage()// HUDMESSAGE_COLOR
}
show_hudmessage(id, "%s", sMessage);
}

Do you have the rest of the code? What is gMaxPlayers defined as? and does the code even compile? That first if statement, i'm not sure is a valid expression. What "start code" do you need? You mean headers and init function?

Also....when you're posting code into a thread make sure to wrap "[CODE" "[/CODE" or "[PHP" "[/PHP" tags around it to preserve whitespace. NOTE: PHP tags preserve syntax highlighting, if you want it to look fancy.

mattiiias93 04-25-2012 14:10

Re: Health Display
 
The rest of the code is lost and i don't remeber how i did to fix it..

Liverwiz 04-25-2012 15:59

Re: Health Display
 
PHP Code:

acquireTarget(){
new 
targetbody;
get_user_aiming(idtargetbody9999);

if(
is_user_alive(target))
{
    new 
sName[32], sMessage[64];
    
get_user_name(targetsName31);

    if( 
cs_get_user_team(target) == cs_get_user_team(id) )
        
formatex(sMessage63"Friend: %s^nHealth: %i"sNameget_user_health(target))
    else 
        
formatex(sMessage63"Enemy: %s"sName)

    
set_hudmessage()// HUDMESSAGE_COLOR
    
show_hudmessage(id"%s"sMessage)
}


Now....i'm not exactly sure what event you would use in replace of "acquireTarget" But i fixed up your code a bit. If you or someone else can find an event that would be good to call this function.

And what mod do you need this for? Everything i've played already prints those messages to your hud.

<VeCo> 04-25-2012 16:03

Re: Health Display
 
You can use StatusText event - it is the default HUD text showing name and health when you aim at somebody.

mattiiias93 04-26-2012 10:09

Re: Health Display
 
Thanks really nice. But Im no good with scripting plugins so can someone maybe complete the plugin? Please:D


All times are GMT -4. The time now is 07:47.

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