31.01.2017, 01:02
(
Last edited by haikalbintang; 16/02/2017 at 11:59 PM.
Reason: Edit serveral information.
)
Selamat Pagi Semuanya (Good Morning All)
Today i be showing you guys an tutorial to make simple vehicle lights system.
I dunno if this tutorial will helpful or not, but i want to help you guys if you don't know about it xD
So, the first thing you need to do is add ManualVehicleEngineAndLights(); in OnGameModeInit for example like this :
Why must we add ManualVehicleEngineAndLights(); ?
That's function make every vehicle (except bicycle), turn on engine & lights manually.
Done? Not yet, now you need to make a function to turn on the lights.
What function should we add? Ok, first thing you need to do is GetVehicleParamsEx, and also an variable example like this :
So what is GetVehicleParamsEx is? A function to check vehicle information like engine, lights, alarm, doors any many more. After you GetVehicleParamsEx, you need to check if the vehicle turn on / not.
VEHICLE_PARAMS_ON it's mean if the lights turn on, also VEHICLE_PARAMS_OFF it's mean if the lights turn off. What about the VEHICLE_PARAMS_UNSET? that mean if the lights is not set.
Now we need to add an function to turn on / off the lights with SetVehicleParamsEx.
Now the CMD to turn on / off the lights, before turning the lights, we need to check the player in vehicle and also check the vehicle information too.
Almost finish, now you need add a function when player in vehicle. But 1 problem is, bicycle doesn't have lights. So we need to check are the player is not using bike.
What is 481, 509, and 510? It's a BMX, Mountain Bike and Bike they all don't have lights.
After check the vehicle model, time to add the VehicleLights function.
Don't forget to add and clientmessage if player using bike.
Ok, maybe just that it's really simple. I dunno if this a tutorial or not, but i hope this will help you. Thanks
Today i be showing you guys an tutorial to make simple vehicle lights system.
I dunno if this tutorial will helpful or not, but i want to help you guys if you don't know about it xD
So, the first thing you need to do is add ManualVehicleEngineAndLights(); in OnGameModeInit for example like this :
PHP Code:
public OnGameModeInit()
{
ManualVehicleEngineAndLights();
//another function
return 1;
}
That's function make every vehicle (except bicycle), turn on engine & lights manually.
Done? Not yet, now you need to make a function to turn on the lights.
Code:
forward VehicleLights(playerid, vehicleid);
PHP Code:
public VehicleLights(playerid, vehicleid)
{
return 1;
}
PHP Code:
public VehicleLights(playerid, vehicleid)
{
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
return 1;
}
PHP Code:
public VehicleLights(playerid, vehicleid)
{
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(lights == VEHICLE_PARAMS_ON)
{
}
else if(lights == VEHICLE_PARAMS_OFF || lights == VEHICLE_PARAMS_UNSET)
{
}
return 1;
}
Now we need to add an function to turn on / off the lights with SetVehicleParamsEx.
PHP Code:
public VehicleLights(playerid, vehicleid)
{
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(lights == VEHICLE_PARAMS_ON)
{
SetVehicleParamsEx(vehicleid, engine, VEHICLE_PARAMS_OFF, alarm, doors, bonnet, boot, objective);
SendClientMessage(playerid, COLOR_LIGHTYELLOW, "Vehicle light turned off.");
}
else if(lights == VEHICLE_PARAMS_OFF || lights == VEHICLE_PARAMS_UNSET)
{
SetVehicleParamsEx(vehicleid, engine, VEHICLE_PARAMS_ON, alarm, doors, bonnet, boot, objective);
SendClientMessage(playerid, COLOR_LIGHTYELLOW, "Vehicle light turned on.");
}
return 1;
}
PHP Code:
CMD:lights(playerid, params[])
{
new vehicleid = GetPlayerVehicleID(playerid);
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(IsPlayerInAnyVehicle(playerid))
{
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You are not in any vehicle.");
}
return 1;
}
PHP Code:
CMD:lights(playerid, params[])
{
new vehicleid = GetPlayerVehicleID(playerid);
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(IsPlayerInAnyVehicle(playerid))
{
if(GetVehicleModel(vehicleid) != 481 || GetVehicleModel(vehicleid) != 509 || GetVehicleModel(vehicleid) != 510)
{
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You are not in any vehicle.");
}
return 1;
}
After check the vehicle model, time to add the VehicleLights function.
PHP Code:
CMD:lights(playerid, params[])
{
new vehicleid = GetPlayerVehicleID(playerid);
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(IsPlayerInAnyVehicle(playerid))
{
if(GetVehicleModel(vehicleid) != 481 || GetVehicleModel(vehicleid) != 509 || GetVehicleModel(vehicleid) != 510)
{
VehicleLights(playerid, vehicleid);
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You are not in any vehicle.");
}
return 1;
}
PHP Code:
CMD:lights(playerid, params[])
{
new vehicleid = GetPlayerVehicleID(playerid);
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(IsPlayerInAnyVehicle(playerid))
{
if(GetVehicleModel(vehicleid) != 481 || GetVehicleModel(vehicleid) != 509 || GetVehicleModel(vehicleid) != 510)
{
VehicleLights(playerid, vehicleid);
}
else
{
SendClientMessage(playerid, COLOR_GREY, "This vehicle doesn't have lights.");
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You are not in any vehicle.");
}
return 1;
}