[UNSOLVED] OnPlayerDeath - Not respawning
#1

Hi,

I've got this annoying problem somehow. Basically when a player dies, he dies, but he doesn't respawn. The camera just stays as it is (because i use setcamerapos - thats fine), the health bar remains flashing, but i can move about. I've noticed that when i set my health to 100 it respawns me and OnPlayerSpawn is called, otherwise OnPlayerSpawn is not called.

Here's my OnPlayerDeath callback:

pawn Код:
public OnPlayerDeath(playerid,killerid,reason)
{
    new dbugstring[128];
    format(dbugstring,sizeof(dbugstring),"|| DEBUG || %s Onplayerdeathstarted", playerid);
    SendClientMessageToAll(COLOR_BRIGHTRED,dbugstring);
    print(dbugstring);
    TextDrawShowForPlayer(playerid,WideScreenUp);
    TextDrawShowForPlayer(playerid,WideScreenDown);
    format(dbugstring,sizeof(dbugstring),"|| DEBUG || %s BAR TD SHOWN", playerid);
    SendClientMessageToAll(COLOR_BRIGHTRED,dbugstring);
    print(dbugstring);
    //GameTextForPlayer(playerid,"Wasted", 3000, 2);
  new Float:X, Float:Y, Float:Z; //creating some variables
    GetPlayerPos(playerid, X, Y, Z);
    SetPlayerCameraPos(playerid, X + 22.0, Y + 5.0, Z + 15.0);
    SetPlayerCameraLookAt(playerid, X, Y, Z);
    format(dbugstring,sizeof(dbugstring),"|| DEBUG || %s CAMERa SET", playerid);
    SendClientMessageToAll(COLOR_BRIGHTRED,dbugstring);
    print(dbugstring);
    SetPlayerWorldBounds(playerid, INFINITY, -INFINITY, INFINITY, -INFINITY);
    if(GAMETYPE == 2 && Current != -1 && Player[playerid][pPlaying]) // for TDM
  {
        Player[playerid][pPlaying] = true;
        if(Player[killerid][pTeam] == T_ATT) TDM_DEFScore++;
        else if(Player[killerid][pTeam] == T_DEF) TDM_ATTScore++;
    }
    else Player[playerid][pPlaying] = false;
  ViewingBase[playerid] = -1;
  SendDeathMessage(killerid,playerid,reason);
  ResetPlayerWeapons(playerid);
  GivePlayerMoney(playerid, 100);
    SetPlayerTeam(playerid,playerid);
  TextDrawShowForAll(Baseloading);
  GivePlayerMoney(playerid, 100);

    if(IsPlayerConnected(killerid)) SetPlayerScore(killerid, GetPlayerScore(killerid) + 1); /// This updates player's score when he kills someone

    if(KillsCountActive)
    {
        Kills[killerid]++;
    }
    format(dbugstring,sizeof(dbugstring),"|| DEBUG || %s STAGE 3", playerid);
    SendClientMessageToAll(COLOR_BRIGHTRED,dbugstring);
    print(dbugstring);
    if(KillzCounter && IsPlayerConnected(killerid) && Player[killerid][pPlaying] == true) Killz[killerid]++;

    for(new x=0; x<MAX_SERVER_PLAYERS; x++) {
      if(GetPlayerState(x) == PLAYER_STATE_SPECTATING && gSpectateID[x] == playerid) {
        StopSpectate(x);
        }
    }
    if(reason == 50)
    {
        new killername[24],string[STR];
        GetPlayerName(killerid,killername,STR);
        format(string,STR,"%s has been eliminated for Heli-Killing.",killername);
        SendClientMessageToAll(COLOR_BRIGHTRED,string);
        SetPlayerHealth(killerid,0);
  }
    if(reason == 4)
    {
        new killername[MAX_PLAYER_NAME],playername[MAX_PLAYER_NAME], string[STR], string2[STR];
        GetPlayerName(killerid,killername,STR), GetPlayerName(playerid,playername,sizeof(playername));
        format(string,STR,"|| Knifage!! || %s has Knifed %s to death in the back!",killername, playername);
        SendClientMessageToAll(COLOR_BRIGHTRED,string);
        format(string2,STR,"Smart kill there %s, have $250 for killing %s",killername, playername);
        SendClientMessage(killerid,COLOR_GREY,string2);
        GivePlayerMoney(killerid, 250);
    }

  if(IsPlayerInCheckpoint(playerid))
    {
        KillTimer(CountdownTimer);
        IsCPTimerStarted=0;
        KillTimer(CTime);
    }

    for(new x=0; x<MAX_SERVER_PLAYERS; x++)
    {
        if(GetPlayerState(x) == PLAYER_STATE_SPECTATING && gSpectateID[x] == playerid)
        {
        AdvanceSpectate(x);
        }
    }
    if(!Player[playerid][killedhimself] && killerid != INVALID_PLAYER_ID)
    {
        new killer[MAX_PLAYER_NAME], killmsg[128];
        new Float:armour, Float:health2;
        GetPlayerHealth(killerid, health2);
        GetPlayerArmour(killerid, armour);
        GetPlayerName(killerid,killer,sizeof(killer));
        format(killmsg, sizeof(killmsg), "Your killer %s had %.0f health points and %.0f armour.", killer, health2, armour);
        SendClientMessage(playerid, AAD_COLOR_RED, killmsg);
        TogglePlayerSpectating(playerid, 1);
        PlayerSpectatePlayer(playerid, killerid);
        SendClientMessage(playerid,COLOR_LIME,">> Respawning in 5 seconds...");
        SetTimerEx("STOPSPECCINGNOW", 5000, false, "d", playerid);
  }
  if(Player[playerid][pPlaying]== true && FirstRoundKill)
  {
    GameTextForAll("~r~~n~~n~~n~~n~First Blood",5000,3);
    FirstRoundKill = false;
  }
    format(dbugstring,sizeof(dbugstring),"|| DEBUG || %s Onplayerdeath ENDED", playerid);
    SendClientMessageToAll(COLOR_BRIGHTRED,dbugstring);
    print(dbugstring);
    return 1;
}
If you want to see OnPlayerSpawn please let me know, but at the moment i dont think it's necessary. I've also noticed that On foot rate, incar_rate etc is not set in my server.cfg, is this a problem? (BTW, i'm using 0.3).

Any help would be appreciated. I've disabled all my FS's etc and the problem still remains. Someone has suggested to use timers on irc, but i'd rather not cure it, but rather prevent it in the first place.

Thanks.
Reply
#2

Maybe use a timer ?
Reply
#3

Quote:
Originally Posted by ►Peter Corneile◄ [hugu-hosting.co.uk
]
Maybe use a timer ?
Quote:
Originally Posted by [B2K
Hustler ]
Someone has suggested to use timers on irc, but i'd rather not cure it, but rather prevent it in the first place.
I did mention i'd prefer not to use timers. Thanks anyways.
Reply
#4

Quote:
Originally Posted by [B2K
Hustler ]
Quote:
Originally Posted by ►Peter Corneile◄ [hugu-hosting.co.uk
]
Maybe use a timer ?
Quote:
Originally Posted by [B2K
Hustler ]
Someone has suggested to use timers on irc, but i'd rather not cure it, but rather prevent it in the first place.
I did mention i'd prefer not to use timers. Thanks anyways.
Ahh alright
Reply
#5

Heyho.

Little question first:

What should this part do:

pawn Код:
new Float:X, Float:Y, Float:Z; //creating some variables
    GetPlayerPos(playerid, X, Y, Z);
    SetPlayerCameraPos(playerid, X + 22.0, Y + 5.0, Z + 15.0);
    SetPlayerCameraLookAt(playerid, X, Y, Z);
In my oppinion this might cause the problem, but i'm unsure, because i never had a problem like that before.
Reply
#6

Quote:
Originally Posted by DeathOnaStick
Heyho.

Little question first:

What should this part do:

Код:
new Float:X, Float:Y, Float:Z; //creating some variables
	GetPlayerPos(playerid, X, Y, Z);
	SetPlayerCameraPos(playerid, X + 22.0, Y + 5.0, Z + 15.0);
	SetPlayerCameraLookAt(playerid, X, Y, Z);
In my oppinion this might cause the problem, but i'm unsure, because i never had a problem like that before.
Maybe yes because Camera Pos doesnt stop unless a timer is made (Correct me if i am wrong)
Reply
#7

That's exacly what i thought, too. You really might try it with a timer, or delete that part of code, it might work then.
Reply
#8

You should try to set a timer that forces you to spawn after a certain amount of time
Reply
#9

you should try to use SetCameraBehindPlayer in OnPlayerSpawn
Reply
#10

Quote:
Originally Posted by ♣ ⓐⓢⓢ
you should try to use SetCameraBehindPlayer in OnPlayerSpawn
None of the above work, neither does SetCameraBehindPlayer. This isn't the main problem, basically OnPlayerSpawn isn't even called after death, so SetCameraBehindPlayer would not execute, and also my textdraws are not hidden either which show under OnPlayerDeath.

Still looking for an answer.

Note: Sometimes it works fine, but sometimes this problem happens. Also, if you come back after a while, you successfully respawn. Also, as stated earlier, if i set my health back to 100, OnPlayerSpawn is called. I don't exactly know whether this is a 0.3 problem or the script itself.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)