SA-MP Forums Archive
Help (TimerEx bug) [Rep+] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help (TimerEx bug) [Rep+] (/showthread.php?tid=293878)



Help (TimerEx bug) [Rep+] + ANOTHER QUESTION! - GangsTa_ - 30.10.2011

pawn Код:
forward hptimer(playerid);
public hptimer(playerid)
{
    new Float:health;
    health = GetPlayerHealth(playerid, health);
    SetPlayerHealthAC(playerid, health+1);
    PlayerInfo[playerid][pHP] = SetPlayerHealth(playerid, health+1);
    GameTextForPlayer(playerid, "~g~+1 HP", 500, 3);
    PlayerPlaySound(playerid, 1083, 0.0,0.0,0.0);
    SetTimerEx("hptimer", 7000, 0, "d", playerid);
    return 1;
}
Please help. I want to make a system which gives +1 HP to the existing health. But it sets the HP to 1 (Dunno why).


Re: Help (TimerEx bug) [Rep+] - Kyle - 30.10.2011

Use this:

pawn Код:
forward hptimer(playerid);
public hptimer(playerid)
{
    new Float:health;
    GetPlayerHealth(playerid, health);
        SetPlayerHealthAC(playerid, health+1);
    PlayerInfo[playerid][pHP] = SetPlayerHealth(playerid, health+1);
    GameTextForPlayer(playerid, "~g~+1 HP", 500, 3);
    PlayerPlaySound(playerid, 1083, 0.0,0.0,0.0);
    SetTimerEx("hptimer", 7000, 0, "d", playerid);
    return 1;
}



Re: Help (TimerEx bug) [Rep+] - playbox12 - 30.10.2011

The above code will work, what you did was this.

You create a float value called health.

You call the function GetPlayerHealth, and let it store the health value in health. Now when that function finishes you let it store the value it returned in health. This means the actuall health will be deleted and it will probally contain 00000.1 or just 0000000 or something among those lines.


Re: Help (TimerEx bug) [Rep+] - Pinguinn - 30.10.2011

EDIT: Too late


Re: Help (TimerEx bug) [Rep+] - GangsTa_ - 30.10.2011

Checking...


Re: Help (TimerEx bug) [Rep+] - wups - 30.10.2011

Jeez, just change
pawn Код:
health = GetPlayerHealth(playerid, health);
to
pawn Код:
GetPlayerHealth(playerid, health);



Re: Help (TimerEx bug) [Rep+] - GangsTa_ - 30.10.2011

Woah thanks works!
Another question:

How to make if a player has 100 HP the timer will stop?


Re: Help (TimerEx bug) [Rep+] - Edvin - 30.10.2011

pawn Код:
forward hptimer(playerid);
public hptimer(playerid)
{
    SetPlayerHealthAC(playerid, GetPlayerHealth(playerid)+1);
    PlayerInfo[playerid][pHP] = SetPlayerHealth(playerid, GetPlayerHealth(playerid)+1);
    GameTextForPlayer(playerid, "~g~+1 HP", 500, 3);
    PlayerPlaySound(playerid, 1083, 0.0,0.0,0.0);
    SetTimerEx("hptimer", 7000, 0, "d", playerid);
    return 1;
}
Somethink like this...

But how do you call "hptimer" function? because i see SetTimerEx in function...


Re: Help (TimerEx bug) [Rep+] - GangsTa_ - 30.10.2011

No, I'm asking how to make if a player has 100 HP the timer will stop?
What callback to use?


Re: Help (TimerEx bug) [Rep+] - RyDeR` - 30.10.2011

Quote:
Originally Posted by GangsTa_
Посмотреть сообщение
Woah thanks works!
Another question:

How to make if a player has 100 HP the timer will stop?
Just use this:
pawn Код:
forward hptimer(playerid); public hptimer(playerid) {
    new
        Float: fHealth
    ;
    GetPlayerHealth(playerid, fHealth);
    fHealth += 1.0;
    SetPlayerHealthAC(playerid, fHealth);
    PlayerInfo[playerid][pHP] = fHealth;
    GameTextForPlayer(playerid, "~g~+1 HP", 500, 3);
    PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
   
    if(fHealth < 100.0) {
        SetTimerEx("hptimer", 7000, 0, "i", playerid);
    }
    return 1;
}