OnPlayerDeath.
#1

When my OnPlayerDeath is called, OnPlayerRequestClass is called alongside it.

Here is my code:

pawn Код:
Code update below near the video;
How can I get it to not call it?

Thanks.
Reply
#2

It's not in this callback. Look for ForceClassSelection anywhere and remove it.
Reply
#3

Very strange ...

OnPlayerRequestClass is called automatically after OnPlayerConnect but not in OnPlayerDeath
Reply
#4

It seems to call it automatically when a player dies, what could be up with it?

Should I try in OnPlayerRequestClass this:

pawn Код:
if(Hospitalized[playerid] == 1)
{
    TogglePlayerSpectating(playerid, true);
}
Thanks.
Reply
#5

[ame]http://www.youtube.com/watch?v=dNFV0NEOAjw[/ame]

Here is what is happening.

And here is my code.

When I /kill, it works fine. Otherwise it does this.

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid != INVALID_PLAYER_ID)
    {
        if(killerid != playerid)
        {
            new string[256];
            Player[playerid][Deaths] += 1;
            Player[killerid][Kills] += 1;
            format(string, sizeof(string), "AdmWarn: %s has killed %s with a %s.", RemoveUnderScore(killerid), RemoveUnderScore(playerid), reason);
            SendToAdmins(RED, string, 1);
            SendToAdmins(RED, string, 0);
            Hospitalized[playerid] = 1;
            SendClientMessage(playerid, WHITE, " ");
            format(string, sizeof(string), "{CC0000}Hospital Staff:{FFFFFF} Hello there %s, you have been sent to hospital and are undergoing our treatment.", GetPlayerFirstName(playerid));
            SendClientMessage(playerid, WHITE, string);
            format(string, sizeof(string), "{CC0000}Hospital Staff:{FFFFFF} We have checked you over and we figured out that you are going to have to spend some time in here with us.");
            SendClientMessage(playerid, WHITE, string);
            format(string, sizeof(string), "{CC0000}Hospital Staff:{FFFFFF} There's no need to worry, you are under professional and complete care with our services.");
            SendClientMessage(playerid, WHITE, string);
            SendClientMessage(playerid, WHITE, " ");
            TogglePlayerSpectating(playerid, false);
            TogglePlayerSpectating(playerid, true);
            TogglePlayerControllable(playerid, 0);
            SetPlayerPos(playerid, 1237.1611,304.9076,24.7578);
            SetPlayerCameraPos(playerid, 1251.0834,353.5869,26.5555);
            SetPlayerCameraLookAt(playerid, 1247.0811,325.1535,24.7578);
            SetTimerEx("HospitalRelease", 30000, 0, "i", playerid);
            SetPlayerPos(playerid, 1237.1611,304.9076,24.7578);
            SetPlayerCameraPos(playerid, 1251.0834,353.5869,26.5555);
            SetPlayerCameraLookAt(playerid, 1247.0811,325.1535,24.7578);
            SetPlayerHealth(playerid, 100);
            SetPlayerArmour(playerid, 0);
            Player[playerid][Health] = 100;
            Player[playerid][Armour] = 0;
            SetTimerEx("HosCam", 1000, 0, "i", playerid);
        }
        else
        {
            new string[256];
            Hospitalized[playerid] = 1;
            SendClientMessage(playerid, WHITE, " ");
            format(string, sizeof(string), "{CC0000}Hospital Staff:{FFFFFF} Hello there %s, you have been sent to hospital and are undergoing our treatment.", GetPlayerFirstName(playerid));
            SendClientMessage(playerid, WHITE, string);
            format(string, sizeof(string), "{CC0000}Hospital Staff:{FFFFFF} We have checked you over and we figured out that you are going to have to spend some time in here with us.");
            SendClientMessage(playerid, WHITE, string);
            format(string, sizeof(string), "{CC0000}Hospital Staff:{FFFFFF} There's no need to worry, you are under professional and complete care with our services.");
            SendClientMessage(playerid, WHITE, string);
            SendClientMessage(playerid, WHITE, " ");
            TogglePlayerSpectating(playerid, false);
            TogglePlayerSpectating(playerid, true);
            TogglePlayerControllable(playerid, 0);
            SetPlayerPos(playerid, 1237.1611,304.9076,24.7578);
            SetPlayerCameraPos(playerid, 1251.0834,353.5869,26.5555);
            SetPlayerCameraLookAt(playerid, 1247.0811,325.1535,24.7578);
            SetTimerEx("HospitalRelease", 30000, 0, "i", playerid);
            SetPlayerPos(playerid, 1237.1611,304.9076,24.7578);
            SetPlayerCameraPos(playerid, 1251.0834,353.5869,26.5555);
            SetPlayerCameraLookAt(playerid, 1247.0811,325.1535,24.7578);
            SetPlayerHealth(playerid, 100);
            SetPlayerArmour(playerid, 0);
            Player[playerid][Health] = 100;
            Player[playerid][Armour] = 0;
            SetTimerEx("HosCam", 1000, 0, "i", playerid);
        }
    }
    else
    {
        if(killerid != playerid)
        {
            new string[512];
            format(string, sizeof(string), "AdmWarn: %s has killed %s with a %s.", RemoveUnderScore(killerid), RemoveUnderScore(playerid), reason);
            SendToAdmins(RED, string, 1);
            SendToAdmins(RED, string, 0);
            Hospitalized[playerid] = 1;
            SendClientMessage(playerid, WHITE, " ");
            format(string, sizeof(string), "{CC0000}Hospital Staff:{FFFFFF} Hello there %s, you have been sent to hospital and are undergoing our treatment.", GetPlayerFirstName(playerid));
            SendClientMessage(playerid, WHITE, string);
            format(string, sizeof(string), "{CC0000}Hospital Staff:{FFFFFF} We have checked you over and we figured out that you are going to have to spend some time in here with us.");
            SendClientMessage(playerid, WHITE, string);
            format(string, sizeof(string), "{CC0000}Hospital Staff:{FFFFFF} There's no need to worry, you are under professional and complete care with our services.");
            SendClientMessage(playerid, WHITE, string);
            SendClientMessage(playerid, WHITE, " ");
            TogglePlayerSpectating(playerid, false);
            TogglePlayerSpectating(playerid, true);
            TogglePlayerControllable(playerid, 0);
            SetPlayerPos(playerid, 1237.1611,304.9076,24.7578);
            SetPlayerCameraPos(playerid, 1251.0834,353.5869,26.5555);
            SetPlayerCameraLookAt(playerid, 1247.0811,325.1535,24.7578);
            SetTimerEx("HospitalRelease", 30000, 0, "i", playerid);
            SetPlayerPos(playerid, 1237.1611,304.9076,24.7578);
            SetPlayerCameraPos(playerid, 1251.0834,353.5869,26.5555);
            SetPlayerCameraLookAt(playerid, 1247.0811,325.1535,24.7578);
            SetPlayerHealth(playerid, 100);
            SetPlayerArmour(playerid, 0);
            Player[playerid][Health] = 100;
            Player[playerid][Armour] = 0;
            SetTimerEx("HosCam", 1000, 0, "i", playerid);
        }
        else
        {
            new string[512];
            Hospitalized[playerid] = 1;
            SendClientMessage(playerid, WHITE, " ");
            format(string, sizeof(string), "{CC0000}Hospital Staff:{FFFFFF} Hello there %s, you have been sent to hospital and are undergoing our treatment.", GetPlayerFirstName(playerid));
            SendClientMessage(playerid, WHITE, string);
            format(string, sizeof(string), "{CC0000}Hospital Staff:{FFFFFF} We have checked you over and we figured out that you are going to have to spend some time in here with us.");
            SendClientMessage(playerid, WHITE, string);
            format(string, sizeof(string), "{CC0000}Hospital Staff:{FFFFFF} There's no need to worry, you are under professional and complete care with our services.");
            SendClientMessage(playerid, WHITE, string);
            SendClientMessage(playerid, WHITE, " ");
            TogglePlayerSpectating(playerid, false);
            TogglePlayerSpectating(playerid, true);
            TogglePlayerControllable(playerid, 0);
            SetPlayerPos(playerid, 1237.1611,304.9076,24.7578);
            SetPlayerCameraPos(playerid, 1251.0834,353.5869,26.5555);
            SetPlayerCameraLookAt(playerid, 1247.0811,325.1535,24.7578);
            SetTimerEx("HospitalRelease", 30000, 0, "i", playerid);
            SetPlayerPos(playerid, 1237.1611,304.9076,24.7578);
            SetPlayerCameraPos(playerid, 1251.0834,353.5869,26.5555);
            SetPlayerCameraLookAt(playerid, 1247.0811,325.1535,24.7578);
            SetPlayerHealth(playerid, 100);
            SetPlayerArmour(playerid, 0);
            Player[playerid][Health] = 100;
            Player[playerid][Armour] = 0;
            SetTimerEx("HosCam", 1000, 0, "i", playerid);
        }
    }
    return 1;
}
Reply
#6

Make a variable that says that the player already selected his class. Example

pawn Код:
new Spawned[MAX_PLAYERS] = 0;

OnPlayerSpawn(playerid)
{
    Spawned[playerid] = 1;
}

OnlPlayerRequestClass(playerid)
{
   if(Spawned[playerid] = 1) return 1;
}
Reply
#7

I thought it had something to do with SpawnPlayer being called without SetSpawnInfo or something along those lines.
Reply
#8

Quote:
Originally Posted by Vince
Посмотреть сообщение
I thought it had something to do with SpawnPlayer being called without SetSpawnInfo or something along those lines.
Yes, you're right. You have to use SetSpawnInfo before you spawn a player.
Reply
#9

The point is, they already have their skins and things, it shouldn't even go to the class selection screen...

I've got to have been spawned before I can even die, so it's not that what's the problem.

Thanks!
Reply
#10

Hmm you might see what's wrong with "HosCam" dunno I just see a timer calls it after 1 sec from death so maybe something wrong there.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)