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(Player, i)
{
if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
new engine, lights, alarm, doors, bonnet, boot, objective;
new vehicle = GetPlayerVehicleID(i);
new VehicleModel = GetVehicleModel(vehicle);
GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
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] >= 1 && vehicle < TOTAL_CARROS)
{
if(Gas[vehicle] <= 10)
{
PlayerPlaySound(i, 1085, 0.0, 0.0, 0.0);
}
if(Gas[vehicle] >= 1 && Gas[vehicle] < 4)
{
new rdon = random(10);
if(rdon >= 0 && rdon <= 7)
{
GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicle, VEHICLE_PARAMS_OFF, lights, alarm, doors, bonnet, boot, objective);
foreach(Player, pp)
{
if(GetPlayerVehicleID(pp) == vehicle)
{
SendClientMessage(pp, COLOR_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(i, 1085, 0.0, 0.0, 0.0);
}
if(Gas[vehicle] >= 1 && Gas[vehicle] < 4)
{
new rdon = random(10);
if(rdon >= 0 && rdon <= 7)
{
GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicle, VEHICLE_PARAMS_OFF, lights, alarm, doors, bonnet, boot, objective);
foreach(Player, pp)
{
if(GetPlayerVehicleID(pp) == vehicle)
{
SendClientMessage(pp, COLOR_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(i, 1159, 0.0, 0.0, 0.0);
GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicle, VEHICLE_PARAMS_OFF, lights, alarm, doors, bonnet, boot, objective);
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 vehicleid, v = GetVehiclePoolSize(); vehicleid <= v; ++vehicleid)// loop passando por todos os veiculos conectados.
{
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(engine <= VEHICLE_PARAMS_OFF) // veiculo desligado
continue;
if(Gas[vehicleid] <= 0){ // caso o veiculo nгo tenha combustivel.
SetVehicleParamsEx(vehicleid, VEHICLE_PARAMS_OFF, lights, alarm, doors, bonnet, boot, objective);
}
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 (: