SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 16/12/2019, 02:58 PM   #1
KayJ
Gangsta
 
KayJ's Avatar
 
Join Date: Apr 2014
Posts: 678
Reputation: 64
Default HealthIncrease Timer

PHP Code:
CMD:cure(playerid,params[])
{
    if(
BeingCured[playerid] == 1) return SendClientMessage(playerid0xFF9900AA"You're already being cured. Please wait for medicine to take effect.");
    switch(
Infected[playerid])
    {
        case 
0:
        {
            
SendClientMessage(playerid0xFF9900AA"You're not infected.");
        }
        case 
1:
        {
            
BeingCured[playerid] = 1;
            
KillTimer(InfectedTimer[playerid]);
            
SendClientMessage(playerid0xFF9900AA"You've cured your zombie infection! You'll feel better gradually.");
            
HealTimer[playerid] = SetTimerEx("HealthIncrease"30001"i"playerid);
        }
    }
    return 
1;

PHP Code:
forward HealthIncrease(playerid);
public 
HealthIncrease(playerid)
{
    new 
Float:HP;
    
GetPlayerHealth(playeridHP);
    
SetPlayerHealth(playeridHP+5);
    if (
HP == 100.0)
    {
        
KillTimer(HealTimer[playerid]);
        
Cured[playerid] = 1;
    }
    return 
1;

The problem is the health keeps increasing after 100.0
KayJ is offline   Reply With Quote
Old 16/12/2019, 03:15 PM   #2
Ever_SH
Gangsta
 
Ever_SH's Avatar
 
Join Date: Sep 2012
Location: RS
Posts: 580
Reputation: 19
Default Re: HealthIncrease Timer

PHP Code:
forward HealthIncrease(playerid);
public 
HealthIncrease(playerid)
{
    new 
Float:HP;
    
GetPlayerHealth(playeridHP);
    
SetPlayerHealth(playeridHP+5);
    if (
HP >= 100.0)
    {
        
SetPlayerHealth(playerid100);
        
KillTimer(HealTimer[playerid]);
        
Cured[playerid] = 1;
    }
    return 
1;

Ever_SH is offline   Reply With Quote
Old 16/12/2019, 03:17 PM   #3
xRadical3
Gangsta
 
xRadical3's Avatar
 
Join Date: May 2017
Location: Iran
Posts: 565
Reputation: 20
Default Re: HealthIncrease Timer

if (HP == 100.0)
To
if (HP >= 100.0)

Because you healthed player every 3secs and if player health is 96 and timer called increased to 101 ...

pawn Code:
forward HealthIncrease(playerid);
public HealthIncrease(playerid)
{
    new Float:HP;
    GetPlayerHealth(playerid, HP);
    if (HP >= 100.0)
    {
        SetPlayerHealth(playerid, 100);
        KillTimer(HealTimer[playerid]);
        Cured[playerid] = 1;
    }
    else
    {
        SetPlayerHealth(playerid, HP+5);
    }
    return 1;
}
xRadical3 is online now   Reply With Quote
Reply

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Performance Question , Per Player Timer vs Timer that loops through all players BiosMarcel Scripting Help 14 12/12/2016 09:50 AM
If /foodsearch doesn't find item, set wait timer (TIMER HELP) Josh_Main Scripting Help 7 14/09/2016 04:13 PM
Which is better Per Player Timer or Global timer? (issue with timer) Dokins Scripting Help 4 07/06/2016 09:50 AM
Slice's Timer Fix include --> timer public function isn't getting called Riwerry Scripting Help 0 02/01/2016 03:50 PM
[Timer Help] Score saving timer, should it always be running or should it be killed? Ghost100 Scripting Help 6 08/10/2012 10:12 PM


All times are GMT. The time now is 09:01 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.