SA-MP Forums Archive
Need help with "/engine" command - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Need help with "/engine" command (/showthread.php?tid=284545)



Need help with "/engine" command - wolfcock - 19.09.2011

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.


Re: Need help with "/engine" command - =WoR=G4M3Ov3r - 19.09.2011

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


Re: Need help with "/engine" command - wolfcock - 19.09.2011

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


Re: Need help with "/engine" command - =WoR=G4M3Ov3r - 19.09.2011

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.


Re: Need help with "/engine" command - Hiddos - 19.09.2011

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



Re: Need help with "/engine" command - Kingunit - 19.09.2011

[DELETED]


Re: Need help with "/engine" command - wolfcock - 19.09.2011

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);




Re: Need help with "/engine" command - GrimR - 20.09.2011

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).


Re: Need help with "/engine" command - GrimR - 20.09.2011

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


Re: Need help with "/engine" command - wolfcock - 20.09.2011

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