how can i decrease player health?
#1

how can i decrease player health with a timer ?(not instant kill ex: -5 or -3)
Reply
#2

by using GetPlayerHealth and SetPlayerHealth
Reply
#3

Quote:
Originally Posted by cessil
Посмотреть сообщение
by using GetPlayerHealth and SetPlayerHealth
Done but is killing, not decreasing :S
Reply
#4

pawn Код:
#include <a_samp>

#define SECONDS 60

forward HealthDecrease(playerid);

public OnGameModeInit()
{
    SetTimer("HealthDecrease", SECONDS*1000, true);
    return 1;
}

public HealthDecrease(playerid)
{
    new Float:HP;
    GetPlayerHealth(playerid, HP);
    SetPlayerHealth(playerid, HP-1);
    return 1;
}
Reply
#5

Quote:
Originally Posted by California
Посмотреть сообщение
pawn Код:
#include <a_samp>

#define SECONDS 60

forward HealthDecrease(playerid);

public OnGameModeInit()
{
    SetTimer("HealthDecrease", SECONDS*1000, true);
    return 1;
}

public HealthDecrease(playerid)
{
    new Float:HP;
    GetPlayerHealth(playerid, HP);
    SetPlayerHealth(playerid, HP-1);
    return 1;
}
Your code doesn't work, you've to use a loop inside the callback because "(playerid)" will be always 0.
Reply
#6

Quote:
Originally Posted by MrDeath
Посмотреть сообщение
Your code doesn't work, you've to use a loop inside the callback because "(playerid)" will be always 0.
That's true, I didn't even know that, and when the timer is executed, playerid will be 0 because I didn't create a loop then use SetTimerEx to define the params.

Anyway, Armed2 was right.

Quote:
Originally Posted by Grdamn13
if u are using a gf edit just /sethp
No, he wants a timer.
Reply
#7

Quote:
Originally Posted by MrDeath
Посмотреть сообщение
Your code doesn't work, you've to use a loop inside the callback because "(playerid)" will be always 0.
He can always use SetTimerEx
Reply
#8

Quote:
Originally Posted by California
Посмотреть сообщение
That's true, I didn't even know that, and when the timer is executed, playerid will be 0 because I didn't create a loop then use SetTimerEx to define the params.

Anyway, Armed2 was right.



No, Josh, he wants a timer.
I know, I only posted that because if he use your code it won't work .
Reply
#9

Quote:
Originally Posted by Mean
Посмотреть сообщение
He can always use SetTimerEx
Thats crazy because your going to have all your players running that timer.
Reply
#10

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
Thats crazy because your going to have all your players running that timer.
Yea that is true lol.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)