Jump to content
Maffegozer

[SCRIPT] Volunteering Firemen Script Error

Recommended Posts

Hello,

(Didn't know what the 'Vrijwillige Brandweer', dutch, or 'Freiwillige Feuerwehr', german, was called in English.)

I've made a script for a mod which should drive 3 cars that I've placed on the map, to 3 virtual objects.

After that they should get out of their cars.

But I get stuck at the part where they need to get out.

I've tested the script when I added the PushActionMove, and it worked.

But now I've added the LeaveCar action and then I get an script error.

The script:


// 112 Veluwe Hoog Soeren
// Script by: Niels
// Alarmering Vrijwillige Post
const char MOVECARONE[] = "movecar1";
const char MOVECARTWO[] = "movecar2";
const char MOVECARTHREE[] = "movecar3";
const char MOVEPERS[] = "movepers";
const char PROTO_ONE[] = "mod:/Prototypes/Persons/Civil/civilman02_blue.e4p";
const char PROTO_TWO[] = "mod:/Prototypes/Persons/Civil/civilman03_red.e4p";
const char PROTO_THREE[] = "mod:/Prototypes/Persons/Civil/civilman06.e4p";
const char alarmicon[] = "icon graag";
const char sound[] = "mod:/ path sound";
object vwbrwpost : CommandScript
{
vwbrwpost()
{
SetIcon(alarmicon);
SetCursor(alarmicon);
SetValidTargets(ACTOR_FLOOR);
}

bool CheckPossible(GameObject *Caller)
{
if (Caller->HasCommand("vwbrwn"))
return false;
return true;
}

bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
{
return true;
}

void PushActions(GameObject *Caller, Actor *Target, int childID)
{
Mission::PlayHint("Alarmering voor de vrijwillige brandweer Hoog Soeren.");
Audio::PlaySample(sound);

Person p1;
Person p2;
Person p3;
Person p4;
Person p5;
Person p6;
GameObject *go;
GameObject *go2;
GameObject *go3;
GameObjectList gol;
GameObjectList gol2;
GameObjectList gol3;
ActorList l1;
ActorList l2;
ActorList l3;

p1 = Game::CreatePerson(PROTO_ONE, "VHSP");
p2 = Game::CreatePerson(PROTO_TWO, "VHSP");
p3 = Game::CreatePerson(PROTO_THREE, "VHSP");
p4 = Game::CreatePerson(PROTO_ONE, "VHSP");
p5 = Game::CreatePerson(PROTO_TWO, "VHSP");
p6 = Game::CreatePerson(PROTO_THREE, "VHSP");

l1 = Game::GetActors(MOVECARONE);
Actor plekp = *l1.GetActor(0);
l2 = Game::GetActors(MOVECARTWO);
Actor plekp2 = *l2.GetActor(0);
l3 = Game::GetActors(MOVECARTHREE);
Actor plekp3 = *l3.GetActor(0);

Vector plek = plekp.GetPosition();
Vector plek2 = plekp2.GetPosition();
Vector plek3 = plekp3.GetPosition();

gol = Game::GetGameObjects("VHSA1");
go = *gol.GetObject(0);
Vehicle v(go);
v.SetSpeed(15.0f);
v.SetMaxPassengers(1);
v.SetMaxTransports(0);
v.AddPassenger(&p1);
v.PushActionWait(ACTION_NEWLIST, 9.0f);
v.PushActionMove(ACTION_APPEND, plek);
v.PushActionExecuteCommand(ACTION_APPEND, "ReadyYourself", &p1, 0, false);

gol2 = Game::GetGameObjects("VHSA2");
go2 = *gol2.GetObject(0);
Vehicle v2(go2);
v2.SetSpeed(15.0f);
v2.SetMaxPassengers(1);
v2.SetMaxTransports(0);
v2.AddPassenger(&p2);
v2.PushActionWait(ACTION_NEWLIST, 7.0f);
v2.PushActionMove(ACTION_APPEND, plek2);
v2.PushActionExecuteCommand(ACTION_APPEND, "ReadyYourself", &p2, 1, false);

gol3 = Game::GetGameObjects("VHSA3");
go3 = *gol3.GetObject(0);
Vehicle v3(go3);
v3.SetSpeed(15.0f);
v3.SetMaxPassengers(1);
v3.SetMaxTransports(0);
v3.AddPassenger(&p3);
v3.PushActionWait(ACTION_NEWLIST, 5.0f);
v3.PushActionMove(ACTION_APPEND, plek3);
v3.PushActionExecuteCommand(ACTION_APPEND, "ReadyYourself", &p3, 2, false);

}
};
object ReadyYourself : CommandScript
{
ReadyYourself()
{
SetIcon(alarmicon);
SetCursor(alarmicon);
}

bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
{
return true;
}

void PushActions(GameObject *Caller, Actor *Target, int childID)
{
GameObject *go;
GameObject *go2;
GameObject *go3;
GameObjectList gol;
GameObjectList gol2;
GameObjectList gol3;
PersonList PL;
Vector EPos;
if (childID == 0)
{
// Car One
Mission::PlayHint("Child 0");
gol = Game::GetGameObjects("VHSA1");
go = *gol.GetObject(0);
Vehicle v(go);
PL = v.GetPassengers();
EPos = v.GetPosition();
Game::FindFreePosition(PL.GetPerson(0),EPos);
PL.GetPerson(0)->PushActionLeaveCar(ACTION_NEWLIST, &p1);
}

if (childID == 1)
{
// Car Two
Mission::PlayHint("Child 1");
gol2 = Game::GetGameObjects("VHSA2");
go2 = *gol2.GetObject(0);
Vehicle v2(go2);
PL = v2.GetPassengers();
EPos = v2.GetPosition();
Game::FindFreePosition(PL.GetPerson(0),EPos);
PL.GetPerson(0)->PushActionLeaveCar(ACTION_NEWLIST, &p2);
}

if (childID == 2)
{
// Car Three
Mission::PlayHint("Child 2");
gol3 = Game::GetGameObjects("VHSA3");
go3 = *gol3.GetObject(0);
Vehicle v3(go3);
PL = v3.GetPassengers();
EPos = v3.GetPosition();
Game::FindFreePosition(PL.GetPerson(0),EPos);
PL.GetPerson(0)->PushActionLeaveCar(ACTION_NEWLIST, &p3);
}
}
};

It gives the script error: Something with class illegal pointer, on the following 3 lines: (Depends on which car gets there faster)


PL.GetPerson(0)->PushActionLeaveCar(ACTION_NEWLIST, &p1);


PL.GetPerson(0)->PushActionLeaveCar(ACTION_NEWLIST, &p2);


PL.GetPerson(0)->PushActionLeaveCar(ACTION_NEWLIST, &p3);

I don't know how to solve this error, as I have never had it before.

Will make a screenshot if you don't know what I mean ;)

Link to comment
Share on other sites

Try changing these lines to:


PL.GetPerson(0)->PushActionLeaveCar(ACTION_NEWLIST, &go);


PL.GetPerson(0)->PushActionLeaveCar(ACTION_NEWLIST, &go2);


PL.GetPerson(0)->PushActionLeaveCar(ACTION_NEWLIST, &go3);

If that doesn't work try:


PL.GetPerson(0)->PushActionLeaveCar(ACTION_NEWLIST, &v);


PL.GetPerson(0)->PushActionLeaveCar(ACTION_NEWLIST, &v2);


PL.GetPerson(0)->PushActionLeaveCar(ACTION_NEWLIST, &v3);

Link to comment
Share on other sites

Ok, So I have tried that and still got the error.

So now I 've tried an other way to accomplish the same.

Instead of having the person get out, I just create a person next to the vehicle.

It doesn't crash or give errors, thats one thing, but it doesnt create a person either.

Using this:


Vector EPos;
GameObjectList gol;
GameObject *go;
if (childID == 0)
{
gol = Game::GetGameObjects("VHSA1");
go = *gol.GetObject(0);
Vehicle v(go);
EPos = v.GetPosition();
Person p = Game::CreatePerson(PROTO_ONE, "Unnamed")
p.PushActionShowHide(ACTION_NEWLIST, true);
p.SetRole(ROLE_SQUAD);
Game::FindFreePosition(&p, EPos, 100.f);
p.SetPosition(EPos);
p.PushActionShowHide(ACTION_APPEND, false);
}
if (childID == 1)
{
gol = Game::GetGameObjects("VHSA2");
go = *gol.GetObject(0);
Vehicle v(go);
EPos = v.GetPosition();
Person p = Game::CreatePerson(PROTO_TWO, "Unnamed")
p.PushActionShowHide(ACTION_NEWLIST, true);
p.SetRole(ROLE_SQUAD);
Game::FindFreePosition(&p, EPos, 100.f);
p.SetPosition(EPos);
p.PushActionShowHide(ACTION_APPEND, false);
}
if (childID == 2)
{
gol = Game::GetGameObjects("VHSA3");
go = *gol.GetObject(0);
Vehicle v(go);
EPos = v.GetPosition();
Person p = Game::CreatePerson(PROTO_THREE, "Unnamed")
p.PushActionShowHide(ACTION_NEWLIST, true);
p.SetRole(ROLE_SQUAD);
Game::FindFreePosition(&p, EPos, 100.f);
p.SetPosition(EPos);
p.PushActionShowHide(ACTION_APPEND, false);
}

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...