Pottyscotty Posted February 6, 2016 Report Share Posted February 6, 2016 I have a command that will turn on TLT_YELLOW however I want it so that it will not do so if the headlights are on, except I am not sure how to get about this. Basically if the command is activated when the headlights are also on, nothing will happen. However if the headlights are off and you activate the command, it will work. http://pastebin.com/yjNHHHW7 Quote Link to comment Share on other sites More sharing options...
bma Posted February 9, 2016 Report Share Posted February 9, 2016 I don't think there is a way for you to check if the headlights are enabled or not. Theese are all the possible light commands void EnableBlueLights(bool enable_); bool IsBlueLightEnabled() const; void EnableHeadLights(bool enable_); void EnableBreakLights(bool enable_); // aus Kombatibilitätsgründen noch da void EnableBrakeLights(bool enable_); bool IsBrakeLightEnabled() const; void EnableSpecialLights(bool enable_); bool IsSpecialLightEnabled() const; void EnableTrafficLight(TrafficLightType type_); void EnableBlinker(BlinkerLightType type_); BlinkerLightType GetBlinkerStatus() const; void SetLightEnabled(int id_, bool enable_); Quote Link to comment Share on other sites More sharing options...
Pottyscotty Posted February 9, 2016 Author Report Share Posted February 9, 2016 15 minutes ago, bma said: I don't think there is a way for you to check if the headlights are enabled or not. Theese are all the possible light commands void EnableBlueLights(bool enable_); bool IsBlueLightEnabled() const; void EnableHeadLights(bool enable_); void EnableBreakLights(bool enable_); // aus Kombatibilitätsgründen noch da void EnableBrakeLights(bool enable_); bool IsBrakeLightEnabled() const; void EnableSpecialLights(bool enable_); bool IsSpecialLightEnabled() const; void EnableTrafficLight(TrafficLightType type_); void EnableBlinker(BlinkerLightType type_); BlinkerLightType GetBlinkerStatus() const; void SetLightEnabled(int id_, bool enable_); Thanks, I was told the same somewhere else as well. One of the ways I was told I could do it was by getting the script to check the time and base it on that instead. Quote Link to comment Share on other sites More sharing options...
bma Posted February 9, 2016 Report Share Posted February 9, 2016 yeah that would be a good way to do it Do you need help trying to find it? Quote Link to comment Share on other sites More sharing options...
Pottyscotty Posted February 9, 2016 Author Report Share Posted February 9, 2016 2 minutes ago, bma said: yeah that would be a good way to do it Do you need help trying to find it? I'm not great at scripting at all and can only really edit basic things so yeah it would be a huge help! Quote Link to comment Share on other sites More sharing options...
bma Posted February 9, 2016 Report Share Posted February 9, 2016 Its on my desktop, ill send it next time im on it Quote Link to comment Share on other sites More sharing options...
bma Posted February 11, 2016 Report Share Posted February 11, 2016 //in the top of your script int Agerskov_hour; int Agerskov_minute; int Agerskov_second; //Just after void PushActions(GameObject *Caller, Actor *Target, int childID) { Game::GetTime(Agerskov_hour, Agerskov_minute, Agerskov_second); //Whereever you need it after Game::GetTimer if(Agerskov_hour > 7 && Agerskov_hour < 17 && Agerskov_minute == 0 && Agerskov_second < 4) Quote Link to comment Share on other sites More sharing options...
Pottyscotty Posted February 11, 2016 Author Report Share Posted February 11, 2016 Upon adding the second bit I get an error while loading the mod that says "Unrecognized Language". void PushActions(GameObject *Caller, Actor *Target, int childID) Game::GetTime(Agerskov_hour, Agerskov_minute, Agerskov_second); { Vehicle v(Caller); v.EnableTrafficLight(TLT_YELLOW); v.AssignCommand(CMD_WWTD_OFF); v.RemoveCommand(CMD_WWTD_ON); Audio::PlaySample3D(SND_TOGGLE, v.GetPosition()); } }; Quote Link to comment Share on other sites More sharing options...
bma Posted February 11, 2016 Report Share Posted February 11, 2016 void PushActions(GameObject *Caller, Actor *Target, int childID) { Game::GetTime(Agerskov_hour, Agerskov_minute, Agerskov_second); Vehicle v(Caller); v.EnableTrafficLight(TLT_YELLOW); v.AssignCommand(CMD_WWTD_OFF); v.RemoveCommand(CMD_WWTD_ON); Audio::PlaySample3D(SND_TOGGLE, v.GetPosition()); } }; Quote Link to comment Share on other sites More sharing options...
Pottyscotty Posted February 11, 2016 Author Report Share Posted February 11, 2016 59 minutes ago, bma said: I presume this isn't how to do an 'if' function either considering I get a different error (Symbol V not defined in current scope). I can't see anything different between mine and other if functions though apart from when they return false/true - Is this a requirement? void PushActions(GameObject *Caller, Actor *Target, int childID) { Game::GetTime(Agerskov_hour, Agerskov_minute, Agerskov_second); if(Agerskov_hour > 7 && Agerskov_hour < 17 && Agerskov_minute == 0 && Agerskov_second < 4) Vehicle v(Caller); v.EnableTrafficLight(TLT_YELLOW); v.AssignCommand(CMD_WWTD_OFF); v.RemoveCommand(CMD_WWTD_ON); Audio::PlaySample3D(SND_TOGGLE, v.GetPosition()); } }; Quote Link to comment Share on other sites More sharing options...
bma Posted February 11, 2016 Report Share Posted February 11, 2016 You take the Vehicle v (Caller); out of the if statement and put it beneeth "game::GetTime" and then you should change the if statement to something realistic the one i added was just to show some of the different elements Edit: dude you need to remeber {} around the code you want the if statement to include Quote Link to comment Share on other sites More sharing options...
Pottyscotty Posted February 11, 2016 Author Report Share Posted February 11, 2016 20 minutes ago, bma said: You take the Vehicle v (Caller); out of the if statement and put it beneeth "game::GetTime" and then you should change the if statement to something realistic the one i added was just to show some of the different elements Edit: dude you need to remeber {} around the code you want the if statement to include Told you I was terrible at this stuff It's not crashing now although it doesn't seem to want to activate no matter what the time of day is. Are you able to explain how the timing works as I'm not sure what values mean what. void PushActions(GameObject *Caller, Actor *Target, int childID) { Game::GetTime(Agerskov_hour, Agerskov_minute, Agerskov_second); Vehicle v(Caller); { if(Agerskov_hour > 7 && Agerskov_hour < 17 && Agerskov_minute == 0 && Agerskov_second < 4) v.EnableTrafficLight(TLT_YELLOW); v.AssignCommand(CMD_WWTD_OFF); v.RemoveCommand(CMD_WWTD_ON); Audio::PlaySample3D(SND_TOGGLE, v.GetPosition()); } } }; Quote Link to comment Share on other sites More sharing options...
bma Posted February 12, 2016 Report Share Posted February 12, 2016 if(Agerskov_hour > 7 && Agerskov_hour < 18) okay, lets take a basic lesson in if statements. && means AND and || means OR. your current if statement says: Agerskov_hour > 7 && Agerskov_hour < 17 && Agerskov_minute == 0 && Agerskov_second < 4 So what this means is that before the statement is true, all of the following criterias has to be true: - The hour has to be more than 7 - The hour has to be less than 17 - The minut has to be 0 - The second has to be less than 4 If just one of theese things are false it won't work. What you are looking for is proberly something like - Hour is more than 7 - Hour is less than 18 if(Agerskov_hour > 7 && Agerskov_hour < 18) Quote Link to comment Share on other sites More sharing options...
Pottyscotty Posted February 12, 2016 Author Report Share Posted February 12, 2016 Thanks for the explanation, all works perfectly! Quote Link to comment Share on other sites More sharing options...