SA-MP Forums Archive
[Ajuda] Sistema de combustнvel - 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] Sistema de combustнvel (/showthread.php?tid=625082)



Sistema de combustнvel - _MtM_ - 27.12.2016

Eu nгo manjo muito disso, entгo peguei um sistema que jб funciona, mas, ele sу funciona quando o player estб dentro do veнculo

PHP код:
CheckGas()
{
    foreach(
Playeri)
    {
           if(
GetPlayerState(i) == PLAYER_STATE_DRIVER)
           {
              new 
enginelightsalarmdoorsbonnetbootobjective;
            new 
vehicle GetPlayerVehicleID(i);
               new 
VehicleModel GetVehicleModel(vehicle);
               
GetVehicleParamsEx(vehicleenginelightsalarmdoorsbonnetbootobjective);
               if(
engine == 0)
            {
                break;
            }
               if(
VehicleModel == 487 || VehicleModel == 520 || VehicleModel == 462 ||
               
VehicleModel == 497 || VehicleModel == 425 || VehicleModel == 592 ||
               
VehicleModel == 519 || VehicleModel == 593 || VehicleModel == 452 ||
               
VehicleModel == 510)
               {
                   continue;
               }
               if(
IsARespCar(vehicle))
               {
                   continue;
               }
            new 
Float:health GetPlayerVehicleHealth(i);
            if(
health 20)continue;
               if(
Gas[vehicle] >= && vehicle TOTAL_CARROS)
               {
                   if(
Gas[vehicle] <= 10)
                   {
                       
PlayerPlaySound(i10850.00.00.0);
                   }
                   if(
Gas[vehicle] >= && Gas[vehicle] < 4)
                   {
                     new 
rdon random(10);
                    if(
rdon >= && rdon <= 7)
                    {
                         
GetVehicleParamsEx(vehicleenginelightsalarmdoorsbonnetbootobjective);
                           
SetVehicleParamsEx(vehicleVEHICLE_PARAMS_OFFlightsalarmdoorsbonnetbootobjective);
                        foreach(
Playerpp)
                        {
                            if(
GetPlayerVehicleID(pp) == vehicle)
                            {
                                
SendClientMessage(ppCOLOR_GRAD1"Aviso: Pouco combustivel no veiculo, o motor desligou. De a partida novamente!");
                            }
                        }
                    }
                   }
                   
Gas[vehicle]--;
                   
UpdateGas(vehicle);
               }
               else if(
CarConce[vehicle] >= 0)
               {
                   if(
Gas[vehicle] <= 10)
                   {
                       
PlayerPlaySound(i10850.00.00.0);
                   }
                   if(
Gas[vehicle] >= && Gas[vehicle] < 4)
                   {
                     new 
rdon random(10);
                    if(
rdon >= && rdon <= 7)
                    {
                         
GetVehicleParamsEx(vehicleenginelightsalarmdoorsbonnetbootobjective);
                           
SetVehicleParamsEx(vehicleVEHICLE_PARAMS_OFFlightsalarmdoorsbonnetbootobjective);
                        foreach(
Playerpp)
                        {
                            if(
GetPlayerVehicleID(pp) == vehicle)
                            {
                                
SendClientMessage(ppCOLOR_GRAD1"Aviso: Pouco combustivel no veiculo, o motor desligou. De a partida novamente!");
                            }
                        }
                    }
                   }
                   
Gas[vehicle]--;
                   
UpdateGas(vehicle);
               }
               else
               {
                   if(
vehicle >= TOTAL_CARROS)continue;
                
NoFuel[i] = 1;
                
PlayerPlaySound(i11590.00.00.0);
                 
GetVehicleParamsEx(vehicleenginelightsalarmdoorsbonnetbootobjective);
                   
SetVehicleParamsEx(vehicleVEHICLE_PARAMS_OFFlightsalarmdoorsbonnetbootobjective);
                
GameTextForPlayer(i,"~r~Sem combustivel~n~~y~Chame um mecanico para ajudar",1500,3);
                
UpdateGas(vehicle);
            }
           }
       } 
O que precisa ser feito para continuar o consumo de combustнvel mesmo quando o player estiver fora do veнculo?


Re: Sistema de combustнvel - MkeY - 27.12.2016

Eu chutaria tirar a verificaзгo if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
Mas provavelmente retornaria alguns erros, ou se nгo, nгo funcionaria corretamente.


Re: Sistema de combustнvel - _MtM_ - 27.12.2016

Eu jб tirei isso, nгo deu erro algum, as, continua funcionando somente com o player dentro do veнculo


Respuesta: Sistema de combustнvel - SammyJ - 27.12.2016

Vocк terб que que refazer esse cуdigo.

Base:
PHP код:
## Base ##
CheckGas()
{
    for(new 
vehicleidGetVehiclePoolSize(); vehicleid <= v; ++vehicleid)// loop passando por todos os veiculos conectados.
    
{
        new 
enginelightsalarmdoorsbonnetbootobjective;
        
GetVehicleParamsEx(vehicleidenginelightsalarmdoorsbonnetbootobjective);
        
        if(
engine <= VEHICLE_PARAMS_OFF// veiculo desligado
            
continue;

        if(
Gas[vehicleid] <= 0){ // caso o veiculo nгo tenha combustivel.
            
SetVehicleParamsEx(vehicleidVEHICLE_PARAMS_OFFlightsalarmdoorsbonnetbootobjective);
        }
        else{
            
Gas[vehicleid]--;
        }
        
    }
    return 
false;




Re: Sistema de combustнvel - _MtM_ - 27.12.2016

Eita carai, refazer o cуdigo? Nгo sei nem por onde comeзar ://


Re: Sistema de combustнvel - didimk157 - 28.12.2016

Comece pela base do glederson (: