SetSpawnInfo in OnPlayerDeath
#1

If SetSpawnInfo is used in OnPlayerDeath, the team parameter has no effect when the player spawns. SetPlayerTeam must be used in OnPlayerSpawn to workaround this.
Reply
#2

Haven't experienced it as I haven't used SetSpawnInfo in OnPlayerDeath, but thanks for the report.
Reply
#3

As per the latest SA-MP 0.3.7-R2 (for Windows), SetSpawnInfo under OnPlayerDeath works fine for me. Can anyone else confirm such an issue for both Windows and Linux? Also, are you using any plugins or includes that modifies memory or functions? This is the code I used to test on a blank gamemode:
pawn Code:
#include <a_samp>

public OnPlayerSpawn(playerid) {

      //If the bug persists, it shouldn't show 2.
    new
        temp_String[64];
    format(temp_String, sizeof(temp_String), "Your team : %d", GetPlayerTeam(playerid));
    SendClientMessage(playerid, -1, temp_String);
   
    return 1;
}

public OnPlayerConnect(playerid) {

    SetPlayerTeam(playerid, 1);
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason) {

    SetSpawnInfo(playerid, 2, 0, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[]) {

    if(!strcmp(cmdtext, "/kill", true)) {
   
        SetPlayerHealth(playerid, 0.0);
        return 1;
    }
    if(!strcmp(cmdtext, "/changeteam", true)) {
   
        SetPlayerTeam(playerid, 3);
        return 1;
    }
    if(!strcmp(cmdtext, "/defaultteam", true)) {
   
        OnPlayerConnect(playerid);
        return 1;
    }
    if(!strcmp(cmdtext, "/spawnme", true)) {
   
        SpawnPlayer(playerid);
        return 1;
    }
    return 0;
}
EDIT : I've only tested with GetPlayerTeam function and it works fine. I'm not sure if this applies to the gameplay, if that's what the OP is referring to. (For instance to shoot your team mates.)
Reply
#4

I have only tested it on Linux and I have only tested it by shooting players who were previously in the same team as me - not tested GetPlayerTeam. Thanks for confirming that it possibly works properly on Windows.
Reply
#5

GetPlayerTeam works properly for Linux versions too. It'd be nice if someone tests if it works on gameplay too. Or else it could be a mistake from something that you're using.
Reply
#6

It all works really well! The change to OnPlayerDeathFinished is awesome It seems like it works really well and properly from what I've tested.

I've only noticed one bug though (not sure if it's a bug but it seems like it is). Sometimes when you die inside a vehicle (tested several times and I think it depends on the vehicle - from what I remember, it bugs out with a Cheetah but not with SAN News Helicopter and Bullet), you get respawn when you finish your animation, it respawns you on the spot (instantly respawns like you mentioned above) which is awesome but you get bugged out. Your skin is set to the CJ skin every now and then. It didn't happen each time though.

I'll be testing some more in the morning and will hopefully be able to explain it better
Reply
#7

Simple solution would be to use a timer.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)