10.04.2017, 10:46
In my opinion, making a system like this based on health blows. I would just try something with death in general. Here are examples from my working script:
You don't have to add TogglePlayerControllable on spawn while dead because having this under OnPlayerUpdate will just repeat the anim and they can't get up but still move their camera.
Just my opinion & a base for you to start if you'd like.
Код:
enum PlayerStatistics { IsDead, Dead, }
Код:
public OnPlayerDeath(playerid, killerid, reason) { new Float:x, Float:y, Float:z; GetPlayerPos(playerid, x, y, z); Player[playerid][LastWorld] = GetPlayerVirtualWorld(playerid); Player[playerid][LastInterior] = GetPlayerInterior(playerid); Player[playerid][LastX] = x; //saves players position for spawning Player[playerid][LastY] = y; Player[playerid][LastZ] = z; Player[playerid][IsDead] = 1; }
Код:
public OnPlayerSpawn(playerid) { if(Player[playerid][IsDead] == 1) { SetPlayerPos(playerid, Player[playerid][LastX], Player[playerid][LastY], Player[playerid][LastZ]); SetPlayerCameraPos(playerid, Player[playerid][LastX], Player[playerid][LastY], Player[playerid][LastZ]); SetPlayerInterior(playerid, Player[playerid][LastInterior]); SetPlayerVirtualWorld(playerid, Player[playerid][LastWorld]); format(string, sizeof(string), "(( Has been brutally wounded, /damages %d for more info. ))", playerid); SetPlayerChatBubble(playerid, string, ADM, 30.0, 600000); // bunch of other shit, anims & etc } }
Код:
public OnPlayerUpdate(playerid) { if(Player[playerid][IsDead] == 1) { ApplyAnimation(playerid, // ur anim } }
Код:
public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid, bodypart) { if(Player[damagedid][IsDead] == 1) { TogglePlayerControllable(damagedid, false); Player[damagedid][IsDead] = 0; Player[damagedid][Dead] = 1; SetPlayerChatBubble(damagedid, "(( PLAYER IS DEAD ))", ADM, 30.0, 1220001); } }