13.05.2011, 15:42
I need a timer, So it decreases like 5 or less hp each second, I'm confused with it. So after a few seconds the hp should finally reach 0 and the player dies. Please help me with this
// Your function
forward Death(playerid);
public Death(playerid)
{
new Float:Health;
GetPlayerHealth(playerid, Health);
SetPlayerHealth(playerid, Health-5);
}
new KillTimer;
KillTimer = SetTimer("KillTimer", 5000, 0);
forward KillTimer();
public KillTimer()
{
new Float:HP;
GetPlayerHealth(playerid, HP);
SetPlayerHealth(playerid, HP -5);
}
//Other stuff..
KillTimer(KillTimer);
forward Death(playerid);
public Death(playerid)
{
new Float:Health;
GetPlayerHealth(playerid, Health);
SetPlayerHealth(playerid, Health-5)
if(Health-5 <= 0) KillTimer(GetPVarInt(playerid, "timerDeath"));
}
SetTimerEx("Death", 1000, true, "i", playerid);
new InfectedTimer[MAX_PLAYERS];
COMMAND:infect(playerid, params[])
{
new targetid;
if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, 0xFFFFFFAA, "USAGE: /infect [playeris | name]");
else if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFFFFFFAA, "That player is not connected");
{
InfectedTimer[playerid] = SetTimerEx("Infected", 1000, true, "d", targetid);
SendClientMessage(playerid, 0xFFFFFFAA, "You infected someone");
SendClientMessage(targetid, 0xFFFFFFAA, "Someone infected you");
}
return 1;
}
forward Infected(playerid);
public Infected(playerid)
{
new Float:Health;
GetPlayerHealth(playerid, Health);
if(Health >= 5)
{
SetPlayerHealth(playerid, Health - 5);
}
else
{
SetPlayerHealth(playerid, 0.0);
KillTimer(InfectedTimer[playerid]);
SendClientMessageToAll(0xFFFFFFAA, "Someone died of a infection");
}
return 1;
}
Whole command.
Not Tested pawn Код:
|
if(Health-2 <= 0) KillTimer(GetPVarInt(playerid, "timerDeath")); |