[Include] [N]Death Sequence - GTA 5 Style Death sequence!
#1

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:
Код:
#include <ndeathseq>
Now inside the callback OnPlayerDeath, add this function(Ideally at the end):
Код:
DeathSequenceInitial(playerid);
Now in OnPlayerSpawn you should make a new condition in which we put this function:
Код:
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:
Код:
DeathSequenceReset(playerid);
It's supposed to look something like this:
Код:
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!
Reply
#2

Damn bro. That looks really nice. But it would be better if you would put a transparent black box in it.
+Rep
Reply
#3

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.

Код:
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;
}
Reply
#4

Awesome work.
What sound did you use when you change the camera?
Reply
#5

Quote:
Originally Posted by Pottus
Посмотреть сообщение
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.

Код:
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)