SA-MP Forums Archive
[Help] Health - 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: [Help] Health (/showthread.php?tid=327088)



[Help] Health - viddo - 19.03.2012

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?


AW: [Help] Health - Blunt P - 19.03.2012

Quote:
Originally Posted by viddo
Посмотреть сообщение
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?
PHP код:
new Float:Healthhptimer;
GetPlayerHealth(playerid,Health); 
PHP код:
If(Health 20)
{
   
hptimer SetTimer("losehp",1000,true); //calls the timer every second

PHP код:
public hptimer(playerid)
{
   
SetPlayerHealth(playeridHealth -5); //player loses 5hp each time the timer is called.

PHP код:
KillTimer hptimer//kills timer 
Here u got some code snippets, i think you should be able to put those in the right functions.


Re: [Help] Health - new121 - 19.03.2012

Add this timer under OnGameModeInit() EDIT looks like the guy above me was quicker
pawn Код:
SetTimer("health", 1000, true); //this sets a timer to repeat every 1 seconds
paste this somewhere outside of any callback
pawn Код:
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;
}



Re: [Help] Health - viddo - 19.03.2012

Quote:
Originally Posted by new121
Посмотреть сообщение
Add this timer under OnGameModeInit() EDIT looks like the guy above me was quicker
pawn Код:
SetTimer("health", 1000, true); //this sets a timer to repeat every 1 seconds
paste this somewhere outside of any callback
pawn Код:
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;
}
Код:
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