timmiej93 Posted August 17, 2014 Report Share Posted August 17, 2014 Hey guys, So I'm trying to control a gate that comes with the game (stated below), as if it is a fire station gate. So I'd have a button on a controlpanel to open the gate and one to close it. The current setup I have is: 2 of these gates, 1 fire station gate, for testing purposes. I've got the script pretty much done, and the fire station gate works, but the Industry gate refuses to do anything.The industry gate btw is one of those gates that work when you place a trigger over it, and give both the trigger and the gate the same name. mod:Prototype/Objects/Fences/industryfence03Industry Fence 03 Animatedfor(int i=0; i < gate01e.GetNumObjects(); i++){ GameObject *gate = gate01e.GetObject(i); Actor *vogate = vogate01e.GetActor(i); if (gate->GetUserData() == 0) { gate->SetUserData(1); gate->SetAnimation(ANI_OPEN); vogate->SetVirtualObjectTerrain(VOSET_ROAD); }}I believe it has something to do with this piece of code, especially the FOR statement. I think this statement never returns a true value. I've tested it with a Mission::PlayHint and a System::Log right behind the GameObject *gate statement, but those never showed up, not ingame, not in the log. Does anyone know why this could be happening and how I can solve this? I'd love to be able to control the gates. Quote Link to comment Share on other sites More sharing options...
sniper3369 Posted August 18, 2014 Report Share Posted August 18, 2014 The script logic you presented above is fine. But I need to see where it is located in the script and I also need to know which command you are using to open the doors. Give it a shot. I'm not sure that it is possible to do with that gate but I don't see why not. Worse comes to worse feel free to send it over I will take a peek when I can. I am assuming your using VcmdGarageDoorsUp and VcmdGarageDoorsDown defined in the LAFireStation script. If so you will see something these under the respective Vcmds if(Caller->HasName(NAME_CONTROLPANEL)) //= fire station 1 Caller->PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 1, false); else if(Caller->HasName(NAME_CONTROLPANEL2)) //= fire station 2 Caller->PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 3, false); else if(Caller->HasName(NAME_CONTROLPANEL3)) //= fire station 3 Caller->PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 5, false); else if(Caller->HasName(NAME_CONTROLPANEL3)) //= fire station 4 Caller->PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 7, false); Make sure you defined the gate under the correct child under DummyGates.In the examples above and below when you put them together when VcmdGarageDoorsUp is activated on CONTROLPANEL3 it will open gates gate07a and gate08a. if(ChildID == 5) //= Open front gates fire station 3 { for(int i=0; i < gate07a.GetNumObjects(); i++) { GameObject *gate = gate07a.GetObject(i); Actor *vogate = vogate07a.GetActor(i); if (gate->GetUserData() == 0) { gate->SetUserData(1); gate->SetAnimation(ANI_OPEN); vogate->SetVirtualObjectTerrain(VOSET_ROAD); } } for(int i=0; i < gate08a.GetNumObjects(); i++) { GameObject *gate = gate08a.GetObject(i); Actor *vogate = vogate08a.GetActor(i); if (gate->GetUserData() == 0) { gate->SetUserData(1); gate->SetAnimation(ANI_OPEN); vogate->SetVirtualObjectTerrain(VOSET_ROAD); } } } Quote Link to comment Share on other sites More sharing options...
timmiej93 Posted August 18, 2014 Author Report Share Posted August 18, 2014 Well actually, I went a bit further then that, I created a new command for it, and added it to the controlpanel at the techstation. I added these commands to a bit of script that is WIP, so I haven't included the top section, but everything is characterized(?).As I said, I have a loose fire station gate to test if the script works, which is gate 3e. This has no VO to block it, since it's just a test gate.Maybe you can test the gates for yourself, if they can be moved manually, I really can't get them to work unfortunately. Here's the entire script that's about the gates:object VcmdTechGatesOpen : CommandScript{ VcmdTechGatesOpen() { SetCursor("garagedoorup"); SetIcon("garagedoorup"); } bool CheckPossible(GameObject *Caller) { if (!Caller->IsValid()) return false; if (!Game::IsFreeplay() && !Game::IsMultiplayer()) return false; Vehicle v(Caller); if (v.HasCommand(DUMMY_ALARM)) return false; return true; } bool CheckTarget(GameObject *Caller, Actor *Target, int childID) { if (!Caller->IsValid() || !Target->IsValid() || (Caller->GetID() != Target->GetID())) return false; return true; } void PushActions(GameObject *Caller, Actor *Target, int ChildID) { if(Caller->HasName(NAME_CONTROLPANEL4)) //= Tech Station Caller->PushActionExecuteCommand(ACTION_NEWLIST, DUMMY_TECHGATES, Caller, 1, false); else Mission::Playhint("Which gates should open then?"); return; }};object VcmdTechGatesClose : CommandScript{ VcmdTechGatesClose() { SetCursor("garagedoordown"); SetIcon("garagedoordown"); } bool CheckPossible(GameObject *Caller) { if (!Caller->IsValid()) return false; if (!Game::IsFreeplay() && !Game::IsMultiplayer()) return false; Vehicle v(Caller); if (v.HasCommand(DUMMY_ALARM)) return false; return true; } bool CheckTarget(GameObject *Caller, Actor *Target, int childID) { if (!Caller->IsValid() || !Target->IsValid() || (Caller->GetID() != Target->GetID())) return false; return true; } void PushActions(GameObject *Caller, Actor *Target, int ChildID) { if(Caller->HasName(NAME_CONTROLPANEL4)) //= Tech Station Caller->PushActionExecuteCommand(ACTION_NEWLIST, DUMMY_TECHGATES, Caller, 2, false); else Mission::Playhint("Which gates should close then?"); return; }};object DummyTechGates : CommandScript{ DummyTechGates() { SetGroupID(DummyGroup); } bool CheckGroupVisibility(GameObject *Caller) { return false; } bool CheckPossible(GameObject *Caller) { return false; } void PushActions(GameObject *Caller, Actor *Target, int ChildID) { GameObjectList gate01e = Game::GetGameObjects(NAME_GATE01E); GameObjectList gate02e = Game::GetGameObjects(NAME_GATE02E); GameObjectList gate03e = Game::GetGameObjects(NAME_GATE03E);// GameObjectList gate01t = Game::GetGameObjects(NAME_GATE01T); // GameObjectList gate02t = Game::GetGameObjects(NAME_GATE02T); // GameObjectList gate03t = Game::GetGameObjects(NAME_GATE03T); ActorList vogate01e = Game::GetActors(VO_GATE01E); ActorList vogate02e = Game::GetActors(VO_GATE02E);// ActorList vogate01t = Game::GetActors(VO_GATE01T);// ActorList vogate02t = Game::GetActors(VO_GATE02T);// ActorList vogate03t = Game::GetActors(VO_GATE03T); if(ChildID == 1) //= Open front gates fire station 1 { for(int i=0; i < gate01e.GetNumObjects(); i++) { GameObject *gate = gate01e.GetObject(i); Actor *vogate = vogate01e.GetActor(i); if (gate->GetUserData() == 0) { gate->SetUserData(1); gate->SetAnimation(ANI_OPEN); vogate->SetVirtualObjectTerrain(VOSET_ROAD); } } for(int i=0; i < gate02e.GetNumObjects(); i++) { GameObject *gate = gate02e.GetObject(i); Actor *vogate = vogate02e.GetActor(i); if (gate->GetUserData() == 0) { gate->SetUserData(1); gate->SetAnimation(ANI_OPEN); vogate->SetVirtualObjectTerrain(VOSET_ROAD); } } for(int i=0; i < gate03e.GetNumObjects(); i++) { GameObject *gate = gate03e.GetObject(i); if (gate->GetUserData() == 0) { gate->SetUserData(1); gate->SetAnimation(ANI_OPEN); } } } if(ChildID == 2) //= Close all opened gates fire station 1 { for(int i=0; i < gate01e.GetNumObjects(); i++) { GameObject *gate = gate01e.GetObject(i); Actor *vogate = vogate01e.GetActor(i); if (gate->GetUserData() == 1) { gate->SetUserData(0); gate->SetAnimation(ANI_CLOSE); vogate->SetVirtualObjectTerrain(VOSET_BARRICADE); } } for(int i=0; i < gate02e.GetNumObjects(); i++) { GameObject *gate = gate02e.GetObject(i); Actor *vogate = vogate02e.GetActor(i); if (gate->GetUserData() == 1) { gate->SetUserData(0); gate->SetAnimation(ANI_CLOSE); vogate->SetVirtualObjectTerrain(VOSET_BARRICADE); } } for(int i=0; i < gate03e.GetNumObjects(); i++) { GameObject *gate = gate03e.GetObject(i); if (gate->GetUserData() == 1) { gate->SetUserData(0); gate->SetAnimation(ANI_CLOSE); } } } }}; Quote Link to comment Share on other sites More sharing options...