Flashing lights! - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Flashing lights! (
/showthread.php?tid=634193)
Flashing lights! -
aoky - 14.05.2017
Hey! I just wanted to ask if it's possible to make it so when a player unlocks his car, that it sets the car lights on then off immediately - just to add a little flash effect on the vehicle lights.
Here is the code.
PHP код:
CMD:lock(playerid, params[])
{
new str[128], id = GetNearestVehicle(playerid, 15.0);
if(id != INVALID_VEHICLE_ID)
{
if (Vehicles[id][Owner] == Character[playerid][ID])
{
if(Vehicles[id][Locked] == 0) // IF IT ISNT LOCKED
{
SetVehicleParamsEx(id, Engine[id], Lights[id], alarm[id], 1, bonnet[id], boot[id], objective[id]);
doors[id] = 1;
PlayerPlaySound(playerid, 1053, 0.0, 0.0, 10.0);
GameTextForPlayer(playerid, "LOCKED", 2000, 4);
// Lock the vehicle status
Vehicles[id][Locked] = 1;
}
else if (Vehicles[id][Locked] == 1) // IF IT IS LOCKED
{
SetVehicleParamsEx(id, Engine[id], Lights[id], alarm[id], 0, bonnet[id], boot[id], objective[id]);
doors[id] = 0;
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 10.0);
GameTextForPlayer(playerid, "UNLOCKED", 2000, 4);
// Vehicle lights flash here once
// Unlock the vehicle status
Vehicles[id][Locked] = 0;
}
}
Thank you.
Re: Flashing lights! -
park4bmx - 14.05.2017
just run a timer, has to be quick timer i guess. to turn them on and off.. passing the vehicleID
Код:
forward FlashLights(vehicleid);
public FlashLights(vehicleid)
{
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(lights>0){
SetVehicleParamsEx(vehicleid, engine, 0, alarm, doors, bonnet, boot, objective);
}else{
SetVehicleParamsEx(vehicleid, engine, 1, alarm, doors, bonnet, boot, objective);
SetTimerEx("FlashLights", 800, false, "i", vehicleid);
}
}
something like that maybe ?
just use
FlashLights(vehicleid); to flash the lights