PDA

View Full Version : help with /light


Dan_Barocu
01/01/2012, 04:21 PM
Hello, i need help with the cmd /lights i want to open the lights even in the daytime i put this FS but only the front open lights not even the back!Sorry for bad english...im romanian..please help...i saw on some servers that u can turn on lights even on daytime..

http://pastebin.com/dFCs7Y5n

James Coral
01/01/2012, 04:27 PM
mhm...... i think its possible, i saw it in one server

Dan_Barocu
01/01/2012, 04:37 PM
please help mee....

Basssiiie
01/01/2012, 05:03 PM
#include <a_samp>
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

new bool: VehicleLightsOn[MAX_VEHICLES];

public OnPlayerStateChange(playerid, newstate, oldstate)
{
if (newstate == PLAYER_STATE_DRIVER)
{
if (VehicleLightsOn[GetPlayerVehicleID(playerid)] == false)
{
new engine, lights, alarm, doors, bonnet, boot, objective, vid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vid, engine, 0, alarm, doors, bonnet, boot, objective);
}
else
{
new engine, lights, alarm, doors, bonnet, boot, objective, vid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vid, engine, 1, alarm, doors, bonnet, boot, objective);
}
}
return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (PRESSED(KEY_ACTION))
{
if (IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if (VehicleLightsOn[GetPlayerVehicleID(playerid)] == false)
{
new engine, lights, alarm, doors, bonnet, boot, objective, vid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vid, engine, 1, alarm, doors, bonnet, boot, objective);
VehicleLightsOn[vid] = true;
}
else
{
new engine, lights, alarm, doors, bonnet, boot, objective, vid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vid, engine, 0, alarm, doors, bonnet, boot, objective);
VehicleLightsOn[vid] = false;
}
}
}
return 1;
}
That should work.

Dan_Barocu
01/01/2012, 05:05 PM
error .... error 017: undefined symbol "vid"

Basssiiie
01/01/2012, 05:05 PM
See the edit. ;) Should work now.

Dan_Barocu
01/01/2012, 05:09 PM
delete never mind :)

Mosslah
01/01/2012, 05:11 PM
Basssiiie's code:
#include <a_samp>
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

new bool: VehicleLightsOn[MAX_VEHICLES];

public OnPlayerStateChange(playerid, newstate, oldstate)
{
if (newstate == PLAYER_STATE_DRIVER)
{
if (VehicleLightsOn[GetPlayerVehicleID(playerid)] == false)
{
new engine, lights, alarm, doors, bonnet, boot, objective, vid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vid, engine, 0, alarm, doors, bonnet, boot, objective);
}
else
{
new engine, lights, alarm, doors, bonnet, boot, objective, vid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vid, engine, 1, alarm, doors, bonnet, boot, objective);
}
}
return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (PRESSED(KEY_ACTION))
{
if (IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if (VehicleLightsOn[GetPlayerVehicleID(playerid)] == false)
{
new engine, lights, alarm, doors, bonnet, boot, objective, vid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vid, engine, 1, alarm, doors, bonnet, boot, objective);
VehicleLightsOn[vid] = true;
}
else
{
new engine, lights, alarm, doors, bonnet, boot, objective, vid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vid, engine, 0, alarm, doors, bonnet, boot, objective);
VehicleLightsOn[vid] = false;
}
}
}
return 1;
}

You shouldn't get any errors with it, I compiled it fine.

Dan_Barocu
01/01/2012, 05:14 PM
i put this in the pawn :)) never mind how can i put it to work in daytime?....i mean i want to turn on lights at 10 am!

Mosslah
01/01/2012, 05:18 PM
It should work in the daytime, if you're in the vehicle and pressed the action key.

But by lights, you do mean vehicle headlights, yes? Or do you mean street-lights?

Basssiiie
01/01/2012, 05:18 PM
Put this under OnGameModeInit:
ManualVehicleEngineAndLights();
And change OnPlayerStateChange to this (because you have to start the engine too now):
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if (newstate == PLAYER_STATE_DRIVER)
{
if (VehicleLightsOn[GetPlayerVehicleID(playerid)] == false)
{
new engine, lights, alarm, doors, bonnet, boot, objective, vid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vid, 1, 0, alarm, doors, bonnet, boot, objective);
}
else
{
new engine, lights, alarm, doors, bonnet, boot, objective, vid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vid, 1, 1, alarm, doors, bonnet, boot, objective);
}
}
return 1;
}
And add this to turn the engine off after exiting. (Else you still hear the engine, which can be quite annoying)
public OnPlayerExitVehicle(playerid, vehicleid)
{
new engine, lights, alarm, doors, bonnet, boot, objective, vid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vid, 0, lights, alarm, doors, bonnet, boot, objective); // turn engine off after exiting the car
return 1;
}

Dan_Barocu
01/01/2012, 05:25 PM
i put these in pawn or in fs?

public OnPlayerStateChange(playerid, newstate, oldstate)
{
if (newstate == PLAYER_STATE_DRIVER)
{
if (VehicleLightsOn[GetPlayerVehicleID(playerid)] == false)
{
new engine, lights, alarm, doors, bonnet, boot, objective, vid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vid, 1, 0, alarm, doors, bonnet, boot, objective);
}
else
{
new engine, lights, alarm, doors, bonnet, boot, objective, vid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vid, 1, 1, alarm, doors, bonnet, boot, objective);
}
}
return 1;
}And add this to turn the engine off after exiting. (Else you still hear the engine, which can be quite annoying)

Code:
public OnPlayerExitVehicle(playerid, vehicleid)
{
new engine, lights, alarm, doors, bonnet, boot, objective, vid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vid, 0, lights, alarm, doors, bonnet, boot, objective); // turn engine off after exiting the car
return 1;
}

Basssiiie
01/01/2012, 05:27 PM
Doesn't matter if it's in one of your filterscripts or in your gamemode. :) As long as it is in one of your scripts which is loaded in the server.

Dan_Barocu
01/01/2012, 05:42 PM
yes but it work only if i type /engine i want the lights to work even if the /engine is off...and i want to type /veh lights twice to open and close lights please i dont know..

Dan_Barocu
01/01/2012, 06:06 PM
can someone help mee??????

Dan_Barocu
01/01/2012, 08:43 PM
Hel please i wait too much