SA-MP Forums Archive
Health/timer problem - 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: Health/timer problem (/showthread.php?tid=424129)



Health/timer problem - thefatshizms - 20.03.2013

Ok, I have this timer, it's supposed to take 0.1 away from my health every 500ms (note this isn't the only thing in the timer) but instead it takes 1 which is really frustrating.

pawn Код:
public SmallTimer(playerid)
{
    new Float:H,  Float:R;

    GetPlayerHealth(playerid, H);
    R = 0.1;
   
    if(Raped[playerid] == true) {
        SetPlayerHealth(playerid, H - R);
    }
    return 1;
}
I used this and i tried a different method with no luck
pawn Код:
public SmallTimer(playerid)
{
    new Float:H;

    GetPlayerHealth(playerid, H);
   
    if(Raped[playerid] == true) {
        SetPlayerHealth(playerid, H - 0.1);
    }
    return 1;
}



Re: Health/timer problem - Patrick - 20.03.2013

im not sure about this. but give it a try

Code
pawn Код:
public SmallTimer(playerid)
{
    new H = GetPlayerHealth(playerid);
    if(Raped[playerid] == true) return SetPlayerHealth(playerid, H -0.1);
    return 1;
}
PS: i use this kind of method on my server


Re: Health/timer problem - thefatshizms - 20.03.2013

Quote:
Originally Posted by pds2012
Посмотреть сообщение
im not sure about this. but give it a try

Code
pawn Код:
public SmallTimer(playerid)
{
    new H = GetPlayerHealth(playerid);
    if(Raped[playerid] == true) return SetPlayerHealth(playerid, H -0.1);
    return 1;
}
PS: i use this kind of method on my server
That would do the same thing, the only difference is your returning a value which really isn't needed.


Re: Health/timer problem - Joshman543 - 20.03.2013

This should work, it's weird that is taking away one.

pawn Код:
public SmallTimer(playerid)
{
    new Float:H,  Float:R; // Not neccessary
    GetPlayerHealth(playerid, H);
    R = 0.1; // Not neccessary
   
    if(Raped[playerid] == true) {
        SetPlayerHealth(playerid, H - R); // or SetPlayerHealth(playerid, H - 0.1);
    }
    return 1;
}



Re: Health/timer problem - Scenario - 20.03.2013

That's odd. I wonder if something else in that timer is causing an issue... Mind posting the full thing?

See if this works either way, though:

pawn Код:
public SmallTimer(playerid)
{
    if(Raped[playerid] == true)
    {
        new
            Float:H,
            Float:R = 0.1
        ;

        GetPlayerHealth(playerid, H);
        SetPlayerHealth(playerid, H-R);
    }
    return 1;
}