AlliedModders

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

BlueDevil 04-21-2006 19:20

Damage
 
Whats the code to make the victim lose x hp each second?
x shall be a cvar.

Basic-Master 04-21-2006 19:30

it's this:

Code:
oh, I lost the code somehow

KoST 04-21-2006 21:54

if 'victim' is a player who has hp<100:

Code:
#include <amxmodx> #define PLUGIN "MightyVictimBash0r" #define VERSION "1.0" #define AUTHOR "KoST" new max_players; public plugin_init(){     register_plugin(PLUGIN,VERSION,AUTHOR)     register_cvar("x","1")     max_players=get_maxplayers()     set_task(1.0,"bash0r",_,_,_,"b") } public bash0r(){     for (new i=1;i<=max_players;i++){         if (is_user_alive(i) && get_user_health(i)<100){             new userid=get_user_userid(i)             server_cmd("amx_slap #%d %d",userid,get_cvar_num("x"))         }     } }

note: this plugin is a good way to get the server empty ! tested and works... :lol:

FatalisDK 04-21-2006 22:43

Or if victim is player you pick.

Code:
#include <amxmodx> #include <amxmisc> #include <fun> #define PLUGIN "New Plugin" #define VERSION "1.0" #define AUTHOR "Author" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         register_clcmd("amx_gaben", "gaben", ADMIN_SLAY)     register_cvar("hp_amount", "10") } public gaben(id, level, cid) {     if (!cmd_access(id, level, cid, 3))         return PLUGIN_HANDLED             new szArg[32]     read_argv(1, szArg, 31)     new Target = cmd_target(id, szArg, 3)         new szArg2[3]     read_argv(2, szArg2, 2)     new Times = str_to_num(szArg2)         if (Target && is_user_alive(Target)) //Forgot to check if alive, thx v3x.         set_task(1.0, "loosehp", id + 69, "", 0, "a", Times)             return PLUGIN_HANDLED } public loosehp(TaskID) {     new id = TaskID - 69         if (!is_user_alive(id))     {         remove_task(id + 69)         return PLUGIN_CONTINUE     }         set_user_health(id, get_user_health(id) - get_cvar_num("hp_amount"))         return PLUGIN_CONTINUE }

v3x 04-21-2006 22:46

Remember to check if the player is alive. If he's not you can either remove the task or not set his health so it does so when it's alive again.

BlueDevil 04-22-2006 08:33

i mean like if you do a command the target loses 1 hp each second untills he dies or if you cancel the command

v3x 04-22-2006 08:36

FatalisDK just did that.

FatalisDK 04-22-2006 08:44

Use amx_loosehp <name> <how many times to loose hp>
0 means loose hp until death.
Use the same command to cancel the loosehp.

Code:
#include <amxmodx> #include <amxmisc> #include <fun> #define PLUGIN "New Plugin" #define VERSION "1.0" #define AUTHOR "Author" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         register_clcmd("amx_loosehp", "loosehp_cmd", ADMIN_SLAY)     register_cvar("amx_looseamount", "1") } public loosehp_cmd(id, level, cid) {     if (!cmd_access(id, level, cid, 3))         return PLUGIN_HANDLED         new szArg[32]     read_argv(1, szArg, 31)     new Target = cmd_target(id, szArg, 3)         new szArg2[3]     read_argv(2, szArg2, 2)     new Times = str_to_num(szArg2)         if (!Times)         Times = 100         if (Target && is_user_alive(Target)) //Forgot to check if alive, thx v3x.         if (!task_exists(id + 69)) set_task(1.0, "loosehp", id + 69, "", 0, "a", Times)         else remove_task(id + 69)         return PLUGIN_HANDLED } public loosehp(TaskID) {     new id = TaskID - 69         if (!is_user_alive(id))     {         remove_task(id + 69)         return PLUGIN_CONTINUE     }         set_user_health(id, get_user_health(id) - get_cvar_num("amx_looseamount"))         return PLUGIN_CONTINUE }


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

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