Turning On Vehicle Lights with L key | Helathien

Started by [KM]Helathien, Jun 14, 2018, 09:17 AM

Previous topic - Next topic

[KM]Helathien

Using Keys to turn on vehicle Lights!

Hi there!
This is a easy tutorial, if you find any problems or bugs in this snippet feel free to PM me or Reply in the comments below :D.

First of all paste this onScriptLoad()
function onScriptLoad ( )
{
L <- BindKey(true, 0x4C, 0, 0);
print( "BindKey Loaded. Key by [KM]Helathien." )
}

After That Find This Function In your server function onKeyDown( player, key )
And Paste This here:
function onKeyDown( player, key )
{
if ( key == L )
{
if ( !player.Vehicle ) return 0;
else
{
local v = player.Vehicle;
if ( v.Lights == true )
{
v.Lights = false;
MessagePlayer( "[#00ff00][LIGHTS] [#ffffff]Vehicle lights turned off." , player )
}
else if ( v.Lights == false )
{
v.Lights = true;
MessagePlayer( "[#00ff00][LIGHTS] [#ffffff]Vehicle lights turned on." , player )
}
}
}
}

And there you go!
Just sit in any vehicle and press the "L" key and the lights will turn on!
Hope it helps.
Feel free to PM.
This idea came from this script request: https://forum.vc-mp.org/?topic=5273.0
Feel free to PM me for any help.
If I am not available on the forum come to VKs Official Server I am usually there.

rww

simplified ;)

function onKeyDown(player,key)
{
if (key == L)
{
local veh = player.Vehicle;
if (veh)
{
if (veh.Lights) veh.Lights = false;
else veh.Lights = true;
}
}
}

Without spam in chatbox ;)
Join to Irrelevant Club Discord: https://discord.gg/MsPPZ5uV4X