OnPlayerDeath - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: OnPlayerDeath (
/showthread.php?tid=555108)
OnPlayerDeath -
PaulDinam - 06.01.2015
Is there a way to disable that the player will respawn after he dies? I'm trying to set his position to where he died and apply an animation but the player respawns shortly after. I'm pretty sure i've seen it on a few RP servers before.
Re: OnPlayerDeath -
HY - 06.01.2015
pawn Код:
new Died[MAX_PLAYERS];
enum pInfo
{
Float:pX,
Float:pY,
Float:pZ
}
new DeathPosition[MAX_PLAYERS][pInfo];
public OnPlayerDeath(playerid, killerid, reason)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
DeathPosition[playerid][pX] = X;
DeathPosition[playerid][pY] = Y;
DeathPosition[playerid][pZ] = Z;
Died[playerid] = 1;
return 1;
}
public OnPlayerSpawn(playerid)
{
if(Died[playerid] == 1)
{
SetPlayerPos(playerid, DeathPosition[playerid][pX], DeathPosition[playerid][pY], DeathPosition[playerid][pZ]);
}
return 1;
}
Re: OnPlayerDeath -
Sid_Alexander - 06.01.2015
pawn Код:
new Float:PosX[MAX_PLAYERS], Float:PosY[MAX_PLAYERS], PosZ[MAX_PLAYERS]; //to save players location
new died[MAX_PLAYERS]; //confirming he's dead
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
died[playerid] = 1; //he's dead
GetPlayerPos(playerid, PosX[playerid], PosY[playerid], PosZ[playerid]); //get his position now
return 1;
}
pawn Код:
if(died[playerid] == 1) //if he's dead
{
died[playerid] = 0; //dead reset
SetPlayerPos(playerid, PosX[playerid], PosY[playerid], PosZ[playerid]); //set his position back to where he was on respawn
// Apply your animation here and more codes
}
return 1;
}
Re: OnPlayerDeath -
PaulDinam - 06.01.2015
Nah, your code only makes him spawn on his previous position after he dies and respawns.
Re: OnPlayerDeath -
Sid_Alexander - 06.01.2015
Quote:
Originally Posted by PaulDinam
Nah, your code only makes him spawn on his previous position after he dies and respawns.
|
If your intention is to avoid dying screen and being teleported to somewhere else, That's impossible, The least you can do is respawn him to where he died, Freeze him, Apply character animation where he's lying, And carry on the roleplay.
Re: OnPlayerDeath -
HY - 06.01.2015
There's nothing wrong with code.
Your code from OnPlayerSpawn() it's problem.
If it's teleporting them to position after dies, then it's ok, you asked for this. But if he got respawned after this it's from your codes.
So, check your OnPlayerSpawn() codes and try to solve problem.