AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Approved Plugins (https://forums.alliedmods.net/forumdisplay.php?f=8)
-   -   Zero (0) HP Bug Fix by Exolent (https://forums.alliedmods.net/showthread.php?t=68124)

Exolent[jNr] 03-08-2008 22:12

Zero (0) HP Bug Fix by Exolent
 
1 Attachment(s)
Intro:
  • Have you ever had messed up movements and zero (0) health on your HUD?
  • This happens from having more than 255 health, and then falling, which causes you to lose health, which sometimes results in having zero (0) health.
  • Then, when this happens, you ask for an admin (if you aren't one) to slap you or give you some health.
  • Well, this plugin blocks the possibility of having zero (0) health!
How to use:
  • Click Get Plugin at the bottom of this post, and place the file in your server's addons/amxmodx/plugins folder
  • Open the plugins.ini file located in your server's addons/amxmodx/configs folder
  • At the very bottom, type zero_hp_fix.amxx
Changelog:
  • Version 0.1
    - Initial Release
  • Version 0.2
    - Changed math
  • Version 0.3
    - Removed Fakemeta
  • Version 0.4
    - Changed HP Check for 255 or greater

project 03-08-2008 22:16

Re: Zero (0) HP Bug Fix
 
looks hot

Bad Coupon 03-08-2008 22:17

Re: Zero (0) HP Bug Fix
 
The must have for a surf server. tyvm exo! :mrgreen:

kp_uparrow 03-09-2008 01:04

Re: Zero (0) HP Bug Fix
 
try:

if(hp>0&&hp%256==0){
....
}

Exolent[jNr] 03-09-2008 01:20

Re: Zero (0) HP Bug Fix
 
well if it works fine the way it is, why change it?

also, i never knew what the % sign meant when using it as an operator.

Lord_Destros 03-09-2008 03:07

Re: Zero (0) HP Bug Fix
 
Yay for modulus?

Exolent[jNr] 03-09-2008 04:00

Re: Zero (0) HP Bug Fix
 
for those people who havent upgraded and need to know :\ (not me :P)

Emp` 03-09-2008 22:08

Re: Zero (0) HP Bug Fix
 
Quote:

Originally Posted by X-olent (Post 594776)
well if it works fine the way it is, why change it?

also, i never knew what the % sign meant when using it as an operator.

returns the remainder when the two are divided.

kp_uparrow is right though, it would make sense to use that.
Code:

public message_Health(msgid, dest, id)
{
        if(!is_user_alive(id))
                return PLUGIN_CONTINUE;
       
        static Float:health, hp;
        pev(id, pev_health, health);
        hp = floatround(health);
       
        if( hp > 0 && hp % 256 == 0 )
        {
                set_pev(id, pev_health, ++health);
                set_msg_arg_int(1, get_msg_argtype(1), 1);
        }
        return PLUGIN_CONTINUE;
}


Exolent[jNr] 03-09-2008 22:10

Re: Zero (0) HP Bug Fix
 
thanks for clearing up how % works :)

ill update in 1 sec.

vittu 03-10-2008 01:00

Re: Zero (0) HP Bug Fix
 
This is not needed: set_pev(id, pev_health, ++health);

you just need to make sure the hud does not show 0 by using:
set_msg_arg_int(1, get_msg_argtype(1), 1);

----------------
You also don't need get_msg_argtype(1) and can just use ARG_BYTE for:
set_msg_arg_int(1, ARG_BYTE, 1);

what i used:
Code:

public message_Health(msgid, dest, id)
{
        if(!is_user_alive(id))
                return PLUGIN_CONTINUE;

        static hp;
        hp = get_msg_arg_int(1);

        if(hp > 0 && (hp % 256) == 0)
        {
                set_msg_arg_int(1, ARG_BYTE, ++hp);
        }
        return PLUGIN_CONTINUE;
}


travo 03-10-2008 04:46

Re: Zero (0) HP Bug Fix
 
if its > than 255 its unreadable anyways, so why not do
PHP Code:

if (hp>255)
{
    
message_begin(MSG_ONE_UNRELIABLE,get_user_msgid("Health"),_,id);
    
write_byte(255);
    
message_end();



hleV 03-10-2008 06:05

Re: Zero (0) HP Bug Fix
 
Nice, gonna use it for ZombieMod server.

vittu 03-11-2008 04:10

Re: Zero (0) HP Bug Fix
 
Quote:

Originally Posted by travo (Post 595126)
if its > than 255 its unreadable anyways, so why not do

for travo, done properly:
Code:

public message_Health(msgid, dest, id)
{
        if(!is_user_alive(id))
                return PLUGIN_CONTINUE;

        if(get_msg_arg_int(1) > 255)
        {
                set_msg_arg_int(1, ARG_BYTE, 255);
        }
        return PLUGIN_CONTINUE;
}


ConnorMcLeod 03-11-2008 05:16

Re: Zero (0) HP Bug Fix
 
Quote:

Originally Posted by vittu (Post 595525)
Code:

public message_Health(msgid, dest, id)
{
        if(!is_user_alive(id))
                return PLUGIN_CONTINUE;

        static hp;
        hp = get_msg_arg_int(1);

        if(hp > 255)
        {
                set_msg_arg_int(1, ARG_BYTE, 255);
        }
        return PLUGIN_CONTINUE;
}


This should be added in the plugin !!

Exolent[jNr] 03-11-2008 07:37

Re: Zero (0) HP Bug Fix
 
@vittu
ill do some testing to see if i can reduce coding
i just like to test myself so i know for sure it will fix the bug

SchlumPF* 03-12-2008 22:23

Re: Zero (0) HP Bug Fix
 
this was made a while ago by fatalis (posted on xtreme-jumps.eu) but nice to see it here too :P

vittu 03-12-2008 23:49

Re: Zero (0) HP Bug Fix
 
Quote:

Originally Posted by SchlumPF* (Post 596277)
this was made a while ago by fatalis (posted on xtreme-jumps.eu) but nice to see it here too :P

Really cause I just took a look and could not find anything there.


------------------
travo, updated that code above. Didn't need the hp variable for what you wanted to do.

Exolent[jNr] 03-13-2008 07:29

Re: Zero (0) HP Bug Fix
 
ive never seen a plugin like this...

Alka 03-13-2008 11:09

Re: Zero (0) HP Bug Fix
 
Quote:

Originally Posted by X-olent (Post 596343)
ive never seen a plugin like this...

Code:

#include <amxmodx>
#include <fun>
 
#define PLUGIN "New Plugin"
#define VERSION "0.1"
#define AUTHOR "Fatalis"
 
public plugin_init()
{
 register_plugin(PLUGIN, VERSION, AUTHOR)
 
 register_event("Damage", "msgDamage", "be", "2!0");
 
 return PLUGIN_CONTINUE;
}
 
public msgDamage(id)
{
 new health = get_user_health(id);
 if(health > 255 && !(health%256))
 {
  set_user_health(id, health-1);
 
  client_print(id, print_chat, "[XJ] 0 HP bug prevented.");
 }
 
 return PLUGIN_CONTINUE;
}


vittu 03-13-2008 15:17

Re: Zero (0) HP Bug Fix
 
Well this method is still superior since that one only catches the damage event. Health can be changed in other ways not involving damage. This plugin's method is also better for its use of register_message rather than register_event. I also would rather not change the users health and just send the message to change their hud only, which I showed above.

Alka 03-13-2008 15:21

Re: Zero (0) HP Bug Fix
 
Indeed vittu, you'r method is best...i just replyed to X-olent post.

Exolent[jNr] 03-13-2008 15:55

Re: Zero (0) HP Bug Fix
 
updated to 0.3
thanks for pointing that out vittu :)

vittu 03-21-2008 16:01

Re: Zero (0) HP Bug Fix
 
Kinda forgot about this but because you are checking if the client is alive, you don't need to check against 0 hp. Client can not be alive and have 0 health or less.
You can reduce the if statement to:
if(hp % 256 == 0)


or if you really wanted, you don't need to check below 255 so you could change it to:
if(hp > 255 && (hp % 256) == 0)

Exolent[jNr] 03-21-2008 17:33

Re: Zero (0) HP Bug Fix
 
done.

dark_style 02-12-2010 09:46

Re: Zero (0) HP Bug Fix by Exolent
 
Can someone edit it to act on the armor?

Exolent[jNr] 02-12-2010 15:03

Re: Zero (0) HP Bug Fix by Exolent
 
Quote:

Originally Posted by dark_style (Post 1086335)
Can someone edit it to act on the armor?

What?

Excalibur.007 02-12-2010 21:50

Re: Zero (0) HP Bug Fix by Exolent
 
Quote:

Originally Posted by Exolent[jNr] (Post 1086613)
What?

He wants it to work for armor too.

Exolent[jNr] 02-13-2010 01:07

Re: Zero (0) HP Bug Fix by Exolent
 
There is no 0 armor bug.

dark_style 02-13-2010 05:15

Re: Zero (0) HP Bug Fix by Exolent
 
Quote:

Originally Posted by Exolent[jNr] (Post 1087098)
There is no 0 armor bug.

Sory, but I think when armor is 200 then show me 0 armor?

Exolent[jNr] 02-13-2010 16:05

Re: Zero (0) HP Bug Fix by Exolent
 
You don't understand the purpose of this plugin.
If a player has more than 255 health, it will loop back to less than or equal to 255.
Example: 510 (which is 255 * 2) will be reduced to 255, but the player's real health is still 510.

The bug with this is when a player has a health value of 256x, where x is any postive integer, it will reduce the player's health to 0 because 255 is the maximum.
When a player's HUD health is 0 but actual health is greater than 255, it turns the player's screen to an awkward view and changes how the player can move.

This plugin detects when that happens and adds 1 health to the player so that the player's HUD health is 1 instead of 0, thus removing the bug.

dark_style 02-14-2010 11:49

Re: Zero (0) HP Bug Fix by Exolent
 
Quote:

Originally Posted by Exolent[jNr] (Post 1087809)
You don't understand the purpose of this plugin.
If a player has more than 255 health, it will loop back to less than or equal to 255.
Example: 510 (which is 255 * 2) will be reduced to 255, but the player's real health is still 510.

The bug with this is when a player has a health value of 256x, where x is any postive integer, it will reduce the player's health to 0 because 255 is the maximum.
When a player's HUD health is 0 but actual health is greater than 255, it turns the player's screen to an awkward view and changes how the player can move.

This plugin detects when that happens and adds 1 health to the player so that the player's HUD health is 1 instead of 0, thus removing the bug.

Okay, sorry and thanks. :oops:

bLacK-bLooD 10-15-2011 06:52

Re: Zero (0) HP Bug Fix by Exolent
 
I use CSDM 2.1.2 and when i am 1 vs 1 , and i die, i have 0 hp and messed up movements.

I use your plugin now, is on the bottom of my plugins.ini , but the same damn thing. 0 hp bug not fixed.

Code:

Zero (0) HP Bug F  0.4        Exolent          zero_hp_fix.amx  runnin
What to do?


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

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