SA-MP Forums Archive
Walking Style when you under 25HP - 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: Walking Style when you under 25HP (/showthread.php?tid=385980)



Walking Style when you under 25HP - RenSoprano - 18.10.2012

I think to add a system where when you under 25HP to change your walking style to Old Man but I need somebody who can show me an example with SetPVarInt

Do you think this will work well?

PHP код:
    if(GetPlayerHealth(playerid) < 25.0 && GetPVarInt(playerid"Under25HP") == 0)
    {
        
ApplyAnimation(playerid,"PED","WALK_DRUNK",4.1,1,1,1,1,1,1);
        
SetPVarInt(playerid"Under25HP"1);
    }
    else if(
GetPVarInt(playerid"Under25HP") == && GetPlayerHealth(playerid) > 25.0)
    {
        
ClearAnimations(playerid);
        
SetPVarInt(playerid"Under25HP"0);
    } 



Re: Walking Style when you under 25HP - niels44 - 18.10.2012

ye if you place this under onplayerupdtate then itll work i think


Re: Walking Style when you under 25HP - CmZxC - 18.10.2012

Quote:
Originally Posted by niels44
Посмотреть сообщение
ye if you place this under onplayerupdtate then itll work i think
god hell no, he will look glitchy and stuff, do you know how many times OnPlayerUpdate is called each second?


Re: Walking Style when you under 25HP - RenSoprano - 19.10.2012

Can you give me an example how it must be?


Re: Walking Style when you under 25HP - XRabbit - 19.10.2012

Mm...i scripting on pawn about 3 years ago, but try something like this

PHP код:
new boolWalkDrunk[MAX_PLAYERS];
public 
OnPlayerUpdate (playerid) {
    new 
playerState GetPlayerState(playerid), FloatplayerHealth;
    
GetPlayerHealth (playeridplayerHealth);
    if (
playerState == PLAYER_STATE_ONFOOT) {
        if (
playerHealth <= 25 && !WalkDrunk[playerid]) {
            
WalkDrunk[playerid] = true;
            
ApplyAnimation (playerid"PED""WALK_DRUNK"4.1111111);
        } else if (
playerHealth 25 && WalkDrunk) {
            
WalkDrunk[playerid] = false;
            
ClearAnimations (playerid);
        }
    }
    return 
1;

It's not a full working variant, but for example need to work with onplayerstatechange