SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 27/04/2018, 08:47 PM   #1
Nickk888
Little Clucker
 
Nickk888's Avatar
 
Join Date: Oct 2011
Location: Germany
Posts: 20
Reputation: 24
Cool [N]Death Sequence - GTA 5 Style Death sequence!

Hi guys! I thought myself "How about you make a small include that creates a simmilar effect to the GTA 5 death sequence". So i did! It's obviously not 100% like GTA 5, i combined the Death Style sequence with the character switching sequence from GTA 5. It's just a fun project, nothing big really but it looks so cool!

Video: https://*********/q1Bx112xPAI

Note: This Video shows a very strong camera shake which i lowered within the include, you can also disable/enable it if you want(Default: Disabled).

Note2: Video contains sound samples from the GTA 5 Game which is not included with the include! I added the sounds within the Video editor for entertaining purpose only! You will hear no sound what so ever.

Download:
https://pastebin.com/KzBAV1v2

Installation:
Write on top your Gamemode this:
Code:
#include <ndeathseq>
Now inside the callback OnPlayerDeath, add this function(Ideally at the end):
Code:
DeathSequenceInitial(playerid);
Now in OnPlayerSpawn you should make a new condition in which we put this function:
Code:
StartDeathSequence(playerid, POS_X, POS_Y, POS_Z, ROTATION)
Inside this function we put in the position where the player will spawn together with the rotation.

Now, inside the brackets we put the further code of the normal spawn of the player by Gamemode.

Explanation: StartDeathSequence returns false if the player has died and we want to enable the death sequence, from the fact that the condition is false,
the usual code will not be executed, only after completing the sequence the condition will be true because it has finished the sequence and we execute the normal spawn code.

Now inside the OnPlayerDisconnect callback we simply put this function:
Code:
DeathSequenceReset(playerid);
It's supposed to look something like this:
Code:
public OnPlayerDeath(playerid, killerid, reason)
{
	DeathSequenceInitial(playerid);
	return 1;
}

public OnPlayerSpawn(playerid)
{
	//HERE WE DO NOT GIVE ANYTHING! EVERYTHING WE PUT INSIDE THE BRACKETS OF THE FOLLOWING CONDITION!
	if(StartDeathSequence(playerid, 1064.3226,-1790.8276,13.6593, 149.5278)) //Player spawn, the same coordinates as below
	{
		//REST OF YOUR CODE!
		SetPlayerPos(playerid, 1064.3226,-1790.8276,13.6593); //Player Spawn
		SetPlayerFacingAngle(playerid, 149.5278);
		SetCameraBehindPlayer(playerid);
	}
	//HERE WE DO NOT GIVE ANYTHING! EVERYTHING, EVERYTHING WE PUT INSIDE THE BRACKETS OF THE ABOVE CONDITION!
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	DeathSequenceReset(playerid);
	return 1;
}
End Note:
I have not tested it within my RP Server! I don't know how it will work within a bigger Gamemode, i have tested it on my Test server which contains only a few lines of code... It's a fun project, i made it in about 15 minutes or so.

Well... ENJOY!

Last edited by Nickk888; 22/05/2018 at 10:26 PM.
Nickk888 is offline   Reply With Quote
Old 17/05/2018, 01:53 PM   #2
Dancsika
Little Clucker
 
Dancsika's Avatar
 
Join Date: Feb 2015
Posts: 14
Reputation: 0
Default Re: [N]Death Sequence - GTA 5 Style Death sequence!

Damn bro. That looks really nice. But it would be better if you would put a transparent black box in it.
+Rep
Dancsika is offline   Reply With Quote
Old 17/05/2018, 05:16 PM   #3
Pottus
Godfather
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 5,420
Reputation: 1240
Default Re: [N]Death Sequence - GTA 5 Style Death sequence!

It's a good idea but you should really hook OnPlayerDisconnect() and do your clean up work automatically.

A definite problem area is in this function.

Code:
stock DeathSequenceInitial(playerid)
{
    DeathSeq[playerid][isdead] = true;
    DeathSeq[playerid][skinid] = GetPlayerSkin(playerid);
    GetPlayerPos(playerid, DeathSeq[playerid][deadpos][0], DeathSeq[playerid][deadpos][1], DeathSeq[playerid][deadpos][2]);
    GetPlayerFacingAngle(playerid, DeathSeq[playerid][deadpos][3]);

// Potential problem here - How do you know this function is not called again before the player actually spawns? 
// Don't use this function without actually spawning the player immediately afterwards as a rule of thumb
// Especially in an include
    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 );

    TogglePlayerSpectating(playerid, true);
    TogglePlayerSpectating(playerid, false);

    // Might cause problems with AC's / Auto health reset etc
    SetPlayerHealth(playerid, 9999);
    return 1;
}
Pottus is offline   Reply With Quote
Old 17/05/2018, 07:49 PM   #4
dani18
Big Clucker
 
dani18's Avatar
 
Join Date: Dec 2017
Posts: 115
Reputation: 14
Default Re: [N]Death Sequence - GTA 5 Style Death sequence!

Awesome work.
What sound did you use when you change the camera?
__________________
RIP X
dani18 is offline   Reply With Quote
Old 18/05/2018, 08:48 AM   #5
RogueDrifter
High-roller
 
RogueDrifter's Avatar
 
Join Date: Dec 2017
Location: SA-MP Drifting world.
Posts: 1,148
Reputation: 345
Default Re: [N]Death Sequence - GTA 5 Style Death sequence!

Quote:
Originally Posted by Pottus View Post
It's a good idea but you should really hook OnPlayerDisconnect() and do your clean up work automatically.

A definite problem area is in this function.

Code:
stock DeathSequenceInitial(playerid)
{
    DeathSeq[playerid][isdead] = true;
    DeathSeq[playerid][skinid] = GetPlayerSkin(playerid);
    GetPlayerPos(playerid, DeathSeq[playerid][deadpos][0], DeathSeq[playerid][deadpos][1], DeathSeq[playerid][deadpos][2]);
    GetPlayerFacingAngle(playerid, DeathSeq[playerid][deadpos][3]);

// Potential problem here - How do you know this function is not called again before the player actually spawns? 
// Don't use this function without actually spawning the player immediately afterwards as a rule of thumb
// Especially in an include
    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 );

    TogglePlayerSpectating(playerid, true);
    TogglePlayerSpectating(playerid, false);

    // Might cause problems with AC's / Auto health reset etc
    SetPlayerHealth(playerid, 9999);
    return 1;
}
I second this,

Also it would've been better if the variable's names weren't as traditional as always, i can imagine having tons of players with a variable called skinid and whatnot, but i love it, it's a very cool concept and just needs a littttle more work over it, would've been perfect, over all you already got my rep hope to see you updating this with a final version.
__________________

[Github]:Link [Gists]:Link [Forum]:Link [Server]:Link [Discord]:Link


RogueDrifter is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Repeating sequence formation. ProRakNet Scripting Help 2 18/05/2016 05:22 PM
How find the missing number in a sequence. (mysql) aoEXE Scripting Help 3 05/02/2016 10:45 AM
Mode Changes Automatically in Sequence SpikY_ Scripting Help 10 04/08/2015 07:07 PM
Detecting sequence of numbers Skiaffo Scripting Help 3 11/03/2012 08:26 PM
sequence Dozer Help Archive 0 28/06/2009 05:03 AM


All times are GMT. The time now is 06:45 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.