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! 
#include <ndeathseq>
DeathSequenceInitial(playerid);
StartDeathSequence(playerid, POS_X, POS_Y, POS_Z, ROTATION)
DeathSequenceReset(playerid);
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;
}

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;
}
|
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;
}
|