AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Here we go again, health messages? (https://forums.alliedmods.net/showthread.php?t=51370)

Davidos 02-16-2007 17:26

Here we go again, health messages?
 
How do you make a message that gets sent when you are, for example, under 25 hp? (Sven coop)

I was fumbling around but all I got was:

Code:
#include <amxmodx> #include <fun> #include <string> public plugin_init() {     register_plugin("Text Health", "0.1337", "Davidos")     register_event("health","display_hud", "be")    } public display_hud(id) {     new players[32]     get_players(players)     {         set_hudmessage(255,0,0,0,0,0,99.9,255,0.0,0.0,-1)         switch ( read_data(1) ) {             case 0 .. 25 :     ----------------->show_hudmessage(players,"Caution!")<-------------------//need a BIGGER SIGN or something??             default :             show_hudmessage(players, "Overcharged")         }     } }

Which ofcourse doesn't work, anyone wanna <kick> point me in the right direction?

Code:

Welcome to the AMX Mod X 1.00-251 Compiler.
Copyright (c) 1997-2004 ITB CompuPhase, AMX Mod X Team

Warning: Number of arguments does not match definition on line 31
Warning: Tag mismatch on line 33
Warning: Tag mismatch on line 33
Warning: Tag mismatch on line 33
Error: Argument type mismatch (argument 1) on line 36
Error: Argument type mismatch (argument 1) on line 38
--> indicates errors!


pRED* 02-16-2007 19:24

Re: Here we go again, health messages?
 
Use VEN's tutorial http://forums.alliedmods.net/showthread.php?t=42159

to make a round start event. Set everybodys rendering to the default there. (or use get_user_health and set it using that value)

Then create a register message for the damage event.

PHP Code:

register_event("Damage","event_damage","b","2!0","3=0","4!0"); 

create a function called event_damage, which gets called anytime a person gets hurt.

PHP Code:

public event_damage(id)
{
    
hp=get_user_health(id)
    
    
//set the users rendering using your switch here..

    
return PLUGIN_CONTINUE;
    


To find a list of all the things you can use with register_event, go into your hlds server and type 'meta game'

Davidos 02-16-2007 19:31

Re: Here we go again, health messages?
 
Quote:

Originally Posted by pRED* | NZ (Post 441295)
Use VEN's tutorial http://forums.alliedmods.net/showthread.php?t=42159

to make a round start event. Set everybodys rendering to the default there. (or use get_user_health and set it using that value)

Then create a register message for the damage event.

PHP Code:

register_event("Damage","event_damage","b","2!0","3=0","4!0"); 

create a function called event_damage, which gets called anytime a person gets hurt.

PHP Code:

public event_damage(id)
{
    
hp=get_user_health(id)
    
    
//set the users rendering using your switch here..

    
return PLUGIN_CONTINUE;
    


To find a list of all the things you can use with register_event, go into your hlds server and type 'meta game'

... what?

My glow mod WORKS FINE, better than anything else out there
it's just the last few lines.
Read it again, I just edited them out -_-

+ I said it was for sven coop, round stuff still gonna work?

pRED* 02-16-2007 19:48

Re: Here we go again, health messages?
 
Oh right. Was thinking CS for some reason.

Um in set_hudmessage the 4,5 and 8th parameters all need to be floats and you've got them as integers.

You also have to create a for loop and loop through all the players (think theres info in the help doc on how to do this) and then change the 'players' in your show_hudmessage to be players[counter]

Oh wait and the first error is because get_players needs 2 variables. player index array and num of players integer

PHP Code:

public display_hud(id) {
    new 
players[32],num;
    
get_players(players,num)

    
set_hudmessage(255,0,0,0.0,0.0,0,99.9,255.0,0.0,0.0,-1
    for (new 
counter=0counter<numcounter++)
    {
        
        switch ( 
read_data(1) ) {
            case 
.. 25 :
            
show_hudmessage(players[counter],"Caution!")
            default :
            
show_hudmessage(players[counter], "Overcharged")
        }
    }


Or maybe this. U already have the id, so you don't need to get_players at all? Not sure, don't know the messages for Sven
PHP Code:

public display_hud(id) {
   
        
set_hudmessage(255,0,0,0.0,0.0,0,99.9,255.0,0.0,0.0,-1
        
        switch ( 
read_data(1) ) {
            case 
.. 25 :
            
show_hudmessage(id,"Caution!")
            default :
            
show_hudmessage(id"Overcharged")
        }
    



Davidos 02-16-2007 19:55

Re: Here we go again, health messages?
 
Quote:

Originally Posted by pRED* | NZ (Post 441311)
Oh right. Was thinking CS for some reason.

Um in set_hudmessage the 4,5 and 8th parameters all need to be floats and you've got them as integers.

You also have to create a for loop and loop through all the players (think theres info in the help doc on how to do this) and then change the 'players' in your show_hudmessage to be players[counter]

Oh wait and the first error is because get_players needs 2 variables. player index array and num of players integer

PHP Code:

public display_hud(id) {
    new 
players[32],num;
    
get_players(players,num)

    
set_hudmessage(255,0,0,0.0,0.0,0,99.9,255.0,0.0,0.0,-1
    for (new 
counter=0counter<numcounter++)
    {
        
        switch ( 
read_data(1) ) {
            case 
.. 25 :
            
show_hudmessage(players[counter],"Caution!")
            default :
            
show_hudmessage(players[counter], "Overcharged")
        }
    }


Or maybe this. U already have the id, so you don't need to get_players at all? Not sure, don't know the messages for Sven
PHP Code:

public display_hud(id) {
   
        
set_hudmessage(255,0,0,0.0,0.0,0,99.9,255.0,0.0,0.0,-1
        
        switch ( 
read_data(1) ) {
            case 
.. 25 :
            
show_hudmessage(id,"Caution!")
            default :
            
show_hudmessage(id"Overcharged")
        }
    




as for the messages, same as hl dm so...

As for the plugin, it keeps messing up when I try to use it... no hud messages at all... what else in there is not like it's supposed to be...
Where is avalanche when you need him...


Code:
#include <amxmodx> #include <amxmisc> #include <fun> #include <string> public plugin_init() {     register_plugin("Text Health", "0.1337", "Davidos")     register_event("Damage","display_hud","be"); } public display_hud(id) {       set_hudmessage(255,0,0,0.0,0.0,0,99,255.0,0,0,2)     switch ( read_data(1) ) {         case 0 .. 25 :         show_hudmessage(id,"Caution!")         default :         show_hudmessage(id, "Overcharged")     }     }

you mean like this?


only error log now

Code:

Welcome to the AMX Mod X 1.00-251 Compiler.
Copyright (c) 1997-2004 ITB CompuPhase, AMX Mod X Team

fun.inc(14) : warning 207: unknown #pragma
fun.inc(14) : error 038: extra characters on line
fun.inc(16) : warning 207: unknown #pragma
fun.inc(16) : error 038: extra characters on line
Warning: Tag mismatch on line 12
Warning: Tag mismatch on line 12
Warning: Tag mismatch on line 12

2 Errors.

Ignore the last line...


as for In game the message doesnt show...


Anyway, I dunno bout you but I'm going to bed, been coding since 10 it's now 00:09

Cheap_Suit 02-16-2007 19:57

Re: Here we go again, health messages?
 
I think this is alot easier than switch statements

PHP Code:

public display_hud(id
{
    new 
health read_data(1)
    if(
health 25)
    {
        
//do stuff
    
}
    else if(
health 100)
    {
        
//do another stuff
    
}



pRED* 02-16-2007 20:00

Re: Here we go again, health messages?
 
What errors are you getting?

I don't know anything about the 'health' message but I'm assuming that it does pass and id and that read_data(1) gives you the hp of that player.

So the only other error could be in displaying the hud message. I have no idea what all the numbers do, i just compared them with this http://www.amxmodx.org/funcwiki.php?...sage&go=search
to see if all the data types matched. Maybe you need to set different numbers..

Davidos 02-16-2007 20:09

Re: Here we go again, health messages?
 
Quote:

Originally Posted by Cheap_Suit (Post 441317)
I think this is alot easier than switch statements

PHP Code:

public display_hud(id
{
    new 
health read_data(1)
    if(
health 25)
    {
        
//do stuff
    
}
    else if(
health 100)
    {
        
//do another stuff
    
}



D'oh <slaps himself in the face> I've been so focussed on black Rose I forgot you could do that as well >_<

pRED* 02-16-2007 20:17

Re: Here we go again, health messages?
 
Remove the #include <fun>, you don't use anything from it anyway.
Maybe something wrong with your fun module because without that defined it compiles fine, but still with all the tag mismatches.

http://www.amxmodx.org/funcwiki.php?...sage&go=search

Read that carefully. It tells you what type each of the parameters for set_hudmessage have to be. Some must be integers (0, 1 etc) other must be floats (0.0, 24.3 etc). This is what's causing the tag mismatch errors. Fix those and it should compile no errors and work hopefully.

Davidos 02-17-2007 04:38

Re: Here we go again, health messages?
 
Double post for bump >so people read it<

Code:
#include <amxmodx> #include <amxmisc> #include <string> //might need this public plugin_init() {     register_plugin("Text Health", "0.1337", "Davidos")     register_event("Damage","display_hud","be"); } public display_hud(id) {     new health = read_data(1)     if(health>=200)     {         set_hudmessage(255,255,255,0.65,0.0,0,1.0,255.0,0.0,0.0,-1)         show_hudmessage(id,"Overcharged!")     }     else if(health>=100)     {         set_hudmessage(0,255,0,0.65,0.0,0,1.0,255.0,0.0,0.0,-1)         show_hudmessage(id,"Fine")     }     else if(health>=75)     {         set_hudmessage(100,255,0,0.65,0.0,0,1.0,255.0,0.0,0.0,-1)         show_hudmessage(id,"Scratched")     }     else if(health>=50)     {         set_hudmessage(255,255,0,0.65,0.0,0,1.0,255.0,0.0,0.0,-1)         show_hudmessage(id,"Hurt")     }     else if(health>=25)     {         set_hudmessage(255,100,0,0.65,0.0,0,1.0,255.0,0.0,0.0,-1)         show_hudmessage(id, "CAUTION!")     }     else if(health>=1)     {         set_hudmessage(255,0,0,0.65,0.0,0,1.0,255.0,0.0,0.0,-1)         show_hudmessage(id, "CRITICAL!")     } }

can anyone point out why nothing shows in the hud?


All times are GMT -4. The time now is 00:44.

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