19.03.2012, 20:50
Hello, How can i make it that if the player's hp is on a certain point it starts to automatically loses by 5 pts or something?
Hello, How can i make it that if the player's hp is on a certain point it starts to automatically loses by 5 pts or something?
|
new Float:Health, hptimer;
GetPlayerHealth(playerid,Health);
If(Health < 20)
{
hptimer = SetTimer("losehp",1000,true); //calls the timer every second
}
public hptimer(playerid)
{
SetPlayerHealth(playerid, Health -5); //player loses 5hp each time the timer is called.
}
KillTimer hptimer; //kills timer
SetTimer("health", 1000, true); //this sets a timer to repeat every 1 seconds
forward health();
public health()
{
for(new i =0; i<MAX_PLAYERS; i++)
{
new Float:h = GetPlayerHealth(i);
if(health =< 20)
{
SetPlayerHealth(i, health-5);
}
}
return 1;
}
Add this timer under OnGameModeInit() EDIT looks like the guy above me was quicker
pawn Код:
pawn Код:
|
C:\Users\Viddo\Desktop\LARP 4.0\LARP 4.0 D\gamemodes\larp.pwn(3794) : warning 219: local variable "health" shadows a variable at a preceding level C:\Users\Viddo\Desktop\LARP 4.0\LARP 4.0 D\gamemodes\larp.pwn(6416) : warning 202: number of arguments does not match definition C:\Users\Viddo\Desktop\LARP 4.0\LARP 4.0 D\gamemodes\larp.pwn(6417) : error 076: syntax error in the expression, or invalid function call C:\Users\Viddo\Desktop\LARP 4.0\LARP 4.0 D\gamemodes\larp.pwn(6417) : error 029: invalid expression, assumed zero C:\Users\Viddo\Desktop\LARP 4.0\LARP 4.0 D\gamemodes\larp.pwn(6417) : warning 215: expression has no effect C:\Users\Viddo\Desktop\LARP 4.0\LARP 4.0 D\gamemodes\larp.pwn(6417) : error 001: expected token: ";", but found ")" C:\Users\Viddo\Desktop\LARP 4.0\LARP 4.0 D\gamemodes\larp.pwn(6417) : fatal error 107: too many error messages on one line