21.05.2013, 17:52
How can I disable this ?
public OnPlayerUpdate(playerid)
{
new
Float:fHealth;
GetPlayerHealth(playerid, fHealth);
if(fHealth > 100.0) SetPlayerHealth(playerid, 100.0);
return 1;
}
public OnGameModeInit()
{
SetTimer("HealthCheck", true, 1000);
return 1;
}
forward HealthCheck();
public HealthCheck()
{
foreach(new i : Player)
{
new
Float:fHealth;
GetPlayerHealth(i, fHealth);
if(fHealth > 100.0) SetPlayerHealth(i, 100.0);
}
return 1;
}
I didn't put it in a timer because we wouldn't want anyone on the server to have over 100 HP and possibly get a tiny advantage over everyone else because the timer didn't call for them yet or something.
But, it would be simple to convert to a timer.. pawn Код:
|
forward HealthCheck();
public HealthCheck()
{
foreach(new i : Player)
{
new
Float:fHealth;
GetPlayerHealth(i, fHealth);
if(fHealth > 100.0) SetPlayerHealth(i, 100.0);
}
return 1;
}
forward HealthCheck();
public HealthCheck()
{
for( new i = 0; i < MAX_PLAYERS; i ++ ) if( IsPlayerConnected( i ) )
{
new
Float:fHealth;
GetPlayerHealth(i, fHealth);
if(fHealth > 100.0) SetPlayerHealth(i, 100.0);
}
return 1;
}
forward HealthCheck();
public HealthCheck()
{
new Float:fHealth;
for( new i = 0; i < MAX_PLAYERS; i ++ ) if( IsPlayerConnected( i ) )
{
GetPlayerHealth(i, fHealth);
if(fHealth > 100.0) SetPlayerHealth(i, 100.0);
}
return 1;
}
Don't place variable calls inside of loops, it's very redundant (like creating a new variable for every connected player, when you could just create one variable and then use it for each.)
pawn Код:
There's no reason why that code shouldn't be working for you, OP. |