Jump to content

Recommended Posts

Hello i need help. I'm trying to create a traffic light system but I can't make anything work. If anyone has anything already done or can help me, I'd appreciate it.

Share this post


Link to post
Share on other sites
/*
 File: trafficLights.sqf
*/

_1a1 = nearestObject [[8538.83,6580.55,0.0999994], "Land_E76_trafficlight02a"];
_1a2 = nearestObject [[8564.94,6599.19,0.0999994], "Land_E76_trafficlight02a"];
_1b1 = nearestObject [[8560.69,6576.75,0.0999994], "Land_E76_trafficlight02a"];
_1b2 = nearestObject [[8542.31,6603.25,0.0999994], "Land_E76_trafficlight02a"];

_2a1 = nearestObject [[8559.91,6702.75,0.0999994], "Land_E76_trafficlight02a"];
_2a2 = nearestObject [[8584.66,6711.34,0.0999994], "Land_E76_trafficlight02a"];
_2b1 = nearestObject [[8582.81,6698.59,0.0999994], "Land_E76_trafficlight03a"];
_2b2 = nearestObject [[8561.75,6715.16,0.0999994], "Land_E76_trafficlight03a"];

_3a1 = nearestObject [[8633.36,6689.42,0.0999994], "Land_E76_trafficlight02a"];
_3a2 = nearestObject [[8658.5,6698.38,0.0999994], "Land_E76_trafficlight02a"];
_3b1 = nearestObject [[8635.84,6702.06,0.0999994], "Land_E76_trafficlight03a"];
_3b2 = nearestObject [[8656.66,6685.59,0.0999994], "Land_E76_trafficlight03a"];

_4a1 = nearestObject [[8654.06,6808.72,0.0999994], "Land_E76_trafficlight02a"];
_4a2 = nearestObject [[8681.03,6826.94,0.0999994], "Land_E76_trafficlight02a"];
_4b1 = nearestObject [[8677.22,6803.5,0.0999994], "Land_E76_trafficlight02a"];
_4b2 = nearestObject [[8659.03,6830.69,0.0999994], "Land_E76_trafficlight02a"];

_5a1 = nearestObject [[3566.718,7536.303,0.0999994], "Land_E76_trafficlight02a"];
_5a2 = nearestObject [[3549.829,7560.835,0.0999994], "Land_E76_trafficlight02a"];
_5b1 = nearestObject [[3566.718,7536.303,0.0999994], "Land_E76_trafficlight02a"];
_5b2 = nearestObject [[3549.829,7560.835,0.0999994], "Land_E76_trafficlight02a"];

_6a1 = nearestObject [[3474.609,7607.043,0.0999994], "Land_E76_trafficlight02a"];
_6a2 = nearestObject [[3466.915,7628.361,0.0999994], "Land_E76_trafficlight02a"];
_6b1 = nearestObject [[3479.372,7630.38,0.0999994], "Land_E76_trafficlight02a"];
_6b2 = nearestObject [[3459.278,7609.513,0.0999994], "Land_E76_trafficlight02a"];

_7a1 = nearestObject [[8300.073,6360.755,0.0999994], "Land_E76_trafficlight02a"];
_7a2 = nearestObject [[8320.945,6368.557,0.0999994], "Land_E76_trafficlight02a"];
_7b1 = nearestObject [[8315.313,6356.344,0.0999994], "Land_E76_trafficlight02a"];
_7b2 = nearestObject [[8306.522,6375.654,0.0999994], "Land_E76_trafficlight02a"];

as = [_1a1,_1a2,_2a1,_2a2,_3a1,_3a2,_4a1,_4a2,_5a1,_5a2,_6a1,_6a2,_7a1,_7a2];//as on same
bs = [_1b1,_1b2,_2b1,_2b2,_3b1,_3b2,_4b1,_4b2,_5b1,_5b2,_6b1,_6b2,_7b1,_7b2];//bs on same

//beim start auf rot setzen bs
{
 _x animate ["switchred",0];
} foreach bs;

active = as;
lightSwitch = true;
counter = 0;

_lightLoop = {
 
 if(counter == 0) exitWith {
 {
 _x animate ["switchgreen",0];
 } foreach active;
 
 {
 _x animate ["switchred",1];
 } foreach active;
 counter = 3;
 };
 if(counter < 17 && {counter > 0}) exitWith {
 counter = counter + 3;
 };
 if(counter == 18) exitWith {
 {
 _x animate ["switchgreen",1];
 } foreach active;
 
 {
 _x animate ["switchyellow",0];
 } foreach active;
 counter = 21;
 };
 if(counter < 23 && {counter > 17}) exitWith {
 counter = counter + 3;
 };
 if(counter == 24) exitWith {
 {
 _x animate ["switchyellow",1];
 } foreach active;
 
 {
 _x animate ["switchred",0];
 } foreach active;
 counter = 27;
 };
 
 if(lightSwitch) then {
 active = bs;
 lightSwitch = false;
 } else {
 active = as;
 lightSwitch = true;
 };
 
 if(counter == 27) then {
 counter = 0;
 };
 
 if(isServer && {life_loopExit}) exitWith {
 [_this select 1] call CBA_fnc_removePerFrameHandler;
 as = nil;
 bs = nil;
 active = nil;
 lightSwitch = nil;
 counter = nil;
 [] remoteExecCall ["TON_fnc_trafficLights",hc_1];
 };
 if(isServer && {!isNil "hc_1"} && {!isNil "life_HC_isActive"} && {life_HC_isActive}) exitWith {
 [_this select 1] call CBA_fnc_removePerFrameHandler;
 life_loopExit = true;
 as = nil;
 bs = nil;
 active = nil;
 lightSwitch = nil;
 counter = nil;
 [] remoteExecCall ["TON_fnc_trafficLights",hc_1];
 };
};

[_lightLoop, 3, []] call CBA_fnc_addPerFrameHandler;

This is my code, but i dont know how to use it. I am trying to use e76 traffic lights.

Share this post


Link to post
Share on other sites
3 hours ago, Stephen Wozniak said:

This is my code, but i dont know how to use it. I am trying to use e76 traffic lights.

 

Well, if it is your code you should know how to use it  :D 

btw that script is made by "Steven Campbell"

 

 

Here is maybe more info about it.

https://www.altisliferpg.com/topic/4703-traffic-light-script-for-the-e76-traffic-lights/

(note for moderators: not promoting other forums ... )

 

You should post on some altis life forum, they will probably help you more than here.

 

 

Share this post


Link to post
Share on other sites
1 hour ago, M1ke_SK said:

 

Well, if it is your code you should know how to use it  :D 

btw that script is made by "Steven Campbell"

 

 

Here is maybe more info about it.

https://www.altisliferpg.com/topic/4703-traffic-light-script-for-the-e76-traffic-lights/

(note for moderators: not promoting other forums ... )

 

You should post on some altis life forum, they will probably help you more than here.

 

 

Well he ripped it off some altis life server, so it has to be his code, right?

Spoiler

Also curious how this should work:


 if(isServer && {life_loopExit}) exitWith {

:yay:

Cheers

  • Like 2

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×