Vice City: Multiplayer

Server Development => Scripting and Server Management => Snippet Showroom => Topic started by: [KM]Helathien on Jun 14, 2018, 09:17 AM

Title: Turning On Vehicle Lights with L key | Helathien
Post by: [KM]Helathien on Jun 14, 2018, 09:17 AM
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
Title: Re: Turning On Vehicle Lights with L key | Helathien
Post by: rww on Jun 14, 2018, 01:44 PM
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 ;)