[Pedido] OnplayerDeath
#1

Bom, eu estou passando todas as verificaзхes no OnPlayerDeath, e chega uma hora aonde que o player se mata sozinho sem querer, Coloco o Hospital para ele spawnar, Mas nгo spawna de jeito nenhum, eu fiz atй um debug da Vбriavel

PHP код:
PlayerInfo[playerid][PlayerHospital
e sempre continua -1.

O jeito que estou usando.

Код:
PlayerInfo[playerid][PlayerHospital] = GetPlayerHospital(playerid);
OnPlayerSpawn

PHP код:
public OnPlayerSpawn(playerid){
    
SetPlayerHealth(playerid99.0);
    
DarArmasProf(playerid);
    
    if(
PlayerPolicial[playerid][Fardado] == 1) return SetPlayerSkin(playeridPlayerPolicial[playerid][SkinFardada]);
    else 
SetPlayerSkin(playeridPlayerInfo[playerid][Skin]);
    
    if(
PlayerPolicial[playerid][ProcuradoMorreu] == true)
    {
        
PlayerPolicial[playerid][ProcuradoMorreu] = false;
        
MostrarTextoPreso(playerid);
        
Prender(playeridPlayerInfo[playerid][SegundosPreso]);
    }
    if(
PlayerInfo[playerid][EstaPreso] == 1)
    {
        
MostrarTextoPreso(playerid);
        
Prender(playeridPlayerInfo[playerid][SegundosPreso]);
    }
    
//---------------------------------------------------------------------------------------------------------------------------------//
    
if(PlayerInfo[playerid][PlayerHospital] == 0)
    {
        
SetPlayerPos(playerid1173.1145,-1323.7125,15.3962);
        
SetPlayerFacingAngle(playerid268.1490);
        
SetCameraBehindPlayer(playerid);
        
PlayerInfo[playerid][PlayerHospital] = -1;
        
MensagemAposMorrer(playerid);
    }
    else if(
PlayerInfo[playerid][PlayerHospital] == 1)
    {
        
SetPlayerPos(playerid2036.5521,-1412.5513,16.9922);
        
SetPlayerFacingAngle(playerid135.5749);
        
SetCameraBehindPlayer(playerid);
        
PlayerInfo[playerid][PlayerHospital] = -1;
        
MensagemAposMorrer(playerid);
    }
    else if(
PlayerInfo[playerid][PlayerHospital] == 2)
    {
        
SetPlayerPos(playerid1607.4396,1819.1462,10.8280);
        
SetPlayerFacingAngle(playerid359.6572);
        
SetCameraBehindPlayer(playerid);
        
PlayerInfo[playerid][PlayerHospital] = -1;
        
MensagemAposMorrer(playerid);
    }
    else if(
PlayerInfo[playerid][PlayerHospital] == 3)
    {
        
SetPlayerPos(playerid, -2665.0503,636.5155,14.4531);
        
SetPlayerFacingAngle(playerid177.0288);
        
SetCameraBehindPlayer(playerid);
        
PlayerInfo[playerid][PlayerHospital] = -1;
        
MensagemAposMorrer(playerid);
    }
    else if(
PlayerInfo[playerid][PlayerHospital] == 4)
    {
        
SetPlayerPos(playerid, -315.0838,1050.7095,20.3403);
        
SetPlayerFacingAngle(playerid359.3905);
        
SetCameraBehindPlayer(playerid);
        
PlayerInfo[playerid][PlayerHospital] = -1;
        
MensagemAposMorrer(playerid);
    }
    else if(
PlayerInfo[playerid][PlayerHospital] == 5)
    {
        
SetPlayerPos(playerid, -1514.6455,2523.4263,55.8138);
        
SetPlayerFacingAngle(playerid359.6804);
        
SetCameraBehindPlayer(playerid);
        
PlayerInfo[playerid][PlayerHospital] = -1;
        
MensagemAposMorrer(playerid);
    }
    else if(
PlayerInfo[playerid][PlayerHospital] == 6)
    {
        
SetPlayerPos(playerid, -2208.2485,-2286.8516,30.6250);
        
SetPlayerFacingAngle(playerid319.4752);
        
SetCameraBehindPlayer(playerid);
        
PlayerInfo[playerid][PlayerHospital] = -1;
        
MensagemAposMorrer(playerid);
    }
    else if(
PlayerInfo[playerid][PlayerHospital] == 7// Favela
    
{
        new 
rand random(sizeof(FavelaSpawns));
        
SetPlayerPos(playeridFavelaSpawns[rand][0], FavelaSpawns[rand][1], FavelaSpawns[rand][2]);
        
SetPlayerFacingAngle(playeridFavelaSpawns[rand][3]);
        
SetCameraBehindPlayer(playerid);
        
PlayerInfo[playerid][PlayerHospital] = -1;
    }
    if(
EspiandoPID[playerid] != INVALID_PLAYER_ID)
    {
        if(
EspiandoPID[playerid] != INVALID_PLAYER_IDEspiandoPID[playerid] = INVALID_PLAYER_ID;
        
TogglePlayerControllable(playeridtrue);
        return 
1;
       }
    return 
1;

Reply
#2

Eu vi que vocк colocou no OnPlayerSpawn porйm й mais certo colocar no OnPlayerDeath mesmo que nem vc coloco no Tнtulo do post :v

Se eu nгo me engano OnPlayerDeath nгo funciona com SetPlayerPos, apenas com SetSpawnInfo jб tive esse problema tbm. Pesquisei em alguns post do forum e alguns colocavam no OnPlayerSpawn e outros no OnPlayerDeath.

O Meu hoje da certo usando SetSpawnInfo na public OnPlayerDeath nгo sу quando o player se mata tbm quando e morto por alguйm.

PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
    if(
Player[playerid][PlayerHospital] == 1)
    {
        
ClearAnimations(playerid);
        
SetSpawnInfo(playerid0Player[playerid][Skin], 1173.1145, -1323.712515.3962270.0000000000);
        
PlayerInfo[playerid][PlayerHospital] = -1;
        
SetCameraBehindPlayer(playerid); 
        
MensagemAposMorrer(playerid);
    }
    else if(
Player[playerid][PlayerHospital] == 2)
    {
        
ClearAnimations(playerid);
        
// ...
    
}
    return 
1;

Reply
#3

Tem como postar a funзгo GetPlayerHospital(playerid)? Й essencial para fazer debug e descobrir o motivo de continuar em -1.
Reply
#4

Quote:
Originally Posted by iHollyZinhO
Посмотреть сообщение
Tem como postar a funзгo GetPlayerHospital(playerid)? Й essencial para fazer debug e descobrir o motivo de continuar em -1.
A funзгo GetPlayerHospital nгo tem nada haver kkk, tipo, quando um assasino mata alguem em contrato, o player que tava em contrato da spawn normal no hospital.

Cуdigo:

PHP код:
public OnPlayerDeath(playeridkilleridreason){
    if(
playerid != killeridSendDeathMessage(killeridplayeridreason);
    
    
//-------------------------------------------------------------------------------------------------------------------------------------//
    
    
if(killerid != INVALID_PLAYER_ID)
    {
        if(
PlayerInfo[killerid][Prof] == PROF_ASSASINO || PlayerInfo[killerid][Prof] == PROF_CHEFAO_DA_MAFIA && !IsPlayerInFavela(killerid) && ArmaIlegalID[killerid] == -1)
        {
              if(
PlayerInfo[playerid][Contratado] > 0)
               {
                
PlayerInfo[playerid][PlayerHospital] = GetPlayerHospital(playerid);
                
PlayerInfo[playerid][Contratado] --;
                
PlayerInfo[killerid][EstrelasProcurado] ++;
                
sGivePlayerCash(killerid700);
                
MensagemFormatadaAll(0xE71434FF"| DM | {FF8080}%s {E71434}matou {FF8080}%s {E71434}| Estrelas: {FFFF80}%d {E71434}Estrelas!"PlayerName(killerid), PlayerName(playerid), PlayerInfo[killerid][EstrelasProcurado]);
            }
            else
            {
                   
PlayerInfo[killerid][EstrelasProcurado] += 2;
                
PlayerInfo[playerid][PlayerHospital] = GetPlayerHospital(playerid);
                
MensagemFormatadaAll(-1"| DM | Jogador(a) %s matou %s que nгo estava em Contrato e ganhou 2 Estrelas! | %d Estrelas"PlayerName(killerid), PlayerName(playerid), PlayerInfo[killerid][EstrelasProcurado]);
            }
            return 
1;
        }
        else
        {
            if(
IsPlayerInFavela(playerid)) PlayerInfo[playerid][PlayerHospital] = 7;
            
//Prender Procurado
              
if(IsPlayerPolicial(killerid) && PlayerPolicial[killerid][Fardado] == 1)
            {
                
MensagemFormatadaAll(0xFFFFFFAA"| DEPARTAMENTO | O(A) policial {FFFF80}%s{FFFFFF} matou e prendeu {FFFF80}%s {FFFFFF}que estava sendo procurado(a)!"PlayerName(killerid), PlayerName(playerid));
                
PlayerPolicial[playerid][ProcuradoMorreu] = true;
                
//SalvarDadosMySQL(killerid, 5); // Prisхes - RANK
                
Prender(playerid120 PlayerInfo[playerid][EstrelasProcurado]);
            }
            if(!
IsPlayerInFavela(killerid))/* && !IsPlayerInGangzone(killerid) && ArenaDuelo[killerid] == false && EntrouArenaID[killerid] == -1) */
            
{
                 if(
ArmaIlegalID[killerid] != -1)
                {
                    if(
GetPlayerWeapon(killerid) == ArmaIlegalID[killerid])
                    {
                        
PlayerInfo[playerid][PlayerHospital] = GetPlayerHospital(playerid);
                        
PlayerInfo[killerid][EstrelasProcurado] ++;
                        
MensagemFormatadaAll(-1"| DM | {FF8000}%s [ %d ]{FFFFFF} com uma {DA1523}%s Ilegal {FFFFFF}acaba de matar {FF8000}%s[%d] | Quantidade de Estrelas: %d"PlayerName(killerid), killeridGetWeaponNameByID(ArmaIlegalID[killerid]), PlayerName(playerid), playeridPlayerInfo[killerid][EstrelasProcurado]);
                    }
                   }
            }
            else
            {
                if(
IsPlayerInFavela(killerid))
                {
                    
PlayerInfo[killerid][pMatou] ++;
                }
                else if(
IsPlayerInFavela(playerid))
                {
                    
PlayerInfo[playerid][pMorreu] ++;
                }
                else if(
IsPlayerInFavela(killerid) && !IsPlayerInFavela(playerid))
                {
                    
PlayerInfo[playerid][PlayerHospital] = GetPlayerHospital(playerid);
                    return 
1;
                  }
                
                  
PlayerInfo[playerid][PlayerHospital] = GetPlayerHospital(playerid); // Essa linha que nгo retorna
            
}
        }
    }
    return 
1;

Reply
#5

Voce tem que colocar o

PHP код:
PlayerInfo[playerid][PlayerHospital] = GetPlayerHospital(playerid); 
Para caso o player nao seja morto por outro player. Basta colocar um else para condiзao
Quote:

if(killerid != INVALID_PLAYER_ID)

E colocar a instruзao la.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)