SA-MP Forums Archive
[SOLVED] OnPlayerUpdate ..... problem again. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [SOLVED] OnPlayerUpdate ..... problem again. (/showthread.php?tid=90649)



[SOLVED] OnPlayerUpdate ..... problem again. - Martin_White - 09.08.2009

SOLVED:
pawn Код:
#include <a_samp>

new neardeath[MAX_PLAYERS];
#define newhealth 25
forward death(playerid);
forward OnPlayerUpdate(playerid);
new Float:pHealth;
public OnPlayerUpdate(playerid)
{
    GetPlayerHealth(playerid,pHealth);
    if (pHealth < 20.0)
        {
            ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
            TogglePlayerControllable(playerid, 0);
            SetTimerEx("death", 60000, false, "i", playerid);
            neardeath[playerid]=true;
        }
    return 1;
}

public death(playerid)
{
    SetPlayerHealth(playerid, 0);
    neardeath[playerid]=false;
    return 1;
}



Re: OnPlayerUpdate ..... problem again. - Martin_White - 09.08.2009

8 People read the topic and noone answered, I want to say something:

If you know the solution, then share it, atleast to help newb who will enter and read, Not just to watch the topic and say: Hah, wannabe.., and leave..?

P.S: IF you're someone who do not know the solution do not post and say that i do not know hte solution so why u insult me?.


Re: OnPlayerUpdate ..... problem again. - Sergei - 09.08.2009

Lol, you said that if you have more than 15 health it sets crack anim and kills you.

if (pHealth > 15.0) => if (pHealth < 15.0)

SetTimer("death", 15000, 0); => SetTimerEx("death", 15000, false, "i", playerid);


Re: OnPlayerUpdate ..... problem again. - Martin_White - 09.08.2009

Can you please explain what is this:

SetTimerEx("death", 15000, false, "i", playerid);


Re: OnPlayerUpdate ..... problem again. - Sergei - 09.08.2009

You have a wiki there to explain you https://sampwiki.blast.hk/wiki/SetTimerEx


Re: OnPlayerUpdate ..... problem again. - Martin_White - 09.08.2009

Edit:

Something happened wrong, it was working good, and next time it kept spamming SetPlayerHealth(playerid, 0);

I wonder what is wrong now


Re: OnPlayerUpdate ..... problem again. - Sergei - 09.08.2009

It seems you didn't get a point. SetTimer is timer which is runned on the server as whole, if you need a timer which is appointed to the specific player id you need ot use SetTimerEx.


Of course health is being reset all the time. OnPlayerUpdate is called like every second on less, so it calls a new timer, so many times.


Re: OnPlayerUpdate ..... problem again. - Martin_White - 09.08.2009

FIXED.

But ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0); is buggy i think.


Re: [SOLVED] OnPlayerUpdate ..... problem again. - Sergei - 09.08.2009

If you mean that it doesn't apply on palyer make sure that it's preloaded or just apply it two times.


Re: [SOLVED] OnPlayerUpdate ..... problem again. - Martin_White - 09.08.2009

Fixed.

ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);