SA-MP Forums Archive
[Ajuda] Flood mensagem public - 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] Flood mensagem public (/showthread.php?tid=579945)



Flood mensagem public - LucasDias - 01.07.2015

O que estб errado? quando meu carro para de funcionar, manda a mensagem, mas fica floodando a mensagem, alguйm poderia me ajudar??

PHP код:
forward CheckCarHealth();
public 
CheckCarHealth()
{
    new 
PlayerAvisado[MAX_PLAYERS] = 0;
    for(new 
i=0i<GetMaxPlayers(); i++)
    {
        if (
IsPlayerConnected(i) && IsPlayerInAnyVehicle(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER)
        {
            new 
Float:health;
            
GetVehicleHealth(GetPlayerVehicleID(i),health);
            if(
health <= 400)
            {
                if(
GetPlayerState(i) == PLAYER_STATE_DRIVER)
                {
                    new 
motlualarporcappormaob;
                    new 
carro GetPlayerVehicleID(i);
                    
GetVehicleParamsEx(carromotlualarporcappormaob);
                    
SetVehicleParamsEx(carroVEHICLE_PARAMS_OFFVEHICLE_PARAMS_OFFalarporcappormaob);
                    
SetVehicleHealth(carro400);
                }
                if(
PlayerAvisado[i] == && health <= 400 )
                {
                    
SendClientMessage(i, -1"{B4B5B7}| INFO | Seu veнculo parou de funcionar, chame um mecвnico (/mecanico)!");
                    
PlayerAvisado[i] = 1;
                }
                return 
1;
            }
        }
    }
    return 
1;




Re: Flood mensagem public - Gii - 01.07.2015

PHP код:
//  Abaixo das Includes
new bool:PlayerAvisado[MAX_PLAYERS]; 
public 
OnPlayerConnect(playerid) {
    
PlayerAvisado[playerid] = false;
    return 
1;
}
forward CheckCarHealth(); 
public 
CheckCarHealth() 

    for(new 
0GetMaxPlayers(); i++) 
    { 
        if (
IsPlayerConnected(i) && IsPlayerInAnyVehicle(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER && PlayerAvisado[i] == false
        { 
            new 
Float:health
            
GetVehicleHealth(GetPlayerVehicleID(i),health); 
            if(
health <= 400
            { 
                if(
GetPlayerState(i) == PLAYER_STATE_DRIVER
                { 
                    new 
motlualarporcappormaob
                    new 
carro GetPlayerVehicleID(i); 
                    
GetVehicleParamsEx(carromotlualarporcappormaob); 
                    
SetVehicleParamsEx(carroVEHICLE_PARAMS_OFFVEHICLE_PARAMS_OFFalarporcappormaob); 
                    
SetVehicleHealth(carro400); 
                }
                
                
SendClientMessage(i, -1"{B4B5B7}| INFO | Seu veнculo parou de funcionar, chame um mecвnico (/mecanico)!"); 
                
PlayerAvisado[i] = true;
                return 
1
            } 
        } 
    } 
    return 
1

Nгo se esqueзa de criar um timer ou algo do gкnero para "resetar" o valor de "PlayerAvisado", caso contrбrio o player recebera a notificaзгo uma ъnica vez durante toda sua jogatina.


Re: Flood mensagem public - LucasDias - 01.07.2015

Quote:
Originally Posted by Gii
Посмотреть сообщение
PHP код:
//  Abaixo das Includes
new bool:PlayerAvisado[MAX_PLAYERS]; 
public 
OnPlayerConnect(playerid) {
    
PlayerAvisado[playerid] = false;
    return 
1;
}
forward CheckCarHealth(); 
public 
CheckCarHealth() 

    for(new 
0GetMaxPlayers(); i++) 
    { 
        if (
IsPlayerConnected(i) && IsPlayerInAnyVehicle(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER && PlayerAvisado[i] == false
        { 
            new 
Float:health
            
GetVehicleHealth(GetPlayerVehicleID(i),health); 
            if(
health <= 400
            { 
                if(
GetPlayerState(i) == PLAYER_STATE_DRIVER
                { 
                    new 
motlualarporcappormaob
                    new 
carro GetPlayerVehicleID(i); 
                    
GetVehicleParamsEx(carromotlualarporcappormaob); 
                    
SetVehicleParamsEx(carroVEHICLE_PARAMS_OFFVEHICLE_PARAMS_OFFalarporcappormaob); 
                    
SetVehicleHealth(carro400); 
                }
                
                
SendClientMessage(i, -1"{B4B5B7}| INFO | Seu veнculo parou de funcionar, chame um mecвnico (/mecanico)!"); 
                
PlayerAvisado[i] = true;
                return 
1
            } 
        } 
    } 
    return 
1

Nгo se esqueзa de criar um timer ou algo do gкnero para "resetar" o valor de "PlayerAvisado", caso contrбrio o player recebera a notificaзгo uma ъnica vez durante toda sua jogatina.
Colocar o timer no ongamemodeinit pra verificar a public sempre?


Re: Flood mensagem public - Gii - 01.07.2015

PHP код:
//  Abaixo das Includes 
new PlayerAvisado[MAX_PLAYERS] = { 0, ... };
forward CheckCarHealth();  
public 
CheckCarHealth()  
{  
    for(new 
0GetMaxPlayers(); i++)  
    {  
        if (
IsPlayerConnected(i) && IsPlayerInAnyVehicle(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER && PlayerAvisado[i] <= gettime() )  
        {  
            new 
Float:health;  
            
GetVehicleHealth(GetPlayerVehicleID(i),health);  
            if(
health <= 400)  
            {  
                if(
GetPlayerState(i) == PLAYER_STATE_DRIVER)  
                {  
                    new 
motlualarporcappormaob;  
                    new 
carro GetPlayerVehicleID(i);  
                    
GetVehicleParamsEx(carromotlualarporcappormaob);  
                    
SetVehicleParamsEx(carroVEHICLE_PARAMS_OFFVEHICLE_PARAMS_OFFalarporcappormaob);  
                    
SetVehicleHealth(carro400);  
                } 
                 
                
SendClientMessage(i, -1"{B4B5B7}| INFO | Seu veнculo parou de funcionar, chame um mecвnico (/mecanico)!");  
                
PlayerAvisado[i] = gettime() + 10// em 10 segundos ele receberб o aviso novamente
                
return 1;  
            }  
        }  
    }  
    return 
1;  




Re: Flood mensagem public - LucasDias - 01.07.2015

Quote:
Originally Posted by Gii
Посмотреть сообщение
PHP код:
//  Abaixo das Includes 
new PlayerAvisado[MAX_PLAYERS] = { 0, ... };
forward CheckCarHealth();  
public 
CheckCarHealth()  
{  
    for(new 
0GetMaxPlayers(); i++)  
    {  
        if (
IsPlayerConnected(i) && IsPlayerInAnyVehicle(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER && PlayerAvisado[i] <= gettime() )  
        {  
            new 
Float:health;  
            
GetVehicleHealth(GetPlayerVehicleID(i),health);  
            if(
health <= 400)  
            {  
                if(
GetPlayerState(i) == PLAYER_STATE_DRIVER)  
                {  
                    new 
motlualarporcappormaob;  
                    new 
carro GetPlayerVehicleID(i);  
                    
GetVehicleParamsEx(carromotlualarporcappormaob);  
                    
SetVehicleParamsEx(carroVEHICLE_PARAMS_OFFVEHICLE_PARAMS_OFFalarporcappormaob);  
                    
SetVehicleHealth(carro400);  
                } 
                 
                
SendClientMessage(i, -1"{B4B5B7}| INFO | Seu veнculo parou de funcionar, chame um mecвnico (/mecanico)!");  
                
PlayerAvisado[i] = gettime() + 10// em 10 segundos ele receberб o aviso novamente
                
return 1;  
            }  
        }  
    }  
    return 
1;  

Eu quero que ele envie uma vez sу a mensagem, nгo mais!