Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Dying System for RE5 Fans
- //By TreePuncher or Jay_McReary
- #include <a_samp>
- #define PRESSED(%0) \
- (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
- forward DyingTime(playerid);
- new DyingTimer;
- new Text:DyingText;
- new Text3D:DyingTextWarn[MAX_PLAYERS];
- new DyingStated[MAX_PLAYERS];
- public OnFilterScriptInit()
- {
- DyingText = TextDrawCreate(312.000000, 198.000000, "You Are Dying");
- TextDrawAlignment(DyingText, 2);
- TextDrawBackgroundColor(DyingText, 255);
- TextDrawFont(DyingText, 0);
- TextDrawLetterSize(DyingText, 0.879998, 3.699997);
- TextDrawColor(DyingText, -16776961);
- TextDrawSetOutline(DyingText, 1);
- TextDrawSetProportional(DyingText, 1);
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- new Float:Health;
- GetPlayerHealth(playerid, Health);
- if(Health <= 15)
- {
- if(!GetPVarInt(playerid, "DyingVar"))
- {
- DyingStated[playerid] = 1;
- DyingTimer = SetTimer("DyingTime", 5000, true);
- TextDrawShowForPlayer(playerid, DyingText);
- SetPVarInt(playerid, "DyingVar", true);
- DyingTextWarn[playerid] = Create3DTextLabel("DYING!!", 0xFF0002AA, 0, 0, 0, 0, 0, 0);
- Attach3DTextLabelToPlayer(DyingTextWarn[playerid], playerid, 0, 0, 2);
- SendClientMessage(playerid, 0xFF0402AA, "You are dying, repeatedly press FIRE BUTTON in order to survive!");
- ApplyAnimation(playerid, "KNIFE", "KILL_Knife_Ped_Die", 2, 0, 1, 1, 1, 0, 1);
- return 1;
- }
- }
- else
- {
- if(GetPVarInt(playerid, "DyingVar"))
- {
- KillTimer(DyingTimer);
- TextDrawHideForPlayer(playerid, DyingText);
- DeletePVar(playerid, "DyingVar");
- DyingStated[playerid] = 0;
- Delete3DTextLabel(DyingTextWarn[playerid]);
- ClearAnimations(playerid);
- return 1;
- }
- }
- return 0;
- }
- public DyingTime(playerid)
- {
- new Float:ChangeHealth, Float:x, Float:y, Float:z;
- GetPlayerHealth(playerid, ChangeHealth);
- SetPlayerHealth(playerid, ChangeHealth-1);
- GetPlayerPos(playerid, x, y, z);
- PlayerPlaySound(playerid, 1002, x, y, z);
- DyingStated[playerid] = 1;
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- if(DyingStated[playerid] == 1)
- {
- new dpName[MAX_PLAYER_NAME], dpstr[128];
- GetPlayerName(playerid, dpName, sizeof(dpName));
- format(dpstr, sizeof(dpstr), "%s [%i] has died while on dying status", dpName, playerid);
- SendClientMessageToAll(0x0000FFAA, dpstr);
- print(dpstr);
- KillTimer(DyingTimer);
- DyingStated[playerid] = 0;
- Delete3DTextLabel(DyingTextWarn[playerid]);
- ClearAnimations(playerid);
- return 1;
- }
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(DyingStated[playerid] == 1)
- {
- if(PRESSED(KEY_FIRE))
- {
- new Float:RecoverHealth;
- GetPlayerHealth(playerid, RecoverHealth);
- SetPlayerHealth(playerid, RecoverHealth+1);
- return 1;
- }
- return 1;
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- Delete3DTextLabel(DyingTextWarn[playerid]);
- ClearAnimations(playerid);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement