How to make bleeding system timer
#1

Hey guys, i want to know, how to reduce player health every 5 seconds, not immediately. Because this is really annoying. I set -1 health in "OnPlayerUpdate" and it decreased 1 health every half-second.
Here is the code
Код:
public OnPlayerUpdate(playerid)
{
/* 
Many things that i'll not show in this code
*/
new status[64], Float:health, Float:armor, string[128];
	GetPlayerHealth(playerid, health);
	GetPlayerArmour(playerid, armor);
	if(GetPVarInt(playerid, "Injured") != 1)
	{
	 if(PlayerInfo[playerid][pTS] > 1 && health > 5)
	 {
	 SetPlayerHealth(playerid, health-1);
  }
 }
	if(GetPVarInt(playerid, "Injured") != 1)
	{
	 if(PlayerInfo[playerid][pHS] > 1 && health > 5)
	 {
  SetPlayerHealth(playerid, health-1);
  }
 }
/*
MANY MORE THINGS
*/
return 1;
}
Please re-make the script 4 me and a timer for decreasing 1 health every 5 seconds
Reply
#2

https://sampforum.blast.hk/showthread.php?tid=607399
Reply
#3

No, not the filterscript, and it don't decrease the health.
Reply
#4

Just create a timer.
Whenever a player starts to bleed. run this timer every 5 seconds and kill the timer when the player has stopped bleeding.

This tutorial might help you setting up that timer:
https://sampforum.blast.hk/showthread.php?tid=171959

Don't use onplayerupdate for such things as it may really start lagging your server.
Reply
#5

So, i should do it in what?
Reply
#6

OnPlayerUpdate is not a timer. and it doesn't have equal interval. It's at least called 33 times per second.

Use SetTimerEx and assign the timer ID to a variable.
Reply
#7

Im still a newbie scripter. Please make it for me, or at least tell me where should i make the code.
In public what?
Reply
#8

@Dirda here you go mate

Код HTML:
// Variable and a Timer that activate the injure system.

new Injured[MAX_PLAYERS], Timer:InjureTime[MAX_PLAYERS];

// You need to add this variables and timers that i added under OnPlayerTakeDamage / OnPlayerDeath / OnPlayerDisconnect
// You need to add this variables and timers that i added under OnPlayerTakeDamage / OnPlayerDeath / OnPlayerDisconnect
// You need to add this variables and timers that i added under OnPlayerTakeDamage / OnPlayerDeath / OnPlayerDisconnect

public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
	if(Injured[playerid] == 1) return 1;
	Injured[playerid] = 1, InjureTime[playerid] = repeat InjuredTime(playerid);
	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    Injured[playerid] = 0;
	stop InjureTime(playerid);
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    Injured[playerid] = 0;
	stop InjureTime(playerid);
	return 1;
}

// This timer you can add everywhere in your script, mostly go at the bottom.

timer InjuredTime[5000](playerid)
{
    new Float:HP;
	GetPlayerHealth(playerid, HP);
	if(Injured[playerid] == 1) SetPlayerHealth(playerid, HP-1);
	return 1;
}
Ann me if is something wrong.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)