The Loot Posted July 18, 2013 Report Share Posted July 18, 2013 I'm trying to recreate the restriction of one bomb robot when it comes to calling additional ambulances from off map. So far, I've added this to the top of the script:const char NAME_AMBULANCE03[] = "Ambulance03";const char NAME_AMBULANCE04[] = "Ambulance04";const char NAME_AMBULANCE05[] = "Ambulance05";And then used this as the script for creating a vehicle:{System::Log("Buy ALS Ambulance"); bool Ambulance03 = true; bool Ambulance04 = true; bool Ambulance05 = true; GameObjectList list = Game::GetGameObjects(NAME_AMBULANCE03) if (list.GetNumObjects() > 0) Ambulance03 = false; GameObjectList list = Game::GetGameObjects(NAME_AMBULANCE04) if (list.GetNumObjects() > 0) Ambulance04 = false; GameObjectList list = Game::GetGameObjects(NAME_AMBULANCE05) if (list.GetNumObjects() > 0) Ambulance05 = false; int Money = Mission::GetMoneyLeft(); if (Money <= 550) Ambulance04 = false; else if (Money <= 850)(Ambulance03 = false && Ambulance05 = false); Vehicle n; if (Ambulance04 = true) {n = Game::CreateVehicle(PROTO_AMBULANCE04, UNNAMED); int NewMoney = Money - 550; } else if (Ambulance05 = true) {n = Game::CreateVehicle(PROTO_AMBULANCE05, UNNAMED); int NewMoney = Money - 850; } else if (Ambulance03 = true) {n = Game::CreateVehicle(PROTO_AMBULANCE03, UNNAMED); int NewMoney = Money - 850; } else {Mission::PlayHint(HINT_NOAMBULANCE); return;} Mission::SetMoney(NewMoney); n.SetSpeed(12.0f); Person p1; Person p2; p1 = Game::CreatePerson(OBJ_PM, UNNAMED); p2 = Game::CreatePerson(OBJ_PM, UNNAMED); n.SetPlayerMP(Caller->GetPlayerMP()); p1.SetPlayerMP(Caller->GetPlayerMP()); p2.SetPlayerMP(Caller->GetPlayerMP()); p1.SetUpgradeLevel(3); p2.SetUpgradeLevel(3); n.SetMaxPassengers(2); n.SetMaxTransports(1); n.AddPassenger(&p1); n.AddPassenger(&p2); n.SetPosition(Spawn); n.UpdatePlacement(); n.Hide(); n.PushActionTurnTo(ACTION_NEWLIST, Rotate); n.PushActionWait(ACTION_APPEND, 35.0f); n.PushActionShowHide(ACTION_APPEND, false); n.PushActionMove(ACTION_APPEND, CmdPos); n.RemoveCommand("VcmdToFireStation"); n.RemoveCommand("VcmdToHospital"); n.RemoveCommand("VcmdPatrolAmbulance"); if (!n.HasCommand(DUMMY_HASSIREN) && n.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed()) Game::ExecuteCommand(CMD_SIREN, &n, &n); Mission::PlayHint(HINT_ALSAMBUBOUGHT); } I end up with the following script errors:?(_LACallAmbulance80504): Error: Game::GetGameObjects(NAME_AMBULANCE03)if(list.GetNumObjects()>0)Ambulance03 Syntax error??(_LACallAmbulance80504): FILE:mod:/scripts/game/command/LACallAmbulance.script80504 LINE:203?(_LACallAmbulance80504): Error: if(list.GetNumObjects()>0)Ambulance03 Syntax error??(_LACallAmbulance80504): FILE:mod:/scripts/game/command/LACallAmbulance.script80504 LINE:203?(_LACallAmbulance80504): Error: Symbol list is not defined in current scope?(_LACallAmbulance80504): FILE:mod:/scripts/game/command/LACallAmbulance.script80504 LINE:203?(_LACallAmbulance80504): Error: Failed to evaluate list.GetNumObjects()?(_LACallAmbulance80504): Possible candidates are...?(_LACallAmbulance80504): filename line:size busy function type and name ?(_LACallAmbulance80504):?(_LACallAmbulance80504): Error: improper lvalue?(_LACallAmbulance80504): FILE:mod:/scripts/game/command/LACallAmbulance.script80504 LINE:203?(_LACallAmbulance80504): !!!Dictionary position rewound...?(_LACallAmbulance80504): !!!Error recovered!!!Obviously I'm missing some code from the LABombRobot script, but I haven't messed with this before. I've added my "Call Ambulance" and "LA Bomb Robot" script files.Scripts.rar Quote Link to comment Share on other sites More sharing options...
Quincy Posted July 18, 2013 Report Share Posted July 18, 2013 Try putting the false declaration in brackets like i've done below. (Copy and paste this snippet over the current code. GameObjectList list = Game::GetGameObjects(NAME_AMBULANCE03) if (list.GetNumObjects() > 0) { Ambulance03 = false; } GameObjectList list = Game::GetGameObjects(NAME_AMBULANCE04) if (list.GetNumObjects() > 0) { Ambulance04 = false; } GameObjectList list = Game::GetGameObjects(NAME_AMBULANCE05) if (list.GetNumObjects() > 0) { Ambulance05 = false; { Quote Link to comment Share on other sites More sharing options...
The Loot Posted July 18, 2013 Author Report Share Posted July 18, 2013 Found a few missing semicolons and added braces, so I've got this now. bool Ambulance03 = true; bool Ambulance04 = true; bool Ambulance05 = true; GameObjectList list = Game::GetGameObjects(PROTO_AMBULANCE03); if (list.GetNumObjects() > 0){Ambulance03 = false;} list = Game::GetGameObjects(PROTO_AMBULANCE04); if (list.GetNumObjects() > 0){Ambulance04 = false;} list = Game::GetGameObjects(PROTO_AMBULANCE05); if (list.GetNumObjects() > 0){Ambulance05 = false;} int Money = Mission::GetMoneyLeft(); if (Money <= 550) {Ambulance04 = false;} else if (Money <= 850) {Ambulance03 = false; Ambulance05 = false;} Vehicle n; if (Ambulance04 == true) {n = Game::CreateVehicle(PROTO_AMBULANCE04, UNNAMED); int NewMoney = Money - 550; } else if (Ambulance05 == true) {n = Game::CreateVehicle(PROTO_AMBULANCE05, UNNAMED); int NewMoney = Money - 850; } else if (Ambulance03 == true) {n = Game::CreateVehicle(PROTO_AMBULANCE03, UNNAMED); int NewMoney = Money - 850; } else {Mission::PlayHint(HINT_NOAMBULANCE); return;} Problem is that it seems "GameObjectList" check isn't either finding the proto (if that's valid to use there), or isn't setting it to false if it is. Quote Link to comment Share on other sites More sharing options...
The Loot Posted August 12, 2013 Author Report Share Posted August 12, 2013 Sorry to bump, but I've tried another method and I still can't get it to work. *System::Log("Buy ALS Ambulance"); bool Ambulance03 = true; bool Ambulance04 = true; bool Ambulance05 = true; ActorList l5 = Game::GetActors(PROTO_AMBULANCE03); ActorList l6 = Game::GetActors(PROTO_AMBULANCE04); ActorList l7 = Game::GetActors(PROTO_AMBULANCE05); if(l5.GetNumActors() > 0) Ambulance03 = false; if(l6.GetNumActors() > 0) Ambulance04 = false; if(l7.GetNumActors() > 0) Ambulance05 = false; int Money = Mission::GetMoneyLeft(); if (Money <= 550) Ambulance04 = false; if (Money <= 850) { Ambulance03 = false; Ambulance05 = false; } Vehicle n; if (Ambulance04) { n = Game::CreateVehicle(PROTO_AMBULANCE04, UNNAMED); int NewMoney = Money - 550; } else if (Ambulance03) { n = Game::CreateVehicle(PROTO_AMBULANCE03, UNNAMED); int NewMoney = Money - 850; } else if (Ambulance05) { n = Game::CreateVehicle(PROTO_AMBULANCE05, UNNAMED); int NewMoney = Money - 850; } else { Mission::PlayHint(HINT_NOAMBULANCE); return; } Anyone have ideas? Quote Link to comment Share on other sites More sharing options...
AdamDwyer Posted August 13, 2013 Report Share Posted August 13, 2013 where you have this GameObjectList list = Game::GetGameObjects(PROTO_AMBULANCE03); if (list.GetNumObjects() > 0){Ambulance03 where the >0) is try changing the 0 to a 1 and see if that works? I noticed that was different when looking at the script. Quote Link to comment Share on other sites More sharing options...
The Loot Posted August 14, 2013 Author Report Share Posted August 14, 2013 I suppose I can change it to ">=1" and still have the effect, but it just seems that I'm using the wrong function or the function isn't working in this case for some reason. Quote Link to comment Share on other sites More sharing options...
NathanDollinger Posted August 21, 2013 Report Share Posted August 21, 2013 I'm trying to recreate the restriction of one bomb robot when it comes to calling additional ambulances from off map. So far, I've added this to the top of the script:const char NAME_AMBULANCE03[] = "Ambulance03";const char NAME_AMBULANCE04[] = "Ambulance04";const char NAME_AMBULANCE05[] = "Ambulance05";And then used this as the script for creating a vehicle: GameObjectList list = Game::GetGameObjects(NAME_AMBULANCE03) if (list.GetNumObjects() > 0) Ambulance03 = false; GameObjectList list = Game::GetGameObjects(NAME_AMBULANCE04) if (list.GetNumObjects() > 0) Ambulance04 = false; GameObjectList list = Game::GetGameObjects(NAME_AMBULANCE05) if (list.GetNumObjects() > 0) Ambulance05 = false; Here your using NAME_AMBULANCE03 to define your ambulance Found a few missing semicolons and added braces, so I've got this now.bool Ambulance03 = true; bool Ambulance04 = true; bool Ambulance05 = true; GameObjectList list = Game::GetGameObjects(PROTO_AMBULANCE03); if (list.GetNumObjects() > 0){Ambulance03 = false;} list = Game::GetGameObjects(PROTO_AMBULANCE04); if (list.GetNumObjects() > 0){Ambulance04 = false;} list = Game::GetGameObjects(PROTO_AMBULANCE05); if (list.GetNumObjects() > 0){Ambulance05 = false;} int Money = Mission::GetMoneyLeft(); if (Money <= 550) {Ambulance04 = false;} else if (Money <= 850) {Ambulance03 = false; Ambulance05 = false;} Vehicle n; if (Ambulance04 == true) {n = Game::CreateVehicle(PROTO_AMBULANCE04, UNNAMED); int NewMoney = Money - 550; } else if (Ambulance05 == true) {n = Game::CreateVehicle(PROTO_AMBULANCE05, UNNAMED); int NewMoney = Money - 850; } else if (Ambulance03 == true) {n = Game::CreateVehicle(PROTO_AMBULANCE03, UNNAMED); int NewMoney = Money - 850; } else {Mission::PlayHint(HINT_NOAMBULANCE); return;}Problem is that it seems "GameObjectList" check isn't either finding the proto (if that's valid to use there), or isn't setting it to false if it is.And here your using this PROTO_AMBULANCE05! Did you change the Objects list to match your script or vise versa? ( PROTO_AMBULANCE00 shout be NAME_AMBULANCE00) Right?You said the gameobjects list wasn't find the prototypes and this would be a cause of that! Also const char NAME_AMBULANCE03[] = "Ambulance03"; <- Define the hole path to your ambulance mod:prototypes/vehicles/ambulance/... There could be one more problem but try that and see what you get!And i think if the other error is what i think it will be it shouldn't be hard to fix! Quote Link to comment Share on other sites More sharing options...
The Loot Posted August 21, 2013 Author Report Share Posted August 21, 2013 Here's my CallAmbulance script as I have it now. My lines are commented out for what I'm attempting to do here. I'm not using NAME or anything, just the prototype constant. LACallAmbulance.rar Quote Link to comment Share on other sites More sharing options...
The Loot Posted November 30, 2013 Author Report Share Posted November 30, 2013 Update: Seems the one step I was missing was actually naming spawned vehicles, as the script was looking for object names. I should be able to finally implement this. Edit: Hmm, nope. ?(_LACallAmbulances836a0): Error: Can't call ActorList::ActorList((class GameObjectList)753413496) in current scopeActorList l5 = Game::GetGameObjects("Ambulance03");Is ActorList or GetGameObjects the wrong function for getting vehicles assigned certain names?BOOM! "Actor" was wrong completely, and of course doesn't mix with "Object". Works perfectly now.bool Ambulance03 = true;bool Ambulance04 = true;bool Ambulance04_1 = true;bool Ambulance05 = true; bool Ambulance05_1 = true; bool SUV = true;GameObjectList l5 = Game::GetGameObjects("Ambulance03");GameObjectList l6 = Game::GetGameObjects("Ambulance04");GameObjectList l7 = Game::GetGameObjects("Ambulance04_1");GameObjectList l8 = Game::GetGameObjects("Ambulance05");GameObjectList l9 = Game::GetGameObjects("Ambulance05_1");GameObjectList l10 = Game::GetGameObjects("SUV");if(l5.GetNumObjects() > 0) Ambulance03 = false;if(l6.GetNumObjects() > 0) Ambulance04 = false;if(l7.GetNumObjects() > 0) Ambulance04_1 = false;if(l8.GetNumObjects() > 0) Ambulance05 = false;if(l9.GetNumObjects() > 0) Ambulance05_1 = false;if(l10.GetNumObjects() > 0) SUV = false; Quote Link to comment Share on other sites More sharing options...