/lights command for vehicles -
Hussain - 21.03.2013
I was in-need of a command that will turn on a players lights for my RP server
so i've decieded to release it
Код:
#include <a_samp>
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_RED 0xAA3333AA
new VehicleLights[MAX_VEHICLES];
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/lights", cmdtext, true, 10) == 0)
{
new vehicleid, engine, lights, alarm, doors, bonnet, boot, objective;
if(!IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid, COLOR_RED, "You aren't in a vehicle");
return 1;
}
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
vehicleid = GetPlayerVehicleID(playerid);
if(VehicleLights[vehicleid] == 0)
{
VehicleLights[vehicleid] = 1;
SendClientMessage(playerid, COLOR_YELLOW, "Lights Turned On");
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid, engine, true, alarm, doors, bonnet, boot, objective);
}
else if(VehicleLights[vehicleid] == 1)
{
VehicleLights[vehicleid] = 0;
SendClientMessage(playerid, COLOR_YELLOW, "Lights Turned Off");
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid, engine, false, alarm, doors, bonnet, boot, objective);
}
}
return 1;
}
return 0;
}
Re: /lights command for vehicles -
mgd - 21.03.2013
Screen shots ?
Re: /lights command for vehicles -
Yves - 21.03.2013
Quote:
Originally Posted by mgd
Screen shots ?
|
you wont need a photo of it!
nice work great for new players with scripting
Re: /lights command for vehicles -
Jamixd1 - 22.03.2013
ahh 7/10
Re: /lights command for vehicles -
Pottus - 22.03.2013
Just one thing here it should look like this.
Код:
#include <a_samp>
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_RED 0xAA3333AA
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp("/lights", cmdtext, true, 10))
{
if(IsPlayerInAnyVehicle(playerid))
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new vehicleid, engine, lights, alarm, doors, bonnet, boot, objective;
vehicleid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(lights)
{
SendClientMessage(playerid, COLOR_YELLOW, "Lights Turned Off");
SetVehicleParamsEx(vehicleid, engine, false, alarm, doors, bonnet, boot, objective);
}
else
{
SendClientMessage(playerid, COLOR_YELLOW, "Lights Turned On");
SetVehicleParamsEx(vehicleid, engine, true, alarm, doors, bonnet, boot, objective);
}
}
else SendClientMessage(playerid, COLOR_RED, "You are not the driver");
}
else SendClientMessage(playerid, COLOR_RED, "You aren't in a vehicle");
return 1;
}
return 0;
}
Now we eliminated the need for VehicleLights[] variable and also created a nice flow in the code for readability.
Re: /lights command for vehicles -
EiresJason - 22.03.2013
Thanks man, i reworked it slightly so that it works for zCMD though.