-
I can't seem to get this to work. ***What am I missing?
I'm using a trigger to exec PilotsGetin.sqf
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
if (_nObject = nearestObject [Player, "Helicopter"]) then
{
Pilot1 assignAsCargo _nObject;
Pilot2 assignAsCargo _nObject;
[_Pilot1] orderGetIn true;
_Pos = position PilotLounge;
Pilot1 move _Pos;
}
esle
{
if (_nObject = nearestObject [Player, "car"]) then
{
Pilot1 assignAsCargo _nObject;
Pilot2 assignAsCargo _nObject;
[_Pilot1] orderGetIn true;
_Pos = position PilotLounge;
Pilot1 move _Pos;
}
esle
{
if (_nObject = nearestObject [Player, "Tank"]) then
{
Pilot1 assignAsCargo _nObject;
Pilot2 assignAsCargo _nObject;
[_Pilot1] orderGetIn true;
_Pos = position PilotLounge;
Pilot1 move _Pos;
}
}
};
[/QUOTE]
-
This is what appears in the editor when previewing:
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
'|#|};'
Error Missing{
[/QUOTE]
-
Sergeant Major
Don't know if you did a cut & paste from your script, for the example you posted. But it should be:
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">else[/QUOTE]
Not
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">esle[/QUOTE]
-
OMG! Thanks.
I fixed the typo and still get same results.
-
Sergeant Major
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (_nObject = nearestObject [Player, "Helicopter"]) then
*** *** *** ***{
*** *** *** ***Pilot1 assignAsCargo _nObject;
*** *** *** ***Pilot2 assignAsCargo _nObject;
*** *** *** ***[Pilot1] orderGetIn true;
*** *** *** ***_Pos = position PilotLounge;
*** *** *** ***Pilot1 move _Pos;
*** *** *** ***}
*** *** *** ***else
*** *** *** ***{
*** *** *** ***if (_nObject = nearestObject [Player, "car"]) then
*** *** *** *** *** *** *** ***{
*** *** *** *** *** *** *** ***Pilot1 assignAsCargo _nObject;
*** *** *** *** *** *** *** ***Pilot2 assignAsCargo _nObject;
*** *** *** *** *** *** *** ***[Pilot1] orderGetIn true;
*** *** *** *** *** *** *** ***_Pos = position PilotLounge;
*** *** *** *** *** *** *** ***Pilot1 move _Pos;
*** *** *** *** *** *** *** ***}
*** *** *** *** *** *** *** ***else
*** *** *** *** *** *** *** ***{
*** *** *** *** *** *** *** ***if (_nObject = nearestObject [Player, "Tank"]) then
*** *** *** *** *** *** *** *** *** *** *** ***{
*** *** *** *** *** *** *** *** *** *** *** ***Pilot1 assignAsCargo _nObject;
*** *** *** *** *** *** *** *** *** *** *** ***Pilot2 assignAsCargo _nObject;
*** *** *** *** *** *** *** *** *** *** *** ***[Pilot1] orderGetIn true;
*** *** *** *** *** *** *** *** *** *** *** ***_Pos = position PilotLounge;
*** *** *** *** *** *** *** *** *** *** *** ***Pilot1 move _Pos;
*** *** *** *** *** *** *** *** *** *** *** ***};
*** *** *** *** *** *** *** ***};
*** *** *** ***};[/QUOTE]
I reformatted the example with indents, makes it a bit easier to read. Just do a search and replace across your script, swapping tab's for eight spaces, when posting code on the forum. I also noticed you had mixed global and local variables for Pilot1 & _Pilot1. So I changed them all to global.
As I said in a similar thread, which was completly ignored. The best way to figure it out, is with a bit of basic debugging. If a chunck of code is giving you problrms, them simplify it.
Start with:
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (_nObject = nearestObject [Player, "Helicopter"]) then
*** *** *** ***{
*** *** *** ***Pilot1 assignAsCargo _nObject;
*** *** *** ***Pilot2 assignAsCargo _nObject;
*** *** *** ***[Pilot1] orderGetIn true;
*** *** *** ***_Pos = position PilotLounge;
*** *** *** ***Pilot1 move _Pos;
*** *** *** ***}
*** *** *** ***else
*** *** *** ***{
*** *** *** ***};[/QUOTE]
If you get the same error, then you only need to worry about a third of your script. If that works ok, then add:
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (_nObject = nearestObject [Player, "Helicopter"]) then
*** *** *** ***{
*** *** *** ***Pilot1 assignAsCargo _nObject;
*** *** *** ***Pilot2 assignAsCargo _nObject;
*** *** *** ***[Pilot1] orderGetIn true;
*** *** *** ***_Pos = position PilotLounge;
*** *** *** ***Pilot1 move _Pos;
*** *** *** ***}
*** *** *** ***else
*** *** *** ***{
*** *** *** ***if (_nObject = nearestObject [Player, "car"]) then
*** *** *** *** *** *** *** ***{
*** *** *** *** *** *** *** ***Pilot1 assignAsCargo _nObject;
*** *** *** *** *** *** *** ***Pilot2 assignAsCargo _nObject;
*** *** *** *** *** *** *** ***[Pilot1] orderGetIn true;
*** *** *** *** *** *** *** ***_Pos = position PilotLounge;
*** *** *** *** *** *** *** ***Pilot1 move _Pos;
*** *** *** *** *** *** *** ***}
*** *** *** *** *** *** *** ***else
*** *** *** *** *** *** *** ***{
*** *** *** *** *** *** *** ***};
*** *** *** ***};[/QUOTE]
And so on...
I know it's tempting to get other people to figure it out (not so much you). But in the long run, you will save yourself so much more time, if you can quickly track down problems as soon as they arise.
-
Thank you!
Here is the correct code:
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
_hObject = nearestObject ***[Pilot1, "Helicopter"];
_cObject = nearestObject ***[Pilot1, "car"];
if (nearestObject = "Helicopter") then
*** *** *** {
*** *** *** Pilot1 assignAsCargo _hObject;
*** *** *** Pilot2 assignAsCargo _hObject;
*** *** *** [Pilot1] orderGetIn true;
*** *** *** _Pos = position PilotLounge;
*** *** *** Pilot1 move _Pos;
*** *** *** }
*** *** *** else
*** *** *** *** *** *** *** ***{
*** *** *** *** *** *** *** ***if (nearestObject = "car") then
*** *** *** *** *** *** *** *** *** *** *** *** {
*** *** *** *** *** *** *** *** *** *** *** *** ***Pilot1 assignAsCargo _cObject;
*** *** *** *** *** *** *** *** *** *** *** *** ***Pilot2 assignAsCargo _cObject;
*** *** *** *** *** *** *** *** *** *** *** *** ***[Pilot1] orderGetIn true;
*** *** *** *** *** *** *** *** *** *** *** *** ***_Pos = position PilotLounge;
*** *** *** *** *** *** *** *** *** *** *** *** ***Pilot1 move _Pos;
*** *** *** *** *** *** *** *** *** *** *** *** ***}
*** *** *** *** *** *** *** *** };
[/QUOTE]
As you can see I had the beginning statements wrong.
That is why it was showing:
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
'|#|};'
Error Missing{
[/QUOTE]
I agree with about doing the research and troubleshooting before posting. ***I jumped the gun.
-
Shouldn't the "=" inside the if conditions be "==" for SQF? I believe a single "=" is an assignment, making the first if always true. It won't cause an error, but you can never get to the rest of the condition testing in the code block.
-
Sergeant Major
Actualy there are a few other things that don't look right. Perhaps if you posted some details on what you're trying to do?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules