Raised This Month: $ Target: $400
 0% 

[Request] Save HP from last Round


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Syturi0
Veteran Member
Join Date: Aug 2014
Location: Your mom house -Portugal
Old 04-30-2015 , 07:46   [Request] Save HP from last Round
Reply With Quote #1

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.
Syturi0 is offline
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 04-30-2015 , 08:19   Re: [Request] Save HP from last Round
Reply With Quote #2

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)
__________________
Kia is offline
Syturi0
Veteran Member
Join Date: Aug 2014
Location: Your mom house -Portugal
Old 04-30-2015 , 08:49   Re: [Request] Save HP from last Round
Reply With Quote #3

Quote:
Originally Posted by Kia View Post
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!
Syturi0 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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