Still need help with GM Vehicle engine script
#1

If anyone can please help me, I have asked this about three times. And everytime I never get a proper answer. I need someone to fix this GM engine script. The problem is the engine doesn't restart after it's shutdown, the other problem is that it freezes the player in the car when shutdown and doesn't allow them to get out.
Please post the fixed version here... I really need help... please...


Код:
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_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
					SetTimerEx("StartingTheVehicle",3500,0,"i",playerid);
					GameTextForPlayer(playerid, "~w~Starting vehicle engine...",3500,3);
					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_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
					GameTextForPlayer(playerid, "~w~Engine Shat Down.",3500,3);
					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;
	}
PS: If someone can make it that when the engine is turned off it actually looks off (engine sound off and exhaust stops), that would be great!

Thanks so much to anyone who can fix it: jakejohnsonusa
Reply
#2

You need to use https://sampwiki.blast.hk/wiki/SetVehicleParamsEx
Reply
#3

I think it's there... but I am not a scripter and have no idea how to fix this... please post a fixed code.
-Thanks for the help though +1 Rep.
Reply
#4

I just scanned your code, (due to I'm not in my full concentrate)

to fix the other problem (freeze of players problem) is

change this:

PHP код:
TogglePlayerControllable(playerid0); 
into this:
PHP код:
TogglePlayerControllable(playerid1); 
Edit: Check this for list of sounds
Reply
#5

Ok thanks, as for the rest of the problems... Doesn't restart and looks like it's on...?
Reply
#6

Anyone, please. I really need this fixed.
Reply
#7

From what I'm getting this should work. Good luck.

Код:
	if(!strcmp(cmd, "/engine", true))
	{
 		new engine, lights, alarm, doors, bonnet, boot, objective;
	    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_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
					SetTimerEx("StartingTheVehicle",3500,0,"i",playerid);
					GameTextForPlayer(playerid, "~w~Starting vehicle engine...",3500,3);
					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);
					SetVehicleParamsEx(GetPlayerVehicleID(playerid), 1, lights, alarm, doors, bonnet, boot, objective);
					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_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
					GameTextForPlayer(playerid, "~w~Engine Shut Down.",3500,3);
					gEngine[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);
     				SetVehicleParamsEx(GetPlayerVehicleID(playerid), 0, lights, alarm, doors, bonnet, boot, objective);
					return 1;
				}
			}
	    }
	    return 1;
	}
Reply
#8

Ok, so the problem was that this script FREEZES the player in off cars, instaed of turning the ENGINE OFF. I have a personally made FS, that fixes this problem... but I need it in my gamemode to replace this. Would anyone be willing to convert a FS into a GM script?

Also Socan +1 for the help!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)