Код:
stock PutPlayer(playerid, Float:x, Float:y, Float:z)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
SetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
}
else
{
SetPlayerPos(playerid, x, y ,z);
}
}
stock SetInterior(playerid, int)
{
PlayerInfo[playerid][pInt] = int;
return SetPlayerInterior(playerid, int);
}
stock SetWorld(playerid, world)
{
PlayerInfo[playerid][pVW] = world;
return SetPlayerVirtualWorld(playerid, world);
}
stock GetInterior(playerid)
{
return PlayerInfo[playerid][pInt];
}
forward FreezePlayer(playerid);
public FreezePlayer(playerid)
{
SetIntVar(playerid, "isFrozen", 1);
TogglePlayerControllable(playerid, false);
return 1;
}
stock OnPlayAnim(playerid,animlib[],animname[], Float:Speed, looping, lockx, locky, lockz, lp)
{
if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
{
if(PlayerIsWounded(playerid) || PlayerInCar(playerid)) return 1;
OnAnim{playerid} = true;
ApplyAnimation(playerid, animlib, animname, Speed, looping, lockx, locky, lockz, lp, 1);
return 1;
}
return 0;
}
forward DeadAnim(playerid);
public DeadAnim(playerid)
{
OnAnim{playerid} = true;
ApplyAnimation(playerid,"PARACHUTE","FALL_skyDive_DIE",3.5,0,0,0,1,0);
return 1;
}
stock DoDamage(targetid, bodypart, weaponid)
{
static bodyparttext[16],DamageType,Float:IncreasedDamage,Float:health,Float:armour;
GetPlayerHealth(targetid, health);
GetPlayerArmour(targetid, armour);
switch(bodypart) {
case 1: bodyparttext = "BODY_PART_HEAD",DamageType = 1;
case 2: bodyparttext = "BODY_PART_TORSO",DamageType = 2;
case 3: bodyparttext = "BODY_PART_LEGS",DamageType = 3; }
switch(weaponid) {
case 23: IncreasedDamage = SDPistolDMG; // SD Pistol
case 24: IncreasedDamage = DeagleDMG; // Desert Eagle
case 25: IncreasedDamage = ShotgunDMG; // Shotgun
case 28: IncreasedDamage = UziDMG; // UZI
case 29: IncreasedDamage = MP5DMG; // UZI
case 30: IncreasedDamage = AK47DMG; // AK47
case 31: IncreasedDamage = M4A1DMG; // M4A1
case 32: IncreasedDamage = Tec9DMG; // Tec9
case 33: IncreasedDamage = CountryRifleDMG; // Country Rifle
case 34: IncreasedDamage = SniperRifleDMG; // Country Rifle
}
if(armour > 10)
{
if(DamageType == 2) { IncreasedDamage += 10.0; }
else if(DamageType == 3) { IncreasedDamage += 10.0; }
}
if(DamageType == 1) {
PlayerInfo[targetid][pArmor] = 0.0;
//PlayerInfo[targetid][pHasArmour] = 0;
SetPlayerArmour(targetid, 0.0);
}
else if(DamageType == 2 || DamageType == 3)
{
if(DamageType == 2) { IncreasedDamage += 10.0; }
else if(DamageType == 3) { IncreasedDamage += 10.0; }
SetPlayerHealth(targetid, health-IncreasedDamage);
}
if(DamageType == 1) { SetPlayerHealth(targetid, 0.0); }
if(health-IncreasedDamage == 0 || health-IncreasedDamage < 0) { MakePlayerWounded(targetid); }
return 1;
}
stock MakePlayerWounded(playerid)
{
if(PlayerInfo[playerid][pJailed] == 0)
{
SetIntVar(playerid, "JustDied", 1);
SavePlayerPos(playerid);
}
return 1;
}
stock Float:PlayerPosX(playerid)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y ,z);
return x;
}
stock Float:PlayerPosY(playerid)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y ,z);
return y;
}
stock Float:PlayerPosZ(playerid)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y ,z);
return z;
}
stock SavePlayerPos(playerid)
{
new Float:a;
GetPlayerFacingAngle(playerid, a);
PlayerInfo[playerid][pPos_x] = PlayerPosX(playerid);
PlayerInfo[playerid][pPos_y] = PlayerPosY(playerid);
PlayerInfo[playerid][pPos_z] = PlayerPosZ(playerid);
PlayerInfo[playerid][pPos_r] = a;
PlayerInfo[playerid][pVW] = GetWorld(playerid);
PlayerInfo[playerid][pInt] = GetInterior(playerid);
return 1;
}
forward CheckWounded(playerid);
public CheckWounded(playerid)
{
if(GetIntVar(playerid, "JustDied") == 1)
{
PutPlayer(playerid,PlayerInfo[playerid][pPos_x],PlayerInfo[playerid][pPos_y],PlayerInfo[playerid][pPos_z]);
SetInterior(playerid, PlayerInfo[playerid][pInt]);
SetWorld(playerid, PlayerInfo[playerid][pVW]);
SetPlayerCameraPos(playerid,PlayerInfo[playerid][pPos_x]+3,PlayerInfo[playerid][pPos_y]+3,PlayerInfo[playerid][pPos_z]+3);
SetPlayerCameraLookAt(playerid,PlayerInfo[playerid][pPos_x],PlayerInfo[playerid][pPos_y],PlayerInfo[playerid][pPos_z]);
SetPlayerHealth(playerid, 1000.0);
GivePlayerCash(playerid, -300);
SendClientMessageEx(playerid, COLOR_GREY, "You've lost $300 when you died.");
SendClientMessageEx(playerid, COLOR_YELLOW, "You are brutally wounded, you may wait for a medic or '/acceptdeath'.");
FreezePlayer(playerid);
OnAnim{playerid} = true;
ApplyAnimation(playerid,"PARACHUTE","FALL_skyDive_DIE",3.5,0,0,0,1,0);
}
}
stock PlayerIsWounded(playerid)
{
if(GetIntVar(playerid, "JustAcceptedDeath") == 1 || GetIntVar(playerid, "JustDied") == 1 || PlayerInfo[playerid][pDied] == 1 || GetIntVar(playerid, "LoggedInDead") == 1)
{
return true;
}
else
{
return false;
}
}
stock PlayerInCar(playerid)
{
if(IsPlayerInAnyVehicle(playerid))
return true;
else
return false;
}
stock StopPlayerAnims(playerid)
{
if(PlayerIsWounded(playerid) || PlayerInCar(playerid)) return 1;
OnAnim{playerid} = false;
ClearAnimations(playerid, 1);
return 1;
}
stock GetWeaponHolding(playerid)
{
new wepid = GetPlayerWeapon(playerid);
if(wepid > 0 && Weapons[playerid][wepid] == 1)
return wepid;
else
return 0;
}
//under OnPlayerGiveDamage
new weapon = GetWeaponHolding(playerid);
if(weapon == 24 || weapon == 30 || weapon == 31 || weapon == 34 || weapon == 25 || weapon == 29 || weapon == 28 || weapon == 32 || weapon == 33 || weapon == 34)
{
if(GetWorld(playerid) == GetWorld(damagedid))
{
if(IsPlayerAimingTargetBodyPart(playerid, damagedid, 1)) // BODY_PART_HEAD
{ DoDamage(damagedid, 1, GetPlayerWeapon(playerid)); }
else if(IsPlayerAimingTargetBodyPart(playerid, damagedid, 2)) // BODY_PART_TORSO
{ DoDamage(damagedid, 2, GetPlayerWeapon(playerid)); }
else if(IsPlayerAimingTargetBodyPart(playerid, damagedid, 3)) // BODY_PART_LEGS
{ DoDamage(damagedid, 3, GetPlayerWeapon(playerid)); }
}
}
//OnPlayerDeath
if(!isAdminDuty(playerid))
{
MakePlayerWounded(playerid);
}
//OnPlayerSpawn
SetTimerEx("CheckWounded", 500, 0, "i", playerid);
//OnPlayerTakeDamage
if(PlayerIsWounded(playerid))
{
SetPlayerHealth(playerid, 1000.0);
}
CMD:acceptdeath(playerid, params[])
{
if(GetIntVar(playerid, "JustDied") == 1 || PlayerInfo[playerid][pDied] == 1)
{
StopPlayerAnims(playerid);
SetIntVar(playerid, "JustAcceptedDeath", 1);
RemoveVar(playerid, "JustDied");
RemoveVar(playerid, "LoggedInDead");
HospitalWait{playerid} = 30;
PlayerInfo[playerid][pDied] = 0;
FreezePlayer(playerid);
PutPlayer(playerid, 256.1596, -229.7117, 1.5302);
SetPlayerCameraPos(playerid, 285.8740, -186.8099, 19.5288);
SetPlayerCameraLookAt(playerid, 263.4915, -229.9948, 3.9282);
SendClientMessageEx(playerid, COLOR_LIGHTRED, "[Hospital] Your medical bill is $500.");
SendClientMessageEx(playerid, COLOR_LIGHTRED, "Please wait 30 seconds before walking out of the hospital.");
GivePlayerCash(playerid, -500);
}
else
{
SendClientMessageEx(playerid, -1, "You are not wounded.");
}
return 1;
}
But the animation is just for few seconds, then i'm standing up and freezed. How can I make animation make to stay for all the time until he /acceptdeath or FD arrive?
You need to set the animation to 'looping', so it won't stop after it's done playback. All you need to do is change the '0' to a '1' for the loop parameter in ApplyAnimation.
Then, once they do /acceptdeath or the FD arrives, you can ClearAnimations or apply another 'standing up' animation.