PLayer health
#1

How can i make that if a person is low on health like 50% an animation will play like /injured and they cant move until their health is high again like 70%. ALso can someone please give a tutorial for maping?
Reply
#2

Search on ******* for the mapping thing MTA map editor etc.
Reply
#3

On the health thing, it basically goes like this :

pawn Код:
new Float:health;
GetPlayerHealth(playerid, health)
if(health => 50)
{
  // do somethings here
}
Well, I don't know the animation, sorry.
Reply
#4

new Float:health;
GetPlayerHealth(playerid, health)
if(health => 50)
{
ApplyAnimationEx(playerid,"SWAT","gnstwall_injurd" , 4.0, 1, 0, 0, 0, 0);//Anim
TogglePlayerControllable(playerid, 0);// Freeze the player
}
Reply
#5

Shouldnt freeze the player, should add a loop to the anim.
Reply
#6

And then just place it on a timer or check.
Reply
#7

Quote:
Originally Posted by Cameltoe
Посмотреть сообщение
Shouldnt freeze the player, should add a loop to the anim.
Its better to freeze the player, as it can be abused by pressing F and Jump, Trust me i've had it on my server
Reply
#8

sry but im a noob at this the
new Float:health;
GetPlayerHealth(playerid, health)
if(health => 50)
{
ApplyAnimationEx(playerid,"SWAT","gnstwall_injurd" , 4.0, 1, 0, 0, 0, 0);//Anim
TogglePlayerControllable(playerid, 0);// Freeze the player
}



should i add it at in my GM at the end? and like this?




{
new Float:health;
GetPlayerHealth(playerid, health)
if(health => 50)
{
ApplyAnimationEx(playerid,"SWAT","gnstwall_injurd" , 4.0, 1, 0, 0, 0, 0);//Anim
TogglePlayerControllable(playerid, 0);// Freeze the player
}
Reply
#9

no, what you can do is create a timer OnGameModeInit. something like this:

pawn Код:
public OnGameModeInit()
{
    //your OnGameModeInitCode
    SetTimer("HealthCheck", 1000, 1);
    return 1;
}

forward HealthCheck();
public HealthCheck()
{
    for(new i=0; i<MAX_PLAYERS; i++){
        if(IsPlayerConnected(i)){
            new Float:Health;
            GetPlayerHealth(i, Health);
            if(Health < 50){
                ApplyAnimationEx(playerid,"SWAT","gnstwall_injurd" , 4.0, 1, 0, 0, 0, 0);//Anim
                TogglePlayerControllable(playerid, 0);// Freeze the player
                SetPlayerHealth(i, Health + 1);//Optional for increace player's life, and unfreeze it
            }
            else{
                ClearAnimations(i);
                TogglePlayerControllable(playerid, 1);
            }
        }
    }
}
Reply
#10

i get this

D:\san andreas SERVER\gamemodes\larp.pwn(81127) : error 021: symbol already defined: "Streamer_OnGameModeInit"
D:\san andreas SERVER\gamemodes\larp.pwn(81141) : error 017: undefined symbol "ApplyAnimationEx"
D:\san andreas SERVER\gamemodes\larp.pwn(81142) : error 017: undefined symbol "playerid"
D:\san andreas SERVER\gamemodes\larp.pwn(81147) : error 017: undefined symbol "playerid"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#11

First look at the lines which say undefined symbol "playerid"

Go to them and replace playerid with i.
Then With ApplyAnimationEx remove Ex off ApplyAnimation.
And Remove the Streamer_OnGamemodeInit Function.
Its already been defined in the script.
Reply
#12

here, my fault:
pawn Код:
public OnFilterScriptInit()
{
    //your OnGameModeInitCode
    SetTimer("HealthCheck", 1000, 1);
    return 1;
}

forward HealthCheck();
public HealthCheck()
{
    for(new i=0; i<MAX_PLAYERS; i++){
        if(IsPlayerConnected(i)){
            new Float:Health;
            GetPlayerHealth(i, Health);
            if(Health < 50){
                ApplyAnimation(i,"SWAT","gnstwall_injurd" , 4.0, 1, 0, 0, 0, 0);//Anim
                TogglePlayerControllable(i, 0);// Freeze the player
                SetPlayerHealth(i, Health + 1);//Optional for increace player's life, and unfreeze it
            }
            else{
                ClearAnimations(i);
                TogglePlayerControllable(i, 1);
            }
        }
    }
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)