//under defines new gPlayerUsingLoopingAnim[MAX_PLAYERS]; LoopingAnim(playerid,animlib[],animname[], Float:Speed, looping, lockx, locky, lockz, lp) { gPlayerUsingLoopingAnim[playerid] = 1; ApplyAnimation(playerid, animlib, animname, Speed, looping, lockx, locky, lockz, lp); } // public onplayerupdate(playerid); // i'd recommand to use a timer for this, go see my tutorial on speedo with timer, it will get you started with timers { new Float:health; GetPlayerHealth(playerid,health); if (health < 25.0) { new string[256]; LoopingAnim(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0); // nice anim for this, but change it if you like (sweet_injured is nice too). format(string, sizeof(string), "~p~ You need Help!"); // color is purple GameTextForPlayer(playerid, string, 3000, 5); // 3000 is 3 second and 5 is the writiing style TogglePlayerControllable(playerid, false); return 1; } return 1; } public OnPlayerDeath(playerid, killerid, reason) { if(gPlayerUsingLoopingAnim[playerid]) { gPlayerUsingLoopingAnim[playerid] = 0; // reset player, if killed while needing help TogglePlayerControllable(playerid, True); //makes the player controllable , if killed during anim } return 1; }
//under defines
new gPlayerUsingLoopingAnim[MAX_PLAYERS];
LoopingAnim(playerid,animlib[],animname[], Float:Speed, looping, lockx, locky, lockz, lp)
{
gPlayerUsingLoopingAnim[playerid] = 1;
ApplyAnimation(playerid, animlib, animname, Speed, looping, lockx, locky, lockz, lp);
}
//
public onplayerupdate(playerid); // i'd recommand to use a timer for this, go see my tutorial on speedo with timer, it will get you started with timers
{
new Float:health;
GetPlayerHealth(playerid,health);
if (health < 25.0)
{
new string[256];
LoopingAnim(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0); // nice anim for this, but change it if you like (sweet_injured is nice too).
format(string, sizeof(string), "~p~ You need Help!"); // color is purple
GameTextForPlayer(playerid, string, 3000, 5); // 3000 is 3 second and 5 is the writiing style
TogglePlayerControllable(playerid, false);
LoopingAnim(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0); //
return 1;
}
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if(gPlayerUsingLoopingAnim[playerid]) {
gPlayerUsingLoopingAnim[playerid] = 0; // reset player, if killed while needing help
TogglePlayerControllable(playerid, True); //makes the player controllable , if killed during anim
}
return 1;
}
// On top of your screen
new injuretimer, Injured[MAX_PLAYERS];
forward InjuredT(playerid);
public OnPlayerUpdate(playerid)
{
new Float:health;
GetPlayerHealth(playerid, health);
if (health < 25.0)
{
new string[50];
LoopingAnim(playerid, "SWEET", "Sweet_injuredloop", 4.0, 1, 0, 0, 0, 0);
format(string, sizeof(string), "~r~You need help!");
GameTextForPlayer(playerid, string, 3000, 5);
TogglePlayerControllable(playerid, false); // disallows him to metagame ^^
SetCameraBehindPlayer(playerid); // turns the camera back for a better view
injuretimer = SetTimerEx("InjuredT", 3000, true, "d", playerid); // starts a timer, every 3 seconds you lose 1 hp
Injured[playerid] = 1;
}
else KillTimer(injuretimer), Injured[playerid] = 0; // this is for safety so it won't bug
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if(gPlayerUsingLoopingAnim[playerid])
{
gPlayerUsingLoopingAnim[playerid] = 0;
TogglePlayerControllable(playerid, true);
}
if(Injured[playerid] == 1)
{
KillTimer(injuretimer);
Injured[playerid] = 0;
}
return 1;
}
public InjuredT(playerid)
{
new Float:health;
GetPlayerHealth(playerid, health);
SetPlayerHealth(playerid, health-1);
return 1;
}
edit: It works as i planned, only problem some people say it doesnt make them into crack, but on other peoples screen they are. also when they get healed they dont get unfrozen and standing up, im guessing this is where timer comes in? |