AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Test this? (https://forums.alliedmods.net/showthread.php?t=29122)

Kensai 05-29-2006 23:47

Test this?
 
I don't have access to any servers, so can you guys test this out real quick. More games the merrier.

It should make every player glow by how much health they have.

100 = Green
10 = Red

The lower the health the more red it turns.

Thanks a bunch.

Xanimos 05-30-2006 00:02

1) What you have would only be run once.
2) Using if's like that is shit.
3) Lets work on this.

Code:
#include <amxmodx> #include <amxmisc> #include <fun> public plugin_init() {     register_plugin("Glow by Health", "1.0", "Kensai")     register_event("Damage" , "health" , "b" , "2!0")     register_event("ResetHUD" , "health" , "b" ) } public health(id) {     new health = get_user_health(id)         switch(health)     {         case 100: set_user_rendering(id, kRenderFxGlowShell, 0, 187, 4, kRenderTransAlpha, 255)         case 90..99: set_user_rendering(id, kRenderFxGlowShell, 47, 187, 0, kRenderTransAlpha, 255)         case 80..89: set_user_rendering(id, kRenderFxGlowShell, 94, 187, 0, kRenderTransAlpha, 255)         case 70..79: set_user_rendering(id, kRenderFxGlowShell, 131, 186, 1, kRenderTransAlpha, 255)         case 60..69: set_user_rendering(id, kRenderFxGlowShell, 172, 186, 1, kRenderTransAlpha, 255)         case 50..59: set_user_rendering(id, kRenderFxGlowShell, 186, 182, 1, kRenderTransAlpha, 255)         case 40..49: set_user_rendering(id, kRenderFxGlowShell, 185, 157, 2, kRenderTransAlpha, 255)         case 30..39: set_user_rendering(id, kRenderFxGlowShell, 186, 140, 1, kRenderTransAlpha, 255)         case 20..29: set_user_rendering(id, kRenderFxGlowShell, 187, 98, 0, kRenderTransAlpha, 255)         case 10..19: set_user_rendering(id, kRenderFxGlowShell, 186, 56, 1, kRenderTransAlpha, 255)         default: set_user_rendering(id, kRenderFxGlowShell, 187, 0, 0, kRenderTransAlpha, 255)     }             return PLUGIN_CONTINUE; }

Much better.

Kensai 05-30-2006 15:54

Ah okay. Didn't know how to use a switch statement like that. So I had to use the ifs.

And thanks for the events.

KoST 05-30-2006 16:31

what about this?

Code:
#include <amxmodx> #include <amxmisc> #include <fun> #define MAX_COLOR 187 public plugin_init() {     register_plugin("Glow by Health", "1.0", "Kensai")     register_event("Damage" , "health" , "b" , "2!0")     register_event("ResetHUD" , "health" , "b" ) } public health(id) {     new health = get_user_health(id)     new Float:factor=float(MAX_COLOR)/100.0 //1.87     new r=MAX_COLOR-floatround((float(health)*factor))     new g=floatround((float(health)*factor))     set_user_rendering(id, kRenderFxGlowShell, r, g, 4, kRenderTransAlpha, 255)     return PLUGIN_CONTINUE; }

[edit] thx VEN !

SweatyBanana 05-30-2006 16:33

Ahhh lots of math...but about 5 times shorter :)

Xanimos 05-30-2006 16:43

I would have done that but I wasn't in the mood to do math....So I just fixed his if's into something better.

VEN 05-30-2006 18:29

KoST: this will not work as you expect.
Quote:

Originally Posted by BAILOPAN
A re-tag is a bitstring copy, not a type cast

Use floatround native.


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

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