AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to show HP when you get more. (https://forums.alliedmods.net/showthread.php?t=83922)

xPaw 01-17-2009 15:37

How to show HP when you get more.
 
Hello, how to show msg/hud when your hp get more, for example when used healer or something else, not when damage. thanks

Exolent[jNr] 01-17-2009 15:38

Re: How to show HP when you get more.
 
Hook "Health" event, and check difference from the event's value from the old event's value.

xPaw 01-17-2009 16:16

Re: How to show HP when you get more.
 
i'm hooked that event, but i cant understand howto do it

hleV 01-17-2009 17:17

Re: How to show HP when you get more.
 
Code:
#include <amxmodx>   new g_iHealth[33] = 100; // I hope you start with 100 health ^^   public plugin_init()         register_event("Health", "eHealth", "be", "1>0");   public eHealth(iCl) {         static iNewHealth; iNewHealth = get_user_health(iCl);         static iGainedHealth = iNewHealth - g_iHealth[iCl];           if (iGainedHealth)         {                 set_hudmessage(255, 255, 255, -1.0, 0.9, 0.1, 0.1, 2.0);                 show_hudmessage(iCl, "Gained health: %d", iGainedHealth);         }           g_iHealth[iCl] = iNewHealth; }

xPaw 01-17-2009 17:27

Re: How to show HP when you get more.
 
ye but hp can be not 100, for example 100800 or so:D

hleV 01-17-2009 18:13

Re: How to show HP when you get more.
 
Did you try the code?..

Exolent[jNr] 01-17-2009 18:17

Re: How to show HP when you get more.
 
Try this:

Code:
#include <amxmodx> #include <amxmisc> #include <hamsandwich> new g_health[33]; public plugin_init() {     RegisterHam(Ham_Spawn, "player", "FwdPlayerSpawn", 1);         register_event("Health", "EventHealthChange", "be"); } public FwdPlayerSpawn(client) {     if( is_user_alive(client) )     {         g_health[client] = get_user_health(client);     } } public EventHealthChange(client) {     new health = get_user_health(client);         new diff = health - g_health[client];     if( diff > 0 )     {         client_print(0, print_chat, "You gained %i health!", diff);     }         g_health[client] = health; }

xPaw 01-18-2009 06:17

Re: How to show HP when you get more.
 
it worked thanks.

Dores 01-18-2009 08:55

Re: How to show HP when you get more.
 
@hleV: I don't think you can create an array like that.
You must set what cell have what value:
Code:
// Creates an array and assigns 100 to every cell. new g_iHealth[33] = {100, ...};
Corrections are more than welcomed. :mrgreen:

SnoW 01-18-2009 10:44

Re: How to show HP when you get more.
 
Quote:

Originally Posted by Dores (Post 746221)
@hleV: I don't think you can create an array like that.
You must set what cell have what value:

Code:
</p><p>// Creates an array and assigns 100 to every cell.</p><p>new g_iHealth[33] = {100, ...};


Corrections are more than welcomed. :mrgreen:

True. Ofc easier is just make a loop, if there should be same value in every cell.


All times are GMT -4. The time now is 01:46.

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