AlliedModders

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

RPRaiden 06-09-2004 15:39

Healing Regen
 
How would I be able to do either one of these:

A) Make it so people gradually recieve 50 hp in the space of 10 seconds.
B) Make it so health is added ontop of users health instead of setting there health?

[FBX] 06-10-2004 01:27

set a task every second to give 1 hp (which you'll want to keep track of using the damage event, because you cant add hit points, you have to keep track of what he has as a variable and add one to that, ande then set his health to that variable). You'll also want to keep track of how much hp you've given someone with another variable and most likely start it at 50 and count down. You can simply use arrays such as:

new healthgive[33]
new currenthealth[33]

and set healthgive[player id] to 50 whenever you want to give them health. Then using the register event command (which i dont feel like looking up its real name right now) you can find out how much health they have. (the event "Health" will tell you what their current health is, as the first byte it sends is the value.)

this will probably blow your mind if your not already familiar with scripting though. You should look through the amxmodx.inc file (in scripting/include) to see some functions that might be handy

Jinto 06-10-2004 03:25

Re: Healing Regen
 
Quote:

Originally Posted by RPRaiden
How would I be able to do either one of these:

A) Make it so people gradually recieve 50 hp in the space of 10 seconds.
B) Make it so health is added ontop of users health instead of setting there health?

Code:
#include <amxmodx> #include <amxmisc> #include <fun> //Our countdown clock new countdown; public plugin_init() {     register_plugin("Regeneration","0.9.8","Jinto");     register_clcmd("amx_regen_all","regenall",ADMIN_LEVEL_A,"Regenerates Every Players Health ( Gives 50hp in 10 seconds )");     return PLUGIN_HANDLED; } public regenall(id,level,cid) {     //Call this task every second and remove it on the 10th second     set_task(1.0,"regen",1,"",0,"b");   //Gives them 5 health every second for 10 seconds         countdown = 10;     //Set the countdown clock to 10 seconds         return PLUGIN_HANDLED; } public regen() {     //Ok first loop through all players and give them 5 health     new players = get_playersnum();     new health;         while(players > 0) {         health = get_user_health(players);         health += 5;         set_user_health(players,health);         players--;     }         //remove one from countdown and if times up remove the task     countdown--;         if(countdown < 1) {         remove_task(1);     } }

That when executed will give all players an extra 50hp within a 10 second time frame.

Peli 06-10-2004 17:12

Very nice. You rock lol. :)

Peli 06-16-2004 23:58

I was messing with it a little and fixed some errors for you , but I didn't add the comments , here it is. :
Code:
#include <amxmodx> #include <amxmisc> #include <fun> new countdown public plugin_init() {     register_plugin("Regeneration","0.9.8","Jinto")     register_clcmd("amx_regen_all","regenall",ADMIN_LEVEL_A,"Regenerates players health by 5 hp for 10 seconds" } public regenall(id,level,cid) {     set_task(1.0,"regen",1,"",0,"b")     countdown = 10      return PLUGIN_HANDLED } public regen() {     new players = get_playersnum()     new health     while(players > 0)     {         health = get_user_health(players)         health += 5         set_user_health(players,health)         players--     }             countdown--     if(countdown < 1)     {         remove_task(1)     } }

kingpin 06-17-2004 00:00

hmm remmeber the RedCross plugin I was working on.. hmm who was it peli? or 2|ob.. wonder who I uploaded it to.. well you can use some thing like that.. its on my server you can see it there or IM me.

Peli 06-17-2004 00:02

It was me. :) Yea you can look at that as help , it's a good source. :)

Jinto 06-17-2004 01:50

There wern't any errors you only removed the semi-colons...
Sorry about those its just habbit from C++.

Peli 06-17-2004 19:19

No problem , but when I ran the compiler it came with some errors...

Peli 06-18-2004 23:50

I just want to change this around a bit , but one question.
1. How do you make it so you can only regenerate at certain areas in a map?
Thanks. :)


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

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