AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   [Request] Save HP from last Round (https://forums.alliedmods.net/showthread.php?t=262223)

Syturi0 04-30-2015 07:46

[Request] Save HP from last Round
 
I have this feature on my VIP plugin.
PHP Code:

public hook_death()
{
    
id read_data(1// Killed id
    
    
if(!(get_user_flags(id) & ADMIN_LEVEL_H))
        return 
PLUGIN_HANDLED

    nHp_add 
35
    
    Killer_hp 
get_user_health(id)
    
Killer_hp += nHp_add

    set_user_health
(idKiller_hp)
    
    return 
PLUGIN_HANDLED


It adds +35 hp everytime a VIP player kills someone.
The only problem is that it resets on new round.

Example:
Quote:

Round Start. I have 100hp. I killed an enemy. I have 135hp. Round Ends. I have 100hp again...
I want to save the HP from last round if it is more than 101 HP.

Kia 04-30-2015 08:19

Re: [Request] Save HP from last Round
 
Make a global var
Code:
 new g_iHealth[33]

Add to hook_death()
Code:
 g_iHealth[id] = Killer_hp

Then Hook Ham_Spawn and do
Code:
 if(g_iHealth[id] > 100) set_user_health(id, g_iHealth[id]) else g_iHealth[id] = get_user_health(id)

Syturi0 04-30-2015 08:49

Re: [Request] Save HP from last Round
 
Quote:

Originally Posted by Kia (Post 2291815)
Make a global var
Code:
 new g_iHealth[33]

Add to hook_death()
Code:
 g_iHealth[id] = Killer_hp

Then Hook Ham_Spawn and do
Code:
 if(g_iHealth[id] > 100) set_user_health(id, g_iHealth[id]) else g_iHealth[id] = get_user_health(id)

Thank you! :fox:


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

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