SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 27/10/2019, 10:06 AM   #1
Proxus
Huge Clucker
 
Proxus's Avatar
 
Join Date: May 2018
Location: United Kingdom
Posts: 363
Reputation: 17
Default Make vehicle lights come on at night, off at day

The title basically says it all.
I may be dumb, but I thought SAMP did it by default and that the only function preventing it was 'ManualVehicleEngineAndLights'

Any help is appreciated.
__________________
Developer @ Trucknation
Administrator & Developer @ Lost Legacy
"Never tell people how to do things. Tell them what to do and they will surprise you with their ingenuity"


IMPORTANT LINKS
Proxus is offline   Reply With Quote
Old 27/10/2019, 10:51 AM   #2
MP2
Godfather
 
MP2's Avatar
 
Join Date: Jan 2011
Location: England
Posts: 6,230
Reputation: 993
Default Re: Make vehicle lights come on at night, off at day

Do you already have a system to track and sync time between players?
__________________
Click banner above for more info. View trailers here.
Enter referral code SAMPFORUM after registering for a $5000 starting bonus!
MP2 is offline   Reply With Quote
Old 27/10/2019, 10:55 AM   #3
Kane
Gangsta
 
Kane's Avatar
 
Join Date: Sep 2012
Posts: 814
Reputation: 125
Default Re: Make vehicle lights come on at night, off at day

Automatically or when a player toggles vehicle lights on?
__________________
Los Santos Roleplay - Developer
@ls-rp.com

Former Beta Tester
Kane is offline   Reply With Quote
Old 27/10/2019, 11:03 AM   #4
Proxus
Huge Clucker
 
Proxus's Avatar
 
Join Date: May 2018
Location: United Kingdom
Posts: 363
Reputation: 17
Default Re: Make vehicle lights come on at night, off at day

Quote:
Originally Posted by Kane View Post
Automatically or when a player toggles vehicle lights on?
Automatically. When it turns dark, it should turn the lights on and when it turns light, it should turn the lights off.

Quote:
Originally Posted by MP2 View Post
Do you already have a system to track and sync time between players?
Nope.
__________________
Developer @ Trucknation
Administrator & Developer @ Lost Legacy
"Never tell people how to do things. Tell them what to do and they will surprise you with their ingenuity"


IMPORTANT LINKS
Proxus is offline   Reply With Quote
Old 28/10/2019, 11:41 AM   #5
MP2
Godfather
 
MP2's Avatar
 
Join Date: Jan 2011
Location: England
Posts: 6,230
Reputation: 993
Default Re: Make vehicle lights come on at night, off at day

If you want to synchronise time between players you need a 1 second repeating timer to increase the time stored in variables. You can then set a players time when they spawn and every few minutes to keep it in sync. Use TogglePlayerClock to enable the clock and slow-transitioning interpolated weather.

Now you’re tracking the time server-side you can easily detect when the time reaches your predetermined ‘dark’ time (8/9pm?) and loop through all players that are driving a vehicle and turn their vehicle lights on with SerVehicleParamsEx. Same for when it gets light (6am?).
__________________
Click banner above for more info. View trailers here.
Enter referral code SAMPFORUM after registering for a $5000 starting bonus!
MP2 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Tutorial] How to make simple vehicle lights system haikalbintang Tutorials 10 18/02/2017 10:16 AM
Car lights looks only at night Omirrow Scripting Help 2 13/03/2013 07:53 PM
Lights day |||| Lights night PaulDinam Scripting Help 5 27/06/2012 07:14 AM
slowely make it night lewismichaelbbc Scripting Help 1 14/06/2012 06:50 PM
Car lights Only work at night? HondaCBR Scripting Help 4 20/11/2011 01:31 PM


All times are GMT. The time now is 03:31 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.