Jump to content
Ghost Graphic Designs

Script: lights don't turn off

Recommended Posts

Hi. 

 

I'm using this script to turn the headlights (set as Special Light) on and off (just like the flashing lights script, for example). The thing is that I can only turn the lights on and when I click on the script again, the lights stay turned on.

 

Any idea of what I'm doing wrong here?

 

Here's the script:


const char IMG[] = "Headlights";

const char DUMMY_HASBELICHTING[] = "DUMMYHasBelichting";

int DummyGroup = 20;

// 1.0
object Headlights : CommandScript
{
Headlights()
{
SetIcon("Headlights");
SetCursor("Headlights");
SetRestrictions(RESTRICT_SELFEXECUTE);
}

bool CheckPossible(GameObject *Caller)
{
if (!Caller->IsValid())
return false;

if (Caller->GetType() == ACTOR_VEHICLE)
{
return true;
}

return false;
}

bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
{
if (!Caller->IsValid() || !Target->IsValid() || Target->GetID() != Caller->GetID())
return false;

if (Caller->GetType() == ACTOR_VEHICLE)
{
return true;
}

return true;
}

void PushActions(GameObject *Caller, Actor *Target, int childID)
{
Vehicle v(Caller);

if (v.HasCommand(DUMMY_HASBELICHTING))
{
v.EnableSpecialLights(false);
v.RemoveCommand(DUMMY_HASBELICHTING);
} else if (!v.HasCommand(DUMMY_HASBELICHTING))
{
v.EnableSpecialLights(true);
v.AssignCommand(DUMMY_HASBELICHTING);
}
}
};

 
Link to comment
Share on other sites

The script should technically work, but you probably didn't add a dummy commandscript with the name "DUMMYHasBelichting"?

If the vehicle does NOT have that dummycommand, the script will turn the lights on. That part seems to work. It's also trying to add the dummy command. If the scripts finds that dummy command, it will turn the lights off. For some reason the script probably cannot find the added dummy command, because it is non existant. That's my guess. The script is running in a loop now and keeps trying to enable the lights and add a command that probably doesn't exist.

Check the logfile, it should mention it if a certain commandscript cannot be found.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...