AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Unapproved/Old Plugins (https://forums.alliedmods.net/forumdisplay.php?f=27)
-   -   Regenerator (https://forums.alliedmods.net/showthread.php?t=75728)

<<<Anonysmous>>> 08-11-2008 05:04

Regenerator
 
1 Attachment(s)
:):):up::up:Hello all People, I am very very new with Amx Mod X Scrpiting and I have just made this little thing that regenerates players health!!!
Description:
This is a little admin thing that regenerates person's health/Armour...
When You Use this command , it will regenerate the chosen player's health and to the customizable value...
CVARS!!!:
amx_reg_enabled 0/1 - Enables this plugin
amx_reg_speed - 0.1 is default, this is the speed of regeneration
amx_reg_hp - 50 is default, HOw much shall a player recieve.
amx_type 1/2 -1=Regenerator will stop at mod's max health/armor 2= Will stop from the values below.
amx_reg_max_xp - At what health shall the regenerator stop?
amx_reg_max_armor - At what armour shall the regenerator stop?
Commands!!!:
amx_regenerate "player" / @all -Starts the regeneration on player or whole server!!!
Credits:
Steve139 - My AMXX Teacher!!!!
Notes:
Works Fine For CS,CS CZ,TFC,HL,OP4,NS,SC,SCXP
If you want this for Fakemeta, ask me I will add it here!
Works With Any Half-Life Mod From now on :D
FUN/ENGINE MODULE IS REQUIRED!!!!

Sam Tsuki 08-11-2008 05:31

Re: Regenerator
 
This is all you have to do:
PHP Code:

#include <amxmodx>
#include <fun>

public plugin_init()
{
    
register_cvar("regen_hp""2")
    
register_cvar("regen_maxhp""100")
    
register_cvar("regen_time""1.0")
    
register_cvar("regen_enable""1")
    
    
set_task(get_cvar_float("regen_time"),"regen_lunch",0,"",0)
}

public 
regen_lunch() {
    if(
get_cvar_num("regen_enable") == 0) return PLUGIN_HANDLED
    
    
for(new 1<= 32i++) {
        if(
is_user_alive(i)) {
            if(
get_user_health(i) < get_cvar_num("regen_maxhp"))
                
set_user_health(iget_user_health(i) + get_cvar_num("regen_hp"))
            else
                
set_user_health(iget_cvar_num("regen_maxhp"))
        }
    }
    
set_task(get_cvar_float("regen_time"),"regen_lunch",0,"",0)
    return 
PLUGIN_HANDLED



YamiKaitou 08-11-2008 16:12

Re: Regenerator
 
Please add the SMA to the first post

Sam Tsuki 08-11-2008 18:19

Re: Regenerator
 
hmm...
That's not bad for a start
But try using more cvars next time ;)

<<<Anonysmous>>> 08-12-2008 05:44

Re: Regenerator
 
I'm working on a CVar that enables this whole thing.... I'll try too do that myself :D
EDIT: Done =)

Howdy! 08-12-2008 14:57

Re: Regenerator
 
Description?

anakin_cstrike 08-13-2008 05:35

Re: Regenerator
 
PHP Code:

if(( is_user_connected(i) && is_user_alive(i) )) 

This is bad, it's enough if you check if the user(s) are alive..if they are alive, shure they're connected:)

Lord_Destros 08-16-2008 03:53

Re: Regenerator
 
I suggest using pcvars and changing your checks on health so that they use less than checks as opposed to the not equals check as if health was manually set above the hardcoded limit the plugin will continue to increase their health.

<<<Anonysmous>>> 08-28-2008 07:51

Re: Regenerator
 
Quote:

Originally Posted by anakin_cstrike (Post 668941)
PHP Code:

if(( is_user_connected(i) && is_user_alive(i) )) 

This is bad, it's enough if you check if the user(s) are alive..if they are alive, shure they're connected:)

Sure, I will change it.... :)

Styles 09-07-2008 01:15

Re: Regenerator
 
A few things, I would cache the armor and such like new armor = get_user_armor(id)

And instead of doing if life != 100 or seomthign do if life < 100 (since what if there life was 250 from another plugin, that sucks to reset it.)


All times are GMT -4. The time now is 22:50.

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