AfterLife system
#1

Hello.
I'm kind of new at Pawno scripting, but i've done this and that @lua script and C++ before.
So currently i'm working on a samp RP server gamemode, doing afterlife system, but i have a problem which i can't fix.

I took this script as the base. Thank you Admantis for ur work. https://sampforum.blast.hk/showthread.php?tid=205223

So the script all in all works fine, it does what it was supposed to do. When the player dies, after writing in /acceptdeath i get sent to the local hospital.

The problem is that, after dieing it used to open up a skin selection menu with CJ. Did abit of research and found out that i have to add SpawnPlayer in OnPlayerRequestClass. It worked, i didnt get the class seletion menu anymore, but the problem was it teleported the character to its spawn position, obviously coz thats what SpawnPlayer is supposed to do, and the deathcam was still at the place where it died. I can't seem to find a way how to fix this. The character should be left dead at the place where it died instead of teleporting it away to its spawn position. I tried to add "SetPlayerPos(...Death positon cordinates); in the OnPlayerRequest but it did not work like that.

That was the first thing, secound problem is the camera. After using the command acceptdeath it brings me to afterlife screen, where it makes a countdown. The camera was supposed to show the entrance of Los Santos hospital but instead its somewhere up in the sky. I tought its because i didnt define in which virtual world the camera is, but even after i defined it, its still not working.

Due to my bad English, i made a small video that shows whats going on.

https://www.youtube.com/watch?v=V1v9cIfqBoY

Heres my script.


http://pastebin.com/VJ8RP1Pg
Reply
#2

-bump-
Reply
#3

Not sure if i can Bump this again, but i really do need help.
Reply
#4

You can save the pos when player died and After player spawns set it's position to dead position and apply dead (any) animation...
Reply
#5

As u can see @ the code, i already did that.
public OnPlayerDeath(playerid, killerid, reason)
{

new FloatX, FloatY, FloatZ;
GetPlayerPos(playerid, pX, pY, pZ);
DeathPosX[playerid] = pX;
DeathPosY[playerid] = pY;
DeathPosZ[playerid] = pZ;
IsDead[playerid] = 1;
}

It saves its death position.

On player spawn it spawns it @ the death position.
public OnPlayerSpawn(playerid)
{

IsAfterLifing[playerid] = 0;
if (IsDead[playerid] == 1)
{
SetPlayerPos(playerid,DeathPosX[playerid],DeathPosY[playerid],DeathPosZ[playerid]);

But it doesnt coz, when player dies it gets sent to the skin select menu. After pressing the spawn button it sends the character to its spawn position, not the death position.
To prevent this, i red that i have to add SpawnPlayer @ OnPlayerClassRequest. but it wont work like that coz, it teleports the character to its spawn position, but leaves the death cam @ the place where he died. I tried to add this " SetPlayerPos(playerid,DeathPosX[playerid],DeathPosY[playerid],DeathPosZ[playerid]);" into OnPlayerClassRequest, but it wont work like that.
Reply
#6

At Top, under includes
pawn Код:
new Float: pX, Float: pY, Float: pZ;
new isDead[MAX_PLAYERS];
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    GetPlayerPos(playerid, pX, pY, pZ);
    DeathPosX[playerid] = pX;
    DeathPosY[playerid] = pY;
    DeathPosZ[playerid] = pZ;
    IsDead[playerid] = 1;
}
Under OnPlayerSpawn
pawn Код:
if(IsDead[playerid] == 1)
{
    SetPlayerPos(playerid, DeathPosX[playerid],DeathPosY[playerid],DeathPosZ[playerid]);
And you said you return to class selection after death?
Show me your OnPlayerRequestClass
Reply
#7

Its just stock. public OnPlayerRequestClass(playerid, classid)
{
return 1;
}

but i've tryed like this:

// public OnPlayerRequestClass(playerid, classid)
// {
// SetPlayerPos(playerid,DeathPosX[playerid],DeathPosY[playerid],DeathPosZ[playerid]);
// return 1;
// }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)