SHARE
TWEET

[N]Death Sequence - SAMP

a guest Apr 27th, 2018 172 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Copyright by Nickk888/Nickk888SAMP!
  2. //27.04.2018
  3.  
  4. #if !defined CAMERASHAKE
  5.     #define CAMERASHAKE false
  6. #endif
  7.  
  8. enum PlayerDeathData
  9. {
  10.     bool:isdead,
  11.     bool:isactive,
  12.     Float:deadpos[4],
  13.     Float:spawnpos[4],
  14.     skinid,
  15.     seqtimer
  16. };
  17. new DeathSeq[MAX_PLAYERS][PlayerDeathData];
  18.  
  19. forward bool:StartDeathSequence(playerid, Float:posx, Float:posy, Float:posz, Float:rot);
  20. stock bool:StartDeathSequence(playerid, Float:posx, Float:posy, Float:posz, Float:rot)
  21. {
  22.     if(DeathSeq[playerid][isactive])
  23.     {
  24.         DeathSeq[playerid][isactive] = false;
  25.         KillTimer(DeathSeq[playerid][seqtimer]);
  26.         #if CAMERASHAKE true
  27.             SetPlayerDrunkLevel(playerid, 0);
  28.         #endif
  29.         SetPlayerHealth(playerid, 100);
  30.     }
  31.     if(DeathSeq[playerid][isdead])
  32.     {
  33.         DeathSeq[playerid][isdead] = false;
  34.         DeathSeq[playerid][isactive] = true;
  35.         DeathSeq[playerid][spawnpos][0] = posx;
  36.         DeathSeq[playerid][spawnpos][1] = posy;
  37.         DeathSeq[playerid][spawnpos][2] = posz;
  38.         DeathSeq[playerid][spawnpos][3] = rot;
  39.         SetPlayerPos(playerid, DeathSeq[playerid][deadpos][0], DeathSeq[playerid][deadpos][1], DeathSeq[playerid][deadpos][2]);
  40.         SetPlayerFacingAngle(playerid, DeathSeq[playerid][deadpos][3]);
  41.         SetPlayerSkin(playerid, DeathSeq[playerid][skinid]);
  42.         ApplyAnimation(playerid,"PED","KO_skid_back",4.1,0,1,1,1,0,1);
  43.         SetPlayerCameraPos(playerid, DeathSeq[playerid][deadpos][0], DeathSeq[playerid][deadpos][1], DeathSeq[playerid][deadpos][2] + 5);
  44.         SetPlayerCameraLookAt(playerid, DeathSeq[playerid][deadpos][0], DeathSeq[playerid][deadpos][1], DeathSeq[playerid][deadpos][2]);
  45.         #if CAMERASHAKE true
  46.             SetPlayerDrunkLevel(playerid, 6000);
  47.         #endif
  48.         DeathSeq[playerid][seqtimer] = SetTimerEx("PlayerDeathSeq", 2000, false, "ii", playerid, 0);
  49.         return false;
  50.     }
  51.     return true;
  52. }
  53.  
  54. stock DeathSequenceReset(playerid)
  55. {
  56.     if(DeathSeq[playerid][isactive])
  57.     {
  58.         DeathSeq[playerid][isactive] = false;
  59.         DeathSeq[playerid][isdead] = false;
  60.         KillTimer(DeathSeq[playerid][seqtimer]);
  61.     }
  62.     return 1;
  63. }
  64.  
  65. stock DeathSequenceInitial(playerid)
  66. {
  67.     DeathSeq[playerid][isdead] = true;
  68.     DeathSeq[playerid][skinid] = GetPlayerSkin(playerid);
  69.     GetPlayerPos(playerid, DeathSeq[playerid][deadpos][0], DeathSeq[playerid][deadpos][1], DeathSeq[playerid][deadpos][2]);
  70.     GetPlayerFacingAngle(playerid, DeathSeq[playerid][deadpos][3]);
  71.     SetSpawnInfo(playerid, NO_TEAM, DeathSeq[playerid][skinid], DeathSeq[playerid][deadpos][0], DeathSeq[playerid][deadpos][1], DeathSeq[playerid][deadpos][2], DeathSeq[playerid][deadpos][3], 0, 0, 0, 0, 0, 0 );
  72.     TogglePlayerSpectating(playerid, true);
  73.     TogglePlayerSpectating(playerid, false);
  74.     SetPlayerHealth(playerid, 9999);
  75.     return 1;
  76. }
  77.  
  78. forward PlayerDeathSeq(playerid, seqid);
  79. public PlayerDeathSeq(playerid, seqid)
  80. {
  81.     #if CAMERASHAKE true
  82.         SetPlayerDrunkLevel(playerid, 6000);
  83.     #endif
  84.     switch(seqid)
  85.     {
  86.         case 0:
  87.         {
  88.             SetPlayerCameraPos(playerid, DeathSeq[playerid][deadpos][0], DeathSeq[playerid][deadpos][1], DeathSeq[playerid][deadpos][2] + 25);
  89.             SetPlayerCameraLookAt(playerid, DeathSeq[playerid][deadpos][0], DeathSeq[playerid][deadpos][1], DeathSeq[playerid][deadpos][2]);
  90.             GameTextForPlayer(playerid, "~r~WASTED", 2000, 0);
  91.             DeathSeq[playerid][seqtimer] = SetTimerEx("PlayerDeathSeq", 4000, false, "ii", playerid, 1);
  92.         }
  93.         case 1:
  94.         {
  95.             SetPlayerCameraPos(playerid, DeathSeq[playerid][deadpos][0], DeathSeq[playerid][deadpos][1], DeathSeq[playerid][deadpos][2] + 80);
  96.             SetPlayerCameraLookAt(playerid, DeathSeq[playerid][deadpos][0], DeathSeq[playerid][deadpos][1], DeathSeq[playerid][deadpos][2]);
  97.             DeathSeq[playerid][seqtimer] = SetTimerEx("PlayerDeathSeq", 800, false, "ii", playerid, 2);
  98.         }
  99.         case 2:
  100.         {
  101.             SetPlayerCameraPos(playerid, DeathSeq[playerid][deadpos][0], DeathSeq[playerid][deadpos][1], DeathSeq[playerid][deadpos][2] + 150);
  102.             SetPlayerCameraLookAt(playerid, DeathSeq[playerid][deadpos][0], DeathSeq[playerid][deadpos][1], DeathSeq[playerid][deadpos][2]);
  103.             DeathSeq[playerid][seqtimer] = SetTimerEx("PlayerDeathSeq", 800, false, "ii", playerid, 3);
  104.         }
  105.         case 3:
  106.         {
  107.             SetPlayerCameraPos(playerid, DeathSeq[playerid][deadpos][0], DeathSeq[playerid][deadpos][1], DeathSeq[playerid][deadpos][2] + 500);
  108.             SetPlayerCameraLookAt(playerid, DeathSeq[playerid][deadpos][0], DeathSeq[playerid][deadpos][1], DeathSeq[playerid][deadpos][2]);
  109.             DeathSeq[playerid][seqtimer] = SetTimerEx("PlayerDeathSeq", 2000, false, "ii", playerid, 4);
  110.         }
  111.         case 4:
  112.         {
  113.             TogglePlayerControllable(playerid, false);
  114.             SetPlayerCameraPos(playerid, DeathSeq[playerid][spawnpos][0], DeathSeq[playerid][spawnpos][1], DeathSeq[playerid][spawnpos][2] + 500);
  115.             SetPlayerCameraLookAt(playerid, DeathSeq[playerid][spawnpos][0], DeathSeq[playerid][spawnpos][1], DeathSeq[playerid][spawnpos][2], CAMERA_MOVE);
  116.             SetPlayerPos(playerid, DeathSeq[playerid][spawnpos][0], DeathSeq[playerid][spawnpos][1], DeathSeq[playerid][spawnpos][2]);
  117.             SetPlayerFacingAngle(playerid, DeathSeq[playerid][spawnpos][3]);
  118.             DeathSeq[playerid][seqtimer] = SetTimerEx("PlayerDeathSeq", 6000, false, "ii", playerid, 5);
  119.         }
  120.         case 5:
  121.         {
  122.             SetPlayerPos(playerid, DeathSeq[playerid][spawnpos][0], DeathSeq[playerid][spawnpos][1], DeathSeq[playerid][spawnpos][2]);
  123.             SetPlayerFacingAngle(playerid, DeathSeq[playerid][spawnpos][3]);
  124.             SetPlayerCameraPos(playerid, DeathSeq[playerid][spawnpos][0], DeathSeq[playerid][spawnpos][1], DeathSeq[playerid][spawnpos][2] + 150);
  125.             SetPlayerCameraLookAt(playerid, DeathSeq[playerid][spawnpos][0], DeathSeq[playerid][spawnpos][1], DeathSeq[playerid][spawnpos][2]);
  126.             DeathSeq[playerid][seqtimer] = SetTimerEx("PlayerDeathSeq", 2000, false, "ii", playerid, 6);
  127.         }
  128.         case 6:
  129.         {
  130.             SetPlayerPos(playerid, DeathSeq[playerid][spawnpos][0], DeathSeq[playerid][spawnpos][1], DeathSeq[playerid][spawnpos][2]);
  131.             SetPlayerFacingAngle(playerid, DeathSeq[playerid][spawnpos][3]);
  132.             SetPlayerCameraPos(playerid, DeathSeq[playerid][spawnpos][0], DeathSeq[playerid][spawnpos][1], DeathSeq[playerid][spawnpos][2] + 50);
  133.             SetPlayerCameraLookAt(playerid, DeathSeq[playerid][spawnpos][0], DeathSeq[playerid][spawnpos][1], DeathSeq[playerid][spawnpos][2]);
  134.             DeathSeq[playerid][seqtimer] = SetTimerEx("PlayerDeathSeq", 1500, false, "ii", playerid, 7);
  135.         }
  136.         case 7:
  137.         {
  138.             SetPlayerPos(playerid, DeathSeq[playerid][spawnpos][0], DeathSeq[playerid][spawnpos][1], DeathSeq[playerid][spawnpos][2]);
  139.             SetPlayerFacingAngle(playerid, DeathSeq[playerid][spawnpos][3]);
  140.             new Float:tmppos[2];
  141.             tmppos[0] = DeathSeq[playerid][spawnpos][0];
  142.             tmppos[1] = DeathSeq[playerid][spawnpos][1];
  143.             NDS_GetXYInFrontOfPoint(tmppos[0], tmppos[1], DeathSeq[playerid][spawnpos][3] + NDS_ExRandom(-45, 45), 5);
  144.             SetPlayerCameraPos(playerid, tmppos[0], tmppos[1], DeathSeq[playerid][spawnpos][2] + 1);
  145.             SetPlayerCameraLookAt(playerid, DeathSeq[playerid][spawnpos][0], DeathSeq[playerid][spawnpos][1], DeathSeq[playerid][spawnpos][2]);
  146.             DeathSeq[playerid][seqtimer] = SetTimerEx("PlayerDeathSeq", 2000, false, "ii", playerid, 8);
  147.         }
  148.         default:
  149.         {
  150.             SpawnPlayer(playerid);
  151.             #if CAMERASHAKE true
  152.                 SetPlayerDrunkLevel(playerid, 0);
  153.             #endif
  154.             SetPlayerHealth(playerid, 100);
  155.             TogglePlayerControllable(playerid, true);
  156.             DeathSeq[playerid][isactive] = false;
  157.         }
  158.     }
  159.     return 1;
  160. }
  161.  
  162. stock NDS_ExRandom(min, max) //By y_less  
  163. {    
  164.     new rand = random(max-min)+min;    
  165.     return rand;
  166. }
  167.  
  168.  
  169. stock NDS_GetXYInFrontOfPoint(&Float:x, &Float:y, Float:angle, Float:distance)
  170. {
  171.     x += (distance * floatsin(-angle, degrees));
  172.     y += (distance * floatcos(-angle, degrees));
  173. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top