Death Bug
#1

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.
Reply
#2

TP'ed? you mean teleported?
Reply
#3

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.
Reply
#4

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

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

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.
Reply
#7

SetSpawnInfo is probably a lot easier.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)