Need help with "/engine" command
#1

Hey all.
I have an Role Play server, won't go further into details and It has a bug with "/engine" command.
I can start it, then stop it, and when i have Stopped it once, i get this message: "NAME - spins a key and turns off the engine." And when i try "/engine" again, i get same comment, and i'm stuck, how can i fix this? the code is below:

Quote:

if(!strcmp(cmd, "/engine", true))
{
if(IsPlayerConnected(playerid))
{
if(IsPlayerInAnyVehicle(playerid))
{
if(!engineOn[GetPlayerVehicleID(playerid)])
{
if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return 1;
if(pveh == 510 || pveh == 462 || pveh == 481 || pveh == 509) return 1;
if(IsARentableCar(idcar))
{
if(HireCar[playerid] != idcar) return 1;
}
if(IsAHarvest(idcar)) return 1;
if(IsADrugHarvest(idcar)) return 1;
if(IsASweeper(idcar)) return 1;


if(CanTurnEngine[playerid] != idcar && CanTurnEngine[playerid] == 9999)
return SendClientMessage(playerid, COLOR_GREY,"* You cannot turn this car's engine!");

format(string, sizeof(string), "* %s spins a key and tries to start vehicle engine.", sendername);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPL E,COLOR_PURPLE);
SetTimerEx("StartingTheVehicle",3500,0,"i",playeri d);
gEngine[playerid] = 1;
new y, m, d;
new h,mi,s;
getdate(y,m,d);
gettime(h,mi,s);
format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s [CMD] -> /engine",d,m,y,h,mi,s,sendername);
CommandLog(string);
return 1;
}
else if(engineOn[GetPlayerVehicleID(playerid)])
{
if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return 1;
if(pveh == 510 || pveh == 462 || pveh == 481 || pveh == 509) return 1;
if(IsARentableCar(idcar))
{
if(HireCar[playerid] != idcar) return 1;
}
if(IsAHarvest(idcar)) return 1;
if(IsADrugHarvest(idcar)) return 1;
if(IsASweeper(idcar)) return 1;

if(CanTurnEngine[playerid] != idcar && CanTurnEngine[playerid] == 9999)
return SendClientMessage(playerid, COLOR_GREY,"* You cannot turn this car's engine!");

format(string, sizeof(string), "* %s spins a key and turns off the engine.", sendername);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPL E,COLOR_PURPLE);
SafeRemovePlayerFromVehicle(playerid);
TextDrawHideForPlayer(playerid, Textdraw39[playerid]);
TextDrawHideForPlayer(playerid, Textdraw40[playerid]);
TextDrawHideForPlayer(playerid, Textdraw53[playerid]);
gEngine[playerid] = 0;
TogglePlayerControllable(playerid, 0);
new y, m, d;
new h,mi,s;
getdate(y,m,d);
gettime(h,mi,s);
format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s [CMD] -> /engine",d,m,y,h,mi,s,sendername);
CommandLog(string);
return 1;
}
}
}
return 1;
}

It compiles with no errors.
Reply
#2

I had this kind of problem, did you try using /engine when it gets stuck, use /engine 2 more times, I believe it'll work
Reply
#3

Are you sure? i cannot try right now, but in a few mins
Reply
#4

Quote:
Originally Posted by wolfcock
Посмотреть сообщение
Are you sure? i cannot try right now, but in a few mins
Just try it, Because I don't see anything wrong with the code.
Reply
#5

I'm wondering what this 'idcar' variable is, and I'm wondering what this does:
pawn Код:
if(CanTurnEngine[playerid] != idcar && CanTurnEngine[playerid] == 9999)
Reply
#6

[DELETED]
Reply
#7

Quote:
Originally Posted by Hiddos
Посмотреть сообщение
I'm wondering what this 'idcar' variable is, and I'm wondering what this does:
pawn Код:
if(CanTurnEngine[playerid] != idcar && CanTurnEngine[playerid] == 9999)
I think that does mean that the vehicle doesn't have an engine, like a Bi-cycle.
Also here is the Variable:


Quote:

new idcar = GetPlayerVehicleID(playerid);

Reply
#8

Hello,

You need to remove:

TogglePlayerControllable(playerid, 0);

This is what stop you from doing anything once you turn the engine off.

If you look below /engine, there is /st and /tn which is basically what is setup to enter/exit vehicle and turn on and off, I don't know why, it's a stupid idea so just comment those 2 out or remove, and change the engineOn to True in the first conditional of /engine and to False in the second part (the full engineOn code is within those /st and /tn commands code).
Reply
#9

That however doesn't completely fix it, it creates a different issues, not sure why though.
Reply
#10

@GrimR - That makes a new bug, then the will still be able to Drive.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)