Results 1 to 8 of 8

Thread: Trouble with SQF and Blocks

  1. #1
    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 &#40;_nObject = nearestObject &#91;Player, &#34;Helicopter&#34;&#93;&#41; then
    {
    Pilot1 assignAsCargo _nObject;
    Pilot2 assignAsCargo _nObject;
    &#91;_Pilot1&#93; orderGetIn true;
    _Pos = position PilotLounge;
    Pilot1 move _Pos;
    }
    esle
    {
    if &#40;_nObject = nearestObject &#91;Player, &#34;car&#34;&#93;&#41; then
    {
    Pilot1 assignAsCargo _nObject;
    Pilot2 assignAsCargo _nObject;
    &#91;_Pilot1&#93; orderGetIn true;
    _Pos = position PilotLounge;
    Pilot1 move _Pos;
    }
    esle
    {
    if &#40;_nObject = nearestObject &#91;Player, &#34;Tank&#34;&#93;&#41; then
    {
    Pilot1 assignAsCargo _nObject;
    Pilot2 assignAsCargo _nObject;
    &#91;_Pilot1&#93; orderGetIn true;
    _Pos = position PilotLounge;
    Pilot1 move _Pos;
    }
    }
    };
    [/QUOTE]

  2. #2
    Private First Class
    Join Date
    Sep 7 2001
    Location
    Florida
    Posts
    32
    Author of the Thread
    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">
    &#39;&#124;#&#124;};&#39;
    Error Missing{
    [/QUOTE]




  3. #3
    Don&#39;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]

  4. #4
    Private First Class
    Join Date
    Sep 7 2001
    Location
    Florida
    Posts
    32
    Author of the Thread
    OMG&#33; Thanks.

    I fixed the typo and still get same results.

  5. #5
    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if &#40;_nObject = nearestObject &#91;Player, &#34;Helicopter&#34;&#93;&#41; then
    *** *** *** ***{
    *** *** *** ***Pilot1 assignAsCargo _nObject;
    *** *** *** ***Pilot2 assignAsCargo _nObject;
    *** *** *** ***&#91;Pilot1&#93; orderGetIn true;
    *** *** *** ***_Pos = position PilotLounge;
    *** *** *** ***Pilot1 move _Pos;
    *** *** *** ***}
    *** *** *** ***else
    *** *** *** ***{
    *** *** *** ***if &#40;_nObject = nearestObject &#91;Player, &#34;car&#34;&#93;&#41; then
    *** *** *** *** *** *** *** ***{
    *** *** *** *** *** *** *** ***Pilot1 assignAsCargo _nObject;
    *** *** *** *** *** *** *** ***Pilot2 assignAsCargo _nObject;
    *** *** *** *** *** *** *** ***&#91;Pilot1&#93; orderGetIn true;
    *** *** *** *** *** *** *** ***_Pos = position PilotLounge;
    *** *** *** *** *** *** *** ***Pilot1 move _Pos;
    *** *** *** *** *** *** *** ***}
    *** *** *** *** *** *** *** ***else
    *** *** *** *** *** *** *** ***{
    *** *** *** *** *** *** *** ***if &#40;_nObject = nearestObject &#91;Player, &#34;Tank&#34;&#93;&#41; then
    *** *** *** *** *** *** *** *** *** *** *** ***{
    *** *** *** *** *** *** *** *** *** *** *** ***Pilot1 assignAsCargo _nObject;
    *** *** *** *** *** *** *** *** *** *** *** ***Pilot2 assignAsCargo _nObject;
    *** *** *** *** *** *** *** *** *** *** *** ***&#91;Pilot1&#93; 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&#39;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 &#40;_nObject = nearestObject &#91;Player, &#34;Helicopter&#34;&#93;&#41; then
    *** *** *** ***{
    *** *** *** ***Pilot1 assignAsCargo _nObject;
    *** *** *** ***Pilot2 assignAsCargo _nObject;
    *** *** *** ***&#91;Pilot1&#93; 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 &#40;_nObject = nearestObject &#91;Player, &#34;Helicopter&#34;&#93;&#41; then
    *** *** *** ***{
    *** *** *** ***Pilot1 assignAsCargo _nObject;
    *** *** *** ***Pilot2 assignAsCargo _nObject;
    *** *** *** ***&#91;Pilot1&#93; orderGetIn true;
    *** *** *** ***_Pos = position PilotLounge;
    *** *** *** ***Pilot1 move _Pos;
    *** *** *** ***}
    *** *** *** ***else
    *** *** *** ***{
    *** *** *** ***if &#40;_nObject = nearestObject &#91;Player, &#34;car&#34;&#93;&#41; then
    *** *** *** *** *** *** *** ***{
    *** *** *** *** *** *** *** ***Pilot1 assignAsCargo _nObject;
    *** *** *** *** *** *** *** ***Pilot2 assignAsCargo _nObject;
    *** *** *** *** *** *** *** ***&#91;Pilot1&#93; orderGetIn true;
    *** *** *** *** *** *** *** ***_Pos = position PilotLounge;
    *** *** *** *** *** *** *** ***Pilot1 move _Pos;
    *** *** *** *** *** *** *** ***}
    *** *** *** *** *** *** *** ***else
    *** *** *** *** *** *** *** ***{
    *** *** *** *** *** *** *** ***};
    *** *** *** ***};[/QUOTE]

    And so on...

    I know it&#39;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.

  6. #6
    Private First Class
    Join Date
    Sep 7 2001
    Location
    Florida
    Posts
    32
    Author of the Thread
    Thank you&#33;

    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 ***&#91;Pilot1, &#34;Helicopter&#34;&#93;;
    _cObject = nearestObject ***&#91;Pilot1, &#34;car&#34;&#93;;
    if &#40;nearestObject = &#34;Helicopter&#34;&#41; then
    *** *** *** {
    *** *** *** Pilot1 assignAsCargo _hObject;
    *** *** *** Pilot2 assignAsCargo _hObject;
    *** *** *** &#91;Pilot1&#93; orderGetIn true;
    *** *** *** _Pos = position PilotLounge;
    *** *** *** Pilot1 move _Pos;
    *** *** *** }
    *** *** *** else
    *** *** *** *** *** *** *** ***{
    *** *** *** *** *** *** *** ***if &#40;nearestObject = &#34;car&#34;&#41; then
    *** *** *** *** *** *** *** *** *** *** *** *** {
    *** *** *** *** *** *** *** *** *** *** *** *** ***Pilot1 assignAsCargo _cObject;
    *** *** *** *** *** *** *** *** *** *** *** *** ***Pilot2 assignAsCargo _cObject;
    *** *** *** *** *** *** *** *** *** *** *** *** ***&#91;Pilot1&#93; 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">
    &#39;&#124;#&#124;};&#39;
    Error Missing{
    [/QUOTE]

    I agree with about doing the research and troubleshooting before posting. ***I jumped the gun.

  7. #7
    Shouldn&#39;t the "=" inside the if conditions be "==" for SQF? I believe a single "=" is an assignment, making the first if always true. It won&#39;t cause an error, but you can never get to the rest of the condition testing in the code block.

  8. #8
    Actualy there are a few other things that don&#39;t look right. Perhaps if you posted some details on what you&#39;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
  •