public OnPlayerUpdate(playerid)
{
new Float:hp;
GetPlayerHealth(playerid,hp);
if (hp < 20.0)
{
GameTextForPlayer(playerid, "~g~You are ~r~hurt,go to ~y~cover~n~~h~", 6000, 6);
}
return 1;
}
// Somewhere in your script, not in a callback
new
losehealth;
forward HealthCheck ( );
// OnPlayerConnect
SetTimer ( HealthCheck, 1, true );
// Behind the forward HealthCheck
public HealthCheck ( )
{
for ( new i; i < MAX_PLAYERS; i ++ ) // You better use foreach
{
new
Float: iHealth;
GetPlayerHealth ( i, iHealth );
if ( iHealth < 30.0 )
{
GameTextForPlayer ( i, "YOU ARE HURT,GO TO COVER", 3000, 3 );
losehealth = SetTimer ( LoseHP, 60000, true );
}
}
return 1;
}
forward LoseHP ( );
public LoseHP ( )
{
for ( new i; i < MAX_PLAYERS; i ++ ) // You better use foreach
{
new
Float: zHealth;
GetPlayerHealth ( i, zHealth );
if ( zHealth > 0 )
{
SetPlayerHealth ( i, zHealth - 5.0 );
}
else
{
KillTimer ( losehealth );
}
}
return 1;
}
// Top of script:
new LoseHealth[MAX_PLAYERS];
// OnPlayerConnect:
LoseHealth[playerid] = SetTimerEx("healthloss", 60000, 1, "%d", playerid);
// Bottom of script:
forward healthloss(playerid);
public healthloss(playerid)
{
new Float:hp;
GetPlayerHealth(playerid, hp);
if(hp < 30.0 && hp > 0.0)
{
GameTextForPlayer(playerid, "~w~You are ~r~hurt~w~, go to ~y~cover", 5000, 5);
SetPlayerHealth(playerid, hp-5.0);
}
return 1;
}
://Put in the top of your gamemode:
new checking[MAX_PLAYERS];
new TimerHP;
forward HealthLose();
forward HealthCheck();
//In the OnGameModeInit:
SetTimer("HealthCheck",2000,1);
//In the End of your gamemode:
public HealthCheck()
{
new Float:hp;
for(new x=0; x<MAX_PLAYERS; x++)
{
if(IsPlayerConnected(x))
{
GetPlayerHealth(x,hp);
if(hp < 20.0)
{
GameTextForPlayer(x, "~g~You are ~r~hurt,go to ~y~cover~n~~h~", 6000, 6);
TimerHP = SetTimerEx("HealthLose", 300000, 0, "i", x);
checking[x] = 1;
} }
}
}
public HealthLose()
{
for(new x=0; x<MAX_PLAYERS; x++)
{
new Float:Health;
if(IsPlayerConnected(x))
{
if(checking[x] == 1)
{
GetPlayerHealth(x,Health);
SetPlayerHealth(x, Health - 5.0);
KillTimer(TimerHP);
checking[x] = 0;
} }
}
}
|
I did it
:pawn Код:
I hope that i have helped ![]() |