AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Zombie Plague Mod (https://forums.alliedmods.net/forumdisplay.php?f=126)
-   -   Subplugin Submission [ZP] Human HP Disguise (https://forums.alliedmods.net/showthread.php?t=89281)

BOYSplayCS 04-04-2009 15:09

[ZP] Human HP Disguise
 
1 Attachment(s)
[ZP] Human HP Disguise 1.0
BOYSplayCS

Description:
When the humans HP drops below a certain amount, they will turn semi-invisible.


Cvars:
zp_disguise_health "35" - Determines the health needed to turn semi-invisible
zp_disguise_alpha "0" - Determines the invisibility amount


Credits:
Exolent - Provided coding help/optimization


Changelog:
4/4/09: Plugin Released (1.0)
4/4/09: Code Changed (1.0) //thanks to Exolent


DruGzOG 04-04-2009 15:18

Re: [ZP] Human HP Disguise
 
o0o, shouldn't this be under the zp topic?

By the way, nice plugin

BOYSplayCS 04-04-2009 15:20

Re: [ZP] Human HP Disguise
 
You know, I'm not so sure. I've been reading about where to post it and everything is confusing me. I think I post it here first, I am not sure at all.

Thank you :)

Exolent[jNr] 04-04-2009 16:10

Re: [ZP] Human HP Disguise
 
All submitted plugins should be posted here.
If it is for a certain mod that has it's own sub-forum, it will be moved if it is approved.

BOYSplayCS 04-04-2009 16:30

Re: [ZP] Human HP Disguise
 
Thank you Exolent. I need some feedback for this plugin so I can get it approved. It does work for me though.

BOYSplayCS 04-04-2009 16:44

Re: [ZP] Human HP Disguise
 
Notice: View the regular version here!

Exolent[jNr] 04-04-2009 16:49

Re: [ZP] Human HP Disguise
 
Okay, lets start.

1. I suggest a cvar for the visibility.

2. I don't think you need ".inc" in the #include.
Code:
#include <zombieplague> // should be enough

3.
Code:
if (get_user_health( id ) > get_pcvar_num( hplevel ) || zp_get_user_zombie(id)) {     return PLUGIN_CONTINUE }
This won't help much, but it will help.
Code:
if (zp_get_user_zombie(id) || get_user_health( id ) > get_pcvar_num( hplevel )) {     return PLUGIN_CONTINUE }

4.
Code:
client_print(id, print_chat, "[ZP] Your health is below %d, you are now semi-invisible.", hplevel);
You printed the cvar pointer value, not the cvar value, lol.[/pawn]

5. I haven't tested, but it seems like the message will be displayed every time the player is hurt after the message has shown the first time.

6. I would do it like this:
Code:
#include <amxmodx> #include <amxmisc> #include <zombieplague> #include <fun> #define PLUGIN "Human HP Disguise" #define VERSION "1.0" #define AUTHOR "BOYSplayCS" new hplevel // Amount of HP before turning Semi-Invisible. new invisamount // Alpha amount for when player has become Semi-Invisible new g_old_health[33]; public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         register_event("Health", "EventHealth", "b");         hplevel = register_cvar("zp_disguise_health", "35");     invisamount = register_cvar("zp_disguise_alpha", "0"); } public EventHealth(client) {     new health = read_data(2);     if( health == g_old_health[client] ) return;         if( !zp_get_user_zombie(id) && health > 0 )     {         new disguise_amount = get_pcvar_num(hplevel);         if( health <= disguise_amount && g_old_health[client] > disguise_amount )         {             set_user_rendering(client, kRenderFxNone, 0, 0, 0, kRenderTransAdd, get_pcvar_num(invisamount));             client_print(client, print_chat, "[ZP] Your health is below %d, you are now semi-invisible.", disguise_amount);         }     }         g_old_health[client] = health; }

Also, you can take these same suggestions for the "Normal" version.

BOYSplayCS 04-04-2009 16:52

Re: [ZP] Human HP Disguise
 
I was actually in the middle of adding a cvar for the invis amount.

About the %d, that was a mistake, lol. I was rushing through it and must have accidentally typed d.

I will add your suggestions, thank you :)

Exolent[jNr] 04-04-2009 16:53

Re: [ZP] Human HP Disguise
 
No, %d isn't the problem. %d and %i are the same. The problem is that you used "hplevel" in the formatting instead of "get_pcvar_num(hplevel)".

BOYSplayCS 04-04-2009 16:59

Re: [ZP] Human HP Disguise
 
I thought that for a cvar value you always used %i though? Guess not, thanks!

Updated


All times are GMT -4. The time now is 16:52.

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