SA-MP Forums Archive
[Ajuda]OnPlayerDisconnect - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda]OnPlayerDisconnect (/showthread.php?tid=264969)



[Ajuda]OnPlayerDisconnect - [Dk]TuReTOo - 28.06.2011

Boas tipo ao entrar avvisa que o player entrou mas ao sair nao avisa :S

vejam ai o onplayerdisconnect

PHP код:
public OnPlayerDisconnect(playeridreason)
{
new 
string[64], name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
switch(
reason)
{
case 
0format(string,sizeof string,"{37FF69}%s(%d) saiu do servidor.",nameplayerid);
}
SendClientMessageToAll(0x009D00AA,string);
gActivePlayers[playerid]--;
numplayers--;
if(
reason == 0)
{
PlayerInfo[playerid][pCrashed] = 1;
for(new 
slot 0slot != 12slot++)
{
new 
wepammo;
GetPlayerWeaponData(playeridslotwepammo);
if(
wep != && ammo != 0)
{
if(
PlayerInfo[playerid][pGun1] == 0) { PlayerInfo[playerid][pGun1] = wepPlayerInfo[playerid][pAmmo1] = ammo; }
else if(
PlayerInfo[playerid][pGun2] == 0) { PlayerInfo[playerid][pGun2] = wepPlayerInfo[playerid][pAmmo2] = ammo; }
else if(
PlayerInfo[playerid][pGun3] == 0) { PlayerInfo[playerid][pGun3] = wepPlayerInfo[playerid][pAmmo3] = ammo; }
else if(
PlayerInfo[playerid][pGun4] == 0) { PlayerInfo[playerid][pGun4] = wepPlayerInfo[playerid][pAmmo4] = ammo; }
}
}
}
 
OnPlayerUpdate(playerid);
    for(new 
0MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i))
        {
            if(
TaxiAccepted[i] < 999)
            {
                if(
TaxiAccepted[i] == playerid)
                {
                    
TaxiAccepted[i] = 999;
                    
GameTextForPlayer(i"~w~Chamador Taxi~n~~r~Esquerdo o jogo"50001);
                    
TaxiCallTime[i] = 0;
                    
DisablePlayerCheckpoint(i);
                }
            }
            else if(
BusAccepted[i] < 999)
            {
                if(
BusAccepted[i] == playerid)
                {
                    
BusAccepted[i] = 999;
                    
GameTextForPlayer(i"~w~Chamador Autocarro~n~~r~Esquerdo o jogo"50001);
                    
BusCallTime[i] = 0;
                    
DisablePlayerCheckpoint(i);
                }
            }
        }
    }
    
/*if(GettingCK[playerid] < 999)
    {
        if(IsPlayerConnected(GettingCK[playerid]))
        {
            SendClientMessage(GettingCK[playerid], COLOR_YELLOW, "O seu cliente deixou o servidor, tente novamente mais tarde.");
            OnCK[GettingCK[playerid]] = 999;
        }
    }*/
    
if (GetPlayerVehicleID(playerid) == 131SetVehicleToRespawn(131);
    
OnPlayerUpdate(playerid);
    
//----------------------------------------------------------
    
if(TransportCost[playerid] > && TransportDriver[playerid] < 999)
    {
        if(
IsPlayerConnected(TransportDriver[playerid]))
        {
            new 
string[64];
            
TransportMoney[TransportDriver[playerid]] += TransportCost[playerid];
            
TransportTime[TransportDriver[playerid]] = 0;
            
TransportCost[TransportDriver[playerid]] = 0;
            
format(stringsizeof(string), "~w~Passageiros esquerdos~n~~g~Acumulado %dЂ",TransportCost[playerid]);
            
GameTextForPlayer(TransportDriver[playerid], string50001);
        }
    }
    if(
GotHit[playerid] > 0)
    {
        if(
GetChased[playerid] < 999)
        {
            if(
IsPlayerConnected(GetChased[playerid]))
            {
                
SendClientMessage(GetChased[playerid], COLOR_RED"Seu Hit deixou o servidor.");
                
GoChase[GetChased[playerid]] = 999;
            }
        }
    }
    if(
PlayerPaintballing[playerid] != 0)
    {
        
PaintballPlayers --;
    }
    if(
PlayerKarting[playerid] > && PlayerInKart[playerid] > 0)
    {
        
KartingPlayers --;
    }
    if(
PlayersChannel[playerid] < 999)
    {
        
IRCInfo[PlayersChannel[playerid]][iPlayers] -= 1;
    }
    if(
HireCar[playerid] != 299)
    {
        
gLastDriver[HireCar[playerid]] = 300;
        
gCarLock[HireCar[playerid]] = 0;
        
UnLockCar(HireCar[playerid]);
        if(
reason != 0)
        {
            
SetVehicleToRespawn(HireCar[playerid]);
        }
    }
    if(
GangCar[playerid] != 512)
    {
        
gLastDriver[GangCar[playerid]] = 520;
        
gCarLock[GangCar[playerid]] = 0;
        
UnLockCar(GangCar[playerid]);
    }
    if (
gLastCar[playerid] > 0)
    {
        
gLastDriver[gLastCar[playerid]] = 300;
        if(
PlayerInfo[playerid][pPhousekey] != gLastCar[playerid]-1)
        {
            
gCarLock[gLastCar[playerid]] = 0;
            
UnLockCar(gLastCar[playerid]);
        }
    }
    if(
PlayerBoxing[playerid] > 0)
    {
        if(
Boxer1 == playerid)
        {
            if(
IsPlayerConnected(Boxer2))
            {
                
PlayerBoxing[Boxer2] = 0;
                
SetPlayerPos(Boxer2765.8433,3.2924,1000.7186);
                
SetPlayerInterior(Boxer25);
                
PlayerInfo[Boxer2][pInt] = 5;
                
GameTextForPlayer(Boxer2"~r~Partida interrompida"50001);
            }
        }
        else if(
Boxer2 == playerid)
        {
            if(
IsPlayerConnected(Boxer1))
            {
                
PlayerBoxing[Boxer1] = 0;
                
SetPlayerPos(Boxer1765.8433,3.2924,1000.7186);
                
SetPlayerInterior(Boxer15);
                
PlayerInfo[Boxer2][pInt] = 5;
                
GameTextForPlayer(Boxer1"~r~Partida interrompida"50001);
            }
        }
        
InRing 0;
         
RoundStarted 0;
        
Boxer1 255;
        
Boxer2 255;
        
TBoxer 255;
    }
    if(
TransportDuty[playerid] == 1)
    {
        
TaxiDrivers -= 1;
    }
    else if(
TransportDuty[playerid] == 2)
    {
        
BusDrivers -= 1;
    }
    if(
PlayerInfo[playerid][pJob] == 11)
    {
        if(
JobDuty[playerid] == 1) { Medics -= 1; }
    }
    else if(
PlayerInfo[playerid][pJob] == 7)
    {
        if(
JobDuty[playerid] == 1) { Mechanics -= 1; }
    }
    else if(
PlayerInfo[playerid][pJob] == 17)
    {
        if(
JobDuty[playerid] == 1) { PizzaBoys -= 1; }
    }
    if (
PlayerInfo[playerid][pRoadblock] != 0)
    {
        
RemoveRoadblock(playerid);
    }
    
BusrouteEast[playerid][0] = 0;
    
BusrouteWest[playerid][0] = 0;
    
TextDrawHideForPlayer(playerid,lbt);
    
TextDrawHideForPlayer(playerid,lbb);




Re: [Ajuda]OnPlayerDisconnect - lucas_mdr1235 - 28.06.2011

pawn Код:
switch(reason)
{
case 0: format(string,sizeof string,"{37FF69}%s(%d) saiu do servidor.",name, playerid);
}

esse e o certo \/

pawn Код:
switch(reason)
    {
        case 0:format(string, sizeof(string), "***%s Saiu do server por erro de conexгo ou crash.", name);
        case 1:format(string, sizeof(string), "***%s Saiu por vontade propria.", name);
        case 2:format(string, sizeof(string), "***%s Saiu do servidor kickado ou banido.", name);
    }
    SendClientMessageToAll(0x009D00AA,string);



Re: [Ajuda]OnPlayerDisconnect - The Knight - 28.06.2011

Se quiser que sу diga que o jogador saiu:
PHP код:
formatstringsizeof( string ), "{37FF69}%s(%d) saiu do servidor."nameplayerid );
SendClientMessageToAll( -1string ); 
Se quiser que avise o motivo pelo qual o jogador saiu:
PHP код:
if( reason == formatstringsizeof( string ), "{37FF69}%s(%d) saiu do servidor. [Crash]"nameplayerid );
else if( 
reason == formatstringsizeof( string ), "{37FF69}%s(%d) saiu do servidor. [Vontade Prуpria]"nameplayerid );
else if( 
reason == formatstringsizeof( string ), "{37FF69}%s(%d) saiu do servidor. [Kickado/Banido]"nameplayerid );
SendClientMessageToAll( -1string );