AlliedModders

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

Zidd 04-08-2005 19:44

decreasing health
 
does anyone know how to make health decrease by 1HP every .5 seconds til the person gets 1 hp and also does anyone know how to give a person health based on how much damage they do like if you deal 55 damage you get 55 health like that

v3x 04-08-2005 19:54

Try this:
Code:
#include <amxmodx> #include <amxmisc> #include <fun> public plugin_init() {     register_plugin("Decrease HP","0.1","John Doe")     register_clcmd("amx_decreasehp","setHp",ADMIN_KICK,"<nick, #userid>") } public setHp(id,lvl,cid) {     if(!cmd_access(id,lvl,cid,2)) {         return PLUGIN_HANDLED     }     new arg[33]     read_argv(1,arg,32)     new player = cmd_target(id,arg,1+2)     if(!player) {         return PLUGIN_HANDLED     }     set_task(0.5,"remHp",player)     return PLUGIN_HANDLED } public remHp(player) {     new userHp = get_user_health(player)     if(userHp == 1) {         remove_task(player)         return PLUGIN_HANDLED     }     set_user_health(player,userHp - 1)     return PLUGIN_HANDLED }

Sp4rt4n 08-03-2005 17:46

What would you have to do to that code to make it apply to everyone?

(I know, I know, old post :P)

XxAvalanchexX 08-03-2005 17:51

That code wouldn't even work because it would run once and stop.

Sp4rt4n 08-03-2005 18:04

Code:
#include <amxmodx> #include <amxmisc> #include <fun> public plugin_init() {     register_plugin("Decrease HP","0.1","John Doe")     register_clcmd("amx_decreasehp","setHp",ADMIN_KICK,"<nick, #userid>") } public setHp(id,lvl,cid) {     if(!cmd_access(id,lvl,cid,2)) {         return PLUGIN_HANDLED     }     new arg[33]     read_argv(1,arg,32)     new player = cmd_target(id,arg,1+2)     if(!player) {         return PLUGIN_HANDLED     }     set_task(0.5,"remHp",player)     return PLUGIN_HANDLED } public remHp(player) {     new userHp = get_user_health(player)     if(userHp == 1) {         remove_task(player)         return PLUGIN_CONTINUE     }     set_user_health(player,userHp - 1)     return PLUGIN_CONTINUE }

Thatd work for what Zidd would want to do, now what about me? :P

XxAvalanchexX 08-03-2005 23:31

Code:
#include <amxmodx> #include <amxmisc> #include <fun> public plugin_init() {     register_plugin("Decrease HP","0.1","John Doe")     register_clcmd("amx_decreasehp","setHp",ADMIN_KICK,"<nick, #userid | ALL>") } public setHp(id,lvl,cid) {     if(!cmd_access(id,lvl,cid,2)) {         return PLUGIN_HANDLED     }     new arg[33]     read_argv(1,arg,32)     if(equali(arg,"ALL")) {         set_task(0.5,"remHp",0)         return PLUGIN_HANDLED     }     new player = cmd_target(id,arg,1+2)     if(!player) {         return PLUGIN_HANDLED     }     set_task(0.5,"remHp",player)     return PLUGIN_HANDLED } public remHp(player) {     if(player == 0) {         new players[32], num, i, stillalive;         get_players(players,num,"a");         for(i=0;i<num;i++) {             new userHp = get_user_health(players[i]);             if(userHp <= 1) {                 continue;             }             stillalive = 1; // let us know to keep looping             set_user_health(players[i],userHp - 1);         }         if(stillalive == 1) {             set_task(0.5,"remHp",0);         }     }     else {         new userHp = get_user_health(player)         if(userHp == 1) {             return PLUGIN_CONTINUE         }         set_user_health(player,userHp - 1)         set_task(0.5,"remHp",player)     }     return PLUGIN_CONTINUE }

Use ALL to do it to everyone. If everyone is either dead or everyone has 1 HP or less it will stop looping.


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

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