public OnGameModeInit()
{
ManualVehicleEngineAndLights();
}
//under on game mode init
ManualVehicleEngineAndLights();
//only if ur using dcmd
dcmd(lightson,8,cmdtext);
dcmd(lightsoff,9,cmdtext);
//defining
dcmd_lightson(playerid,params[])
{
#pragma unused params
new string[128];
new engine,lights,alarm,doors,bonnet,boot,objective;
new vid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
//checking if player is the driver
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
//checking if the lights are already on
if(lights == VEHICLE_PARAMS_ON)
{
SendClientMessage(playerid,COLOR_ERROR,"The lights are already on.");//change the color_error to the color you want make sure its defined
return 1;
}
//then the action of the lights being on
SetVehicleParamsEx(vid,engine,VEHICLE_PARAMS_ON,alarm,doors,bonnet,boot,objective);
for(new i=0; i<MAX_PLAYERS; i++)
{
if(GetDistanceBetweenPlayers(playerid,i) < 10)
{
format(string,sizeof(string),"%s(%d) twists a lever behind the steering wheel and turns on the lights.",PlayerName(playerid),playerid);
SendClientMessage(i,COLOR_LIGHTBLUE,string);
}
}
}
return 1;
}
dcmd_lightson(playerid,params[])
{
#pragma unused params
new string[128];
new engine,lights,alarm,doors,bonnet,boot,objective;
new vid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(lights == VEHICLE_PARAMS_ON)
{
SendClientMessage(playerid,COLOR_ERROR,"The lights are already on.");
return 1;
}
SetVehicleParamsEx(vid,engine,VEHICLE_PARAMS_ON,alarm,doors,bonnet,boot,objective);
for(new i=0; i<MAX_PLAYERS; i++)
{
if(GetDistanceBetweenPlayers(playerid,i) < 10)
{
format(string,sizeof(string),"%s(%d) twists a lever behind the steering wheel and turns on the lights.",PlayerName(playerid),playerid);
SendClientMessage(i,COLOR_LIGHTBLUE,string);
}
}
}
return 1;
}
//dont copy and paste just learn it its not the same as ur code so then you will come back crying about errors
//defining
dcmd_lightsoff(playerid,params[])
{
#pragma unused params
new string[128];
new engine,lights,alarm,doors,bonnet,boot,objective;
new vid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
//check if he is the driver
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
//check if the lightsare already off
if(lights == VEHICLE_PARAMS_OFF)
{
SendClientMessage(playerid,COLOR_ERROR,"The lights are already off.");
return 1;
}
//action of the lights being off
SetVehicleParamsEx(vid,engine,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
for(new i=0; i<MAX_PLAYERS; i++)
{
if(GetDistanceBetweenPlayers(playerid,i) < 10)
{
format(string,sizeof(string),"%s(%d) twists a lever behind the steering wheel and turns off the lights.",PlayerName(playerid),playerid);
SendClientMessage(i,COLOR_LIGHTBLUE,string);
}
}
}
return 1;
}
//so the full code
dcmd_lightsoff(playerid,params[])
{
#pragma unused params
new string[128];
new engine,lights,alarm,doors,bonnet,boot,objective;
new vid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(lights == VEHICLE_PARAMS_OFF)
{
SendClientMessage(playerid,COLOR_ERROR,"The lights are already off.");
return 1;
}
SetVehicleParamsEx(vid,engine,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
for(new i=0; i<MAX_PLAYERS; i++)
{
if(GetDistanceBetweenPlayers(playerid,i) < 10)
{
format(string,sizeof(string),"%s(%d) twists a lever behind the steering wheel and turns off the lights.",PlayerName(playerid),playerid);
SendClientMessage(i,COLOR_LIGHTBLUE,string);
}
}
}
return 1;
}
but i don't need the engine to start on or off
i have the engine but i need lights to go ON when it's day The lights are going ON when it's only Night How can i Fix that? |
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
if(engine == 0)
{
SetVehicleParamsEx(vid,1,lights,alarm,doors,bonnet,boot,objective);
}
}
}
CMD:lights(playerid, params[])
{
new engine,lights,alarm,doors,bonnet,boot,objective;
new vehicleid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(lights == 1)
{
lights = 0;
SendClientMessage(playerid, COLOR_WHITE,"You have turned the vehicle lights off.");
SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
}
else
{
lights = 1;
SendClientMessage(playerid, COLOR_WHITE,"You have turned the vehicle lights on.");
SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
}
return 1;
}
Adding ManualVehicleEngineAndLights will make a toggle for both the engine and lights, there's no way to just toggle to lights.
If you don't want a engine command, something simple like this should work: pawn Код:
pawn Код:
But you should get the point with it, if you want an engine command its just like the lights command. except change it to engine. |
public OnGameModeInit()
{
ManualVehicleEngineAndLights();
}