[Ajuda] Sistema de combustнvel
#1

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?
Reply
#2

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.
Reply
#3

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

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;

Reply
#5

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

Comece pela base do glederson (:
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)