SA-MP Forums Archive
Death Bug - 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: Death Bug (/showthread.php?tid=552705)



Death Bug - kevannkw - 26.12.2014

So i am facing a bug in my script which is when a player get killed or /kill themself they get teleported to the location they last logged out. I have tried a lot of things, i have searched in the script for possible errors but still no luck. Hopefully someone here can help me. I want the player to die and spawn on the same place as they got killed at as i am currently doing a roleplay server.


Re: Death Bug - Ryz - 26.12.2014

TP'ed? you mean teleported?


Re: Death Bug - GuardedMerchant - 26.12.2014

Quote:
Originally Posted by kevannkw
Посмотреть сообщение
So i am facing a bug in my script which is when a player get killed or /kill themself they get teleported to the location they last logged out. I have tried a lot of things, i have searched in the script for possible errors but still no luck. Hopefully someone here can help me. I want the player to die and spawn on the same place as they got killed at as i am currently doing a roleplay server.
Try looking for OnPlayerDeath, This is the main section I suggest you look at, And see if there is any SetPlayerPostition( x, y, z ), This could be the cause.
Sorry If didn't help.


Re: Death Bug - VishvaJeet - 26.12.2014

Код:
new SavePos[MAX_PLAYERS][4]; // declare array for store player's pos

public OnPlayerDisconnect(playerid, reason)
{
     GetPlayerPos(playerid, SavePos[playerid][0], SavePos[playerid][1], SavePos[playerid][2]); // store player data
     GetPlayerFacingAngle(playerid, SavePos[playerid][3]);
}

public OnPlayerSpawn(playerid)
{
     SetPlayerPos(playerid, SavePos[playerid][0], SavePos[playerid][1], SavePos[playerid][2]); // load player data
     SetPlayerFacingAngle(playerid, SavePos[playerid][3]);
}



AW: Death Bug - Flori - 26.12.2014

Save the position where they got killed, and set their position to exact this position in OnPlayerSpawn.


Re: Death Bug - HY - 26.12.2014

pawn Код:
enum dInfo
{
    Float:dX,
    Float:dY,
    Float:dZ
}
new DeathInfo[MAX_PLAYERS][dInfo];

new Death[MAX_PLAYERS];

public OnPlayerDeath(playerid, killerid, reason)
{
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    DeathInfo[playerid][dX] = X;
    DeathInfo[playerid][dY] = Y;
    DeathInfo[playerid][dZ] = Z;
    Death[playerid] = 1;
    return 1;
}

public OnPlayerSpawn(playerid)
{
    if(Death[playerid] == 1)
    {
        SetPlayerPos(playerid, DeathInfo[playerid][dX], DeathInfo[playerid][dY], DeathInfo[playerid][dZ]);
        Death[playerid] = 0;
    }
    return 1;
}
What said Flori it's ok but wrong. Then if you got spawned by an Admin, or by a command, will send you to last position. So you need a variable to declare if you are dead, and he will got spawned in that place only if he die.


Re: Death Bug - Vince - 26.12.2014

SetSpawnInfo is probably a lot easier.