[HELP] Fuel -
monster010 - 22.05.2014
I put a system engine, but when I stop the engine, the fuel decreases 3-4% then increase at 100%.
Exmeple: i have fuel 80%, when i stop the engine, decreases at 76% then increase at 100%. Why?
pawn Код:
if (newkeys & KEY_NO)
{
if(GetPlayerState(playerid) == 2)
{
//This part here is defining the vehicle ID that the player is currently in.
new engine, lights, alarm, doors, bonnet, boot, objective; //This is defining the vehicles current items.
GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);//This is checking the vehicle's engine/lights/alarm/doors/bonnet/boot/objective status.
if(Engine[vehicle] == 0) //This is checking if the engine of the vehicle, is turned off or not.
{
Engine[vehicle] = 1; //This is setting the global variable that you created at the beginning.
SetVehicleParamsEx(vehicle, 1, lights, alarm, doors, bonnet, boot, 0); //This is setting the vehicles engine to be on.
GameTextForPlayer(playerid, "~w~ENGINE ~g~ON...", 1000, 6);
}
else
{
Engine[vehicle] = 0; //This is setting the global variable that you created at the beginning.
SetVehicleParamsEx(vehicle, 0, lights, alarm, doors, bonnet, boot, 0); //This is setting the vehicles engine to be on.
GameTextForPlayer(playerid, "~w~ENGINE ~r~OFF...", 1000, 6);
}
}
}
pawn Код:
public CheckGas()
{
new string[256];
for(new i=0;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
new vehicle = GetPlayerVehicleID(i);
if(Gas[vehicle] >= 1)
{
if(Gas[vehicle] <= 10) { PlayerPlaySound(i, 1085, 0.0, 0.0, 0.0); }
if(gGas[i] == 1) {
format(string, sizeof(string), "~b~~n~~n~~n~~n~~n~~n~~n~~n~~n~Fuel:~w~ %d% %",Gas[vehicle]);
GameTextForPlayer(i,string,15500,3); }
if(IsAPlane(vehicle) || IsABoat(vehicle) || IsABmx(vehicle)) { Gas[vehicle]++; }
Gas[vehicle]--;
}
else
{
NoFuel[i] = 1;
TogglePlayerControllable(i, 0);
GameTextForPlayer(i,"~r~~n~~n~~n~~n~~n~~n~~n~~n~No fuel in Vehicle~n~Use /exit to leave the vehicle",1500,3);
}
}
}
}
return 1;
}
Re: [HELP] Fuel -
monster010 - 23.05.2014
Nobody can help me?
Re: [HELP] Fuel -
Fred1993 - 23.05.2014
pawn Код:
if (newkeys & KEY_NO)
{
if(GetPlayerState(playerid) == 2)
{
//This part here is defining the vehicle ID that the player is currently in.
new engine, lights, alarm, doors, bonnet, boot, objective; //This is defining the vehicles current items.
GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);//This is checking the vehicle's engine/lights/alarm/doors/bonnet/boot/objective status.
if(Engine[vehicle] == 0) //This is checking if the engine of the vehicle, is turned off or not.
{
Engine[vehicle] = 1; //This is setting the global variable that you created at the beginning.
SetVehicleParamsEx(vehicle, 1, lights, alarm, doors, bonnet, boot, 0); //This is setting the vehicles engine to be on.
GameTextForPlayer(playerid, "~w~ENGINE ~g~ON...", 1000, 6);
}
else
{
Engine[vehicle] = 0; //This is setting the global variable that you created at the beginning.
SetVehicleParamsEx(vehicle, 0, lights, alarm, doors, bonnet, boot, 0); //This is setting the vehicles engine to be on.
GameTextForPlayer(playerid, "~w~ENGINE ~r~OFF...", 1000, 6);
}
}
}
i don't see anything wrong here though
well maybe the checkgas() is loading more than 1 time ?
Re: [HELP] Fuel -
monster010 - 23.05.2014
Mean?
Re : [HELP] Fuel -
yusei - 23.05.2014
Hello Try at first
PHP код:
public CheckGas()
{
new string[256];
for (new i=0; i<=MAX_PLAYERS; i++) {
new vehicle = GetPlayerVehicleID(i);
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vehicle,engine,lights,alarm,doors,bonnet,boot,objective);
if(engine >= 1) {
if(Gas[vehicle] >= 1) {
format(string, sizeof(string), "~b~~n~~n~~n~~n~~n~~n~~n~~n~~n~Fuel:~w~ %d% %",Gas[vehicle]);
GameTextForPlayer(i,string,15500,3); }
Gas[vehicle]--;
}
else {
NoFuel[i] = 1;
TogglePlayerControllable(i, 0);
GameTextForPlayer(i,"~r~~n~~n~~n~~n~~n~~n~~n~~n~No fuel in Vehicle~n~Use /exit to leave the vehicle",1500,3);
}
}
}
return 1;
}
make sur your timer is
PHP код:
new var;
var = SetTimer("CheckGas", TIMEhere, true);
Re: [HELP] Fuel -
monster010 - 23.05.2014
what I replace "TIMEhere"?
Re : [HELP] Fuel -
yusei - 23.05.2014
Number ''15000''
Re: [HELP] Fuel -
monster010 - 23.05.2014
Код:
error 010: invalid function or declaration
LINE:
Re : [HELP] Fuel -
yusei - 23.05.2014
remove bracket
PHP код:
public CheckGas()
{
new string[256];
for (new i=0; i<=MAX_PLAYERS; i++) {
new vehicle = GetPlayerVehicleID(i);
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vehicle,engine,lights,alarm,doors,bonnet,boot,objective);
if(engine >= 1) {
if(Gas[vehicle] >= 1) {
format(string, sizeof(string), "~b~~n~~n~~n~~n~~n~~n~~n~~n~~n~Fuel:~w~ %d% %",Gas[vehicle]);
GameTextForPlayer(i,string,15500,3); }
Gas[vehicle]--;
}
else {
NoFuel[i] = 1;
TogglePlayerControllable(i, 0);
GameTextForPlayer(i,"~r~~n~~n~~n~~n~~n~~n~~n~~n~No fuel in Vehicle~n~Use /exit to leave the vehicle",1500,3);
}
}
return 1;
}
Re: [HELP] Fuel -
monster010 - 23.05.2014
SOLVED !
pawn Код:
public CheckGas()
{
new string[256];
for(new i=0;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
new vehicle = GetPlayerVehicleID(i);
if(Engine[vehicle] == 1)
{
if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
if(Gas[vehicle] >= 1)
{
if(Gas[vehicle] <= 10) { PlayerPlaySound(i, 1085, 0.0, 0.0, 0.0); }
if(gGas[i] == 1) {
format(string, sizeof(string), "",Gas[vehicle]);
GameTextForPlayer(i,string,15500,3); }
if(IsAPlane(vehicle) || IsABoat(vehicle) || IsABmx(vehicle)) { Gas[vehicle]++; }
Gas[vehicle]--;
}
else
{
NoFuel[i] = 1;
TogglePlayerControllable(i, 0);
GameTextForPlayer(i,"~r~~n~~n~~n~~n~~n~~n~~n~~n~No fuel in Vehicle~n~Use /exit to leave the vehicle",1500,3);
}
}
}
}
}
return 1;
}