SA-MP Forums Archive
How to make bleeding system timer - 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: How to make bleeding system timer (/showthread.php?tid=652198)



How to make bleeding system timer - Dirda - 05.04.2018

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


Re: How to make bleeding system timer - m4karow - 05.04.2018

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


Re: How to make bleeding system timer - Dirda - 05.04.2018

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


Re: How to make bleeding system timer - jasperschellekens - 05.04.2018

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.


Re: How to make bleeding system timer - Dirda - 05.04.2018

So, i should do it in what?


Re: How to make bleeding system timer - Logic_ - 05.04.2018

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.


Re: How to make bleeding system timer - Dirda - 05.04.2018

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


Re: How to make bleeding system timer - MarianImmortalGod - 05.04.2018

@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.