How to add command to manually turn my vehicle's lights on?
#1

How do I add a cmd to turn on a vehicle's light manually on SAMP 0.3.7?
Reply
#2

Code i have for it.
Код:
CMD:lights(playerid,params[])
{
	new string[124];
	new vehicleid = GetPlayerVehicleID(playerid);

    GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
    if(GetPlayerState(playerid) == 2)
    {
		if(lights != 1)
		{
			SetVehicleParamsEx(vehicleid, engine, 1, alarm, doors, bonnet, boot, 0);
	  		format(string, sizeof(string), "* %s turns the lights on.", GetName(playerid));
	  		ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
		}
		else if(lights != 0)
		{
			SetVehicleParamsEx(vehicleid, engine, 0, alarm, doors, bonnet, boot, 0);
			format(string, sizeof(string), "* %s turns the lights off.", GetName(playerid));
	  		ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
		}
	}
	return 1;
}
Reply
#3

https://sampwiki.blast.hk/wiki/SetVehicleParamsEx
Reply
#4

Quote:
Originally Posted by alexkeward
Посмотреть сообщение
Code i have for it.
Код:
CMD:lights(playerid,params[])
{
	new string[124];
	new vehicleid = GetPlayerVehicleID(playerid);

    GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
    if(GetPlayerState(playerid) == 2)
    {
		if(lights != 1)
		{
			SetVehicleParamsEx(vehicleid, engine, 1, alarm, doors, bonnet, boot, 0);
	  		format(string, sizeof(string), "* %s turns the lights on.", GetName(playerid));
	  		ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
		}
		else if(lights != 0)
		{
			SetVehicleParamsEx(vehicleid, engine, 0, alarm, doors, bonnet, boot, 0);
			format(string, sizeof(string), "* %s turns the lights off.", GetName(playerid));
	  		ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
		}
	}
	return 1;
}
Should I put that in my gamemode?
Reply
#5

Quote:
Originally Posted by Gorgeousmaniac
Посмотреть сообщение
Should I put that in my gamemode?
If you believe it will work yes.
Reply
#6

Quote:
Originally Posted by alexkeward
Посмотреть сообщение
If you believe it will work yes.
Is the callback OnPlayerCommandText still needed?
Reply
#7

Quote:
Originally Posted by Gorgeousmaniac
Посмотреть сообщение
Is the callback OnPlayerCommandText still needed?
What callback?
Reply
#8

No, it isn't needed.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)