Problem with /lights command
#1

Hello guys.
I'm Benjamin Jones and I need some help.So I will discribe my problem.When I type /lights I they are working if the time is dark(Night).If it's day they doesn't work.If someone can help me will be really good.I just want to someone make it to work when is day and when is night ... 24 hours...Thank you.

If you help me, I will give you +1 Rep


if(strcmp(cmd, "/lights", true) == 0)
{
new v = GetPlayerVehicleID(playerid);
if(IsPlayerInAnyVehicle(playerid))
{
if(IsPlayerInAnyVehicle(playerid))
{
new seat = GetPlayerVehicleSeat(playerid);
if(seat != 0)
{
return 1;
}
}
if(LightsOn[v] == 0)
{
new engine, light, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(v, engine, light, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(v, engine, VEHICLE_PARAMS_ON, alarm, doors, bonnet, boot, objective);
LightsOn[v] = 1;
//SendClientMessage(playerid, GREY, "You have turned on the lights.");
format(string, sizeof(string), "* %s has turned on the lights.", PlayerName(playerid));
ProxDetector(30.0, playerid, string, PURPLE, PURPLE, PURPLE, PURPLE, PURPLE);
return 1;
}
else
{
new engine, light, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(v, engine, light, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(v, engine, VEHICLE_PARAMS_OFF, alarm, doors, bonnet, boot, objective);
LightsOn[v] = 0;
//SendClientMessage(playerid, GREY, "You have turned off the lights.");
format(string, sizeof(string), "* %s has turned off the lights.", PlayerName(playerid));
ProxDetector(30.0, playerid, string, PURPLE, PURPLE, PURPLE, PURPLE, PURPLE);
return 1;
}
}
return 1;
}
Reply
#2

Add this ManualVehicleEngineAndLights(); ongamemodeinit.
Reply
#3

Quote:
Originally Posted by lean1337
Посмотреть сообщение
Add this ManualVehicleEngineAndLights(); ongamemodeinit.
I gave you +1 rep but can you make the command with this because i'm not good scripter and I know how to do it.
Reply
#4

Someone can add help me because when I add it and try to compile it give me a error - error 021: symbol already defined: "ManualVehicleEngineAndLights" What I to do to fix it?
Reply
#5

You have it twice in your script, search for it and remove one.
Reply
#6

I cant find it "ManualVehicleEngineAndLights" ..... It's not twice in the script....
Reply
#7

Here is a zcmd /car (Status, Engine, Lights, Trunk, Hood, Fuel)
Код:
CMD:car(playerid, params[])
{
	if(isnull(params))
	{
		SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /car [name]");
		SendClientMessageEx(playerid, COLOR_GREY, "Available names: Status, Engine, Lights, Trunk, Hood, Fuel");
		return 1;
	}
	if(strcmp(params, "engine", true) == 0 && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
	{
		new engine,lights,alarm,doors,bonnet,boot,objective,vehicleid;
		new Float:X, Float:Y, Float:Z;
        new string[128];
		vehicleid = GetPlayerVehicleID(playerid);
		GetVehiclePos(vehicleid, X, Y, Z);
		if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510) return SendClientMessageEx(playerid,COLOR_WHITE,"This command can't be used in this vehicle.");
		GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
		if(VehicleBomb[vehicleid] == 1)
		{
			SendClientMessageEx(playerid, COLOR_GRAD2, "**Your engine had a bomb in the engine**");
			CreateExplosion(X, Y, Z, 7, 20);
			CreateExplosion(X, Y, Z, 2, 1);
		    format(string, sizeof(string), "%s has blown up due to the engine was wired with a bomb",GetPlayerNameEx(playerid));
		    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
		    VehicleBomb[vehicleid] = 0;
			return 1;
		}
		else
		{
			if(engine == VEHICLE_PARAMS_ON)
			{
				SetVehicleEngine(vehicleid, playerid);
				format(string, sizeof(string), "* %s has stopped his vehicle's engine",  GetPlayerNameEx(playerid));
	   			ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
			}
			else if((engine == VEHICLE_PARAMS_OFF || engine == VEHICLE_PARAMS_UNSET))
			{
				   SendClientMessageEx(playerid, COLOR_WHITE, "Vehicle engine starting, please wait...");
				   new rand = random(4);
			       if(rand == 0)
				   {
					   SetTimerEx("SetVehicleEngine", 1000, 0, "dd",  vehicleid, playerid);
					   SendClientMessage(playerid, COLOR_TWYELLOW, "Vehicle engine started");
			      	   format(string, sizeof(string), "* %s has turns the key in this ignition and the Engine Starts",  GetPlayerNameEx(playerid));
			 		   ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
			       }
				   if(rand == 1)
				   {
					   SendClientMessage(playerid, COLOR_TWYELLOW, "Vehicle engine failed to start, try restart vehicle engine!");
					   format(string, sizeof(string), "* %s struggles to start the engine but fails",  GetPlayerNameEx(playerid));
			 		   ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				   }
			       if(rand == 2)
				   {
					   SetTimerEx("SetVehicleEngine", 1000, 0, "dd",  vehicleid, playerid);
					   SendClientMessage(playerid, COLOR_TWYELLOW, "Vehicle engine started");
					   format(string, sizeof(string), "* %s has turns the key in this ignition and the Engine Starts",  GetPlayerNameEx(playerid));
			   		   ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				   }
				   if(rand == 3)
				   {
					   SetTimerEx("SetVehicleEngine", 1000, 0, "dd",  vehicleid, playerid);
					   SendClientMessage(playerid, COLOR_TWYELLOW, "Vehicle engine started");
			           format(string, sizeof(string), "* %s has turns the key in this ignition and the Engine Starts",  GetPlayerNameEx(playerid));
			 		   ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				   }
			}
		}
	}
	else if(strcmp(params, "lights", true) == 0 && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
	{
		new vehicleid = GetPlayerVehicleID(playerid);
		if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510) return SendClientMessageEx(playerid,COLOR_WHITE,"This command can't be used in this vehicle.");
		SetVehicleLights(vehicleid, playerid);
	}
	else if(strcmp(params, "hood", true) == 0 && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
	{
		if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
		{
			new vehicleid = GetPlayerVehicleID(playerid);
			if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510 || IsAPlane(vehicleid) || IsABike(vehicleid))
			{
				return SendClientMessageEx(playerid,COLOR_WHITE,"This command can't be used in this vehicle.");
			}
			SetVehicleHood(vehicleid, playerid);
		}
		else if(!IsPlayerInAnyVehicle(playerid))
		{
			new closestcar = GetClosestCar(playerid);
			if(IsPlayerInRangeOfVehicle(playerid, closestcar, 5.0))
			{
				if(GetVehicleModel(closestcar) == 481 || GetVehicleModel(closestcar) == 509 || GetVehicleModel(closestcar) == 510 || IsAPlane(closestcar) || IsABike(closestcar))
				{
					return SendClientMessageEx(playerid,COLOR_WHITE,"This command can't be used on this vehicle.");
				}
				SetVehicleHood(closestcar, playerid);
			}
		}
	}
	else if(strcmp(params, "trunk", true) == 0)
	{
		if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
		{
			new vehicleid = GetPlayerVehicleID(playerid);
			if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510)
			{
				return SendClientMessageEx(playerid,COLOR_WHITE,"This command can't be used in this vehicle.");
			}
			SetVehicleTrunk(vehicleid, playerid);
		}
		else if(!IsPlayerInAnyVehicle(playerid))
		{
			new closestcar = GetClosestCar(playerid);
			if(IsPlayerInRangeOfVehicle(playerid, closestcar, 5.0))
			{
				if(GetVehicleModel(closestcar) == 481 || GetVehicleModel(closestcar) == 509 || GetVehicleModel(closestcar) == 510)
				{
					return SendClientMessageEx(playerid,COLOR_WHITE,"This command can't be used on this vehicle.");
				}
				SetVehicleTrunk(closestcar, playerid);
			}
		}
	}
	else if(strcmp(params, "fuel", true) == 0 && IsPlayerInAnyVehicle(playerid))
	{
		if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 481 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 509 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 510) return SendClientMessageEx(playerid,COLOR_RED,"This vehicle doesn't need fuel.");
		if(GetPVarInt(playerid, "fuelonoff") == 0)
		{
			SendClientMessageEx(playerid, COLOR_WHITE, "You have turned on the fuel indicator (green bar).");
			SetPVarInt(playerid, "fuelonoff", 1);
			FuelBar[playerid] = CreateProgressBar(548.00, 26.00, 57.50, 3.20, 866792447, 100.0);
			textdrawscount++;
			SetProgressBarValue(FuelBar[playerid], VehicleFuel[GetPlayerVehicleID(playerid)]);
			ShowProgressBarForPlayer(playerid, FuelBar[playerid]);
		}
		else
		{
			SendClientMessageEx(playerid, COLOR_WHITE, "You have turned off the fuel indicator (green bar).");
			SetPVarInt(playerid, "fuelonoff", 0);
			DestroyProgressBar(FuelBar[playerid]);
			textdrawscount--;
			FuelBar[playerid] = INVALID_BAR_ID;
		}
	}
	else if(strcmp(params, "status", true) == 0)
	{
		if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
		{
			new vehicleid = GetPlayerVehicleID(playerid);
			new engine,lights,alarm,doors,bonnet,boot,objective,enginestatus[4],lightstatus[4], string[48];
			GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
			if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510) return SendClientMessageEx(playerid,COLOR_RED,"This vehicle doesn't need fuel.");
			if(engine != VEHICLE_PARAMS_ON) format(enginestatus, sizeof(enginestatus), "OFF");
			else format(enginestatus, sizeof(enginestatus), "ON");
			if(lights != VEHICLE_PARAMS_ON) format(lightstatus, sizeof(lightstatus), "OFF");
			else format(lightstatus, sizeof(lightstatus), "ON");
			format(string, sizeof(string), "Engine: %s | Lights: %s | Fuel: %.2f.",enginestatus,lightstatus,VehicleFuel[vehicleid]);
			SendClientMessageEx(playerid, COLOR_WHITE, string);
		}
	}
	return 1;
}
Reply
#8

Thank you but I need to fix my command please....Someone can help me?

+1 rep if you help
Reply
#9

Give that a try
pawn Код:
if(strcmp(cmd, "/lights", true) == 0)
{
    new vehicleid, engine,lights,alarm,doors,bonnet,boot,objective;
    vehicleid = GetPlayerVehicleID(playerid);
    GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
    if(!IsPlayerInAnyVehicle(playerid))
        return SendClientMessage(playerid, COLOR_SKYBLUE, "Error: You are not in a vehicle.");
    if(GetPlayerVehicleSeat(playerid) != 0)
        return SendClientMessage(playerid, COLOR_SKYBLUE, "Error: You are not in the drivers seat.");
    if(lights == 1)
    {
        SetVehicleParamsEx(vehicleid,engine,0,alarm,doors,bonnet,boot,objective);
    }
    else
    {
        SetVehicleParamsEx(vehicleid,engine,1,alarm,doors,bonnet,boot,objective);
    }
    return 1;
}
Reply
#10

Quote:
Originally Posted by DobbysGamertag
Посмотреть сообщение
Give that a try
pawn Код:
CMD:lights(playerid,params[])
{
    new vehicleid, engine,lights,alarm,doors,bonnet,boot,objective;
    vehicleid = GetPlayerVehicleID(playerid);
    GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
    if(!IsPlayerInAnyVehicle(playerid))
        return SendClientMessage(playerid, COLOR_SKYBLUE, "Error: You are not in a vehicle.");
    if(GetPlayerVehicleSeat(playerid) != 0)
        return SendClientMessage(playerid, COLOR_SKYBLUE, "Error: You are not in the drivers seat.");
    if(lights == 1)
    {
        SetVehicleParamsEx(vehicleid,engine,0,alarm,doors,bonnet,boot,objective);
    }
    else
    {
        SetVehicleParamsEx(vehicleid,engine,1,alarm,doors,bonnet,boot,objective);
    }
    return 1;
}
I cant use that because it's CMD: That's YNI I think...So I cant use it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)