AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   hp recover plugin (https://forums.alliedmods.net/showthread.php?t=231955)

AvaStIn 12-23-2013 03:29

hp recover plugin
 
im searching for a plugin to recover hp (100 hp) after player fall from a high spot and simply reset his hp after few seconds (100 hp)

Kia 12-23-2013 04:23

Re: hp recover plugin
 
Try this.

PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fun>

#define PLUGIN "Recover my Health"
#define VERSION "1.0.0"
#define AUTHOR "Kia"

// !!!
// ===============================================================================
//     WARNING! THIS PLUGIN IS UNTESTED! USE ON OWN RISK!
// ===============================================================================
// !!!

// ===============================================================================
//     Editing begins here
// ===============================================================================

// Time in Seconds for healing HEALTH_AMOUNT Health.
#define HEALTH_INTERVAL 0.5

// Health per HEALTH_INTERVAL
#define HEALTH_AMOUNT 6

// ===============================================================================
//     and stops here. DO NOT MODIFY BELOW UNLESS YOU KNOW WHAT YOU'RE DOING
// ===============================================================================

// ===============================================================================
//     Variables
// ===============================================================================

/* Defines */

#define TASK_ID_RECOVER 1920

#define DMG_FALL (1<<5) 

// ===============================================================================
//     plugin_init
// ===============================================================================

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
/* Hamsandwich */
    
    
RegisterHam(Ham_TakeDamage"player""Ham_PlayerTakeDamgePre"0);
}

// ===============================================================================
//     Ham_PlayerTakeDamgePre - Called when a player is taking Damage
// ===============================================================================

public Ham_PlayerTakeDamgePre(idiInflictoriAttackerFloat:flDamageiDmgBits)
{
    if(
iDmgBits DMG_FALL)
    {
        new 
Float:flTimeToRecover
        
        flTimeToRecover 
= ((100 flDamage) / HEALTH_AMOUNT) * HEALTH_INTERVAL
        
        set_task
(HEALTH_INTERVAL"GivePlayerIntervalHealth"TASK_ID_RECOVER id)
        
set_task(flTimeToRecover"StopRecoverTask"TASK_ID_RECOVER id)
    }
}

// ===============================================================================
//     GivePlayerIntervalHealth - Called after a player falled down
// ===============================================================================

public GivePlayerIntervalHealth(id)
{
    
id -= TASK_ID_RECOVER
    set_user_health
(idget_user_health(id) + HEALTH_AMOUNT)
}
    
// ===============================================================================
//     StopRecoverTask - Stops the plugin giving the player Health
// ===============================================================================

public StopRecoverTask(id)
    
remove_task(id


ANTICHRISTUS 12-23-2013 04:37

Re: hp recover plugin
 
saw something like this, maybe author is ConnorMcLeod.


All times are GMT -4. The time now is 20:31.

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