Jump to content
Sign in to follow this  
Toasted Duckie

Can't get script to work

Recommended Posts

Hey guys, I'm making a little script to have a leader move a AI unit into a vehicle near (AI is annoying sometimes).

I managed (with the help of some of the guys over at GOL's) to get this far:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_helo = _this select 0

_int = _this select 1

_distance = 50

_Vararray = ["_helo","_int"]

#check

?(_int in _helo) : goto "remove1"

?(_int distance _helo) < _distance : goto "addaction"

~3

goto "check"

#addaction

?(player == leader _int) : Action_HostageEvac = leader _int addaction ["Move hostage into aircraft","gethimin.sqs", _Vararray];

~2

#remove

?(_int in _helo) : goto "remove1"

?(_int distance _helo) > _distance : goto "remove1"

~3

goto "remove"

#remove1

(leader _int) removeaction action_HostageEvac

~3

goto "check"

and in the second script for the action I have <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Vararray = _this select 3

_helo = _Vararray select 0

_int = _Vararray select 1

_int moveincargo _helo

However if I want to perform the action I get a error saying "Type String, expected Object".

I'm very much new to scripting so this is still quite confusing for me, but I'll manage. Help much appreciated! smile_o.gif

Share this post


Link to post
Share on other sites

Change the line <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Vararray = ["_helo","_int"]

to:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Vararray = [_helo,_int]

You want to pass an array of objects and not an array of strings. By putting something in " ", you're making a string out of it, no matter what it was before.

Share this post


Link to post
Share on other sites

I still can't believe the smallest changes, so simple, can still be this hard to find and figure out biggrin_o.gif

It works like a charm, thanks a lot buddy notworthy.gif

It's been only days since I started this scripting stuff so bear with me this one time whistle.gif

Cheers!

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×