[SOLVED] OnPlayerUpdate ..... problem again.
#1

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;
}
Reply
#2

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?.
Reply
#3

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);
Reply
#4

Can you please explain what is this:

SetTimerEx("death", 15000, false, "i", playerid);
Reply
#5

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

Edit:

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

I wonder what is wrong now
Reply
#7

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.
Reply
#8

FIXED.

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

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

Fixed.

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


Forum Jump:


Users browsing this thread: 1 Guest(s)