Home   Help Search Login Register  

Author Topic: Problem with Radio Airstrike Script  (Read 1844 times)

0 Members and 1 Guest are viewing this topic.

Offline Mostly

  • Members
  • *
Problem with Radio Airstrike Script
« on: 30 Dec 2008, 15:23:32 »
I'm having trouble with a radio/airstrike script. Think it's quite a simple problem but can't seem to work it out!
I've created a radio script which lets me have sub-channels for the radio. For example, my main radio menu looks something like:
1. Request Airsupport
2. Request Resupply
3. Request Extraction
When you select one of them it brings up a menu which refers to the topic selected. So when I select 1. Request Airstrike, I get another menu which has more options on it.

The problem is that the Airstrike script won't work properly. The Airstrike script works by the player clicking on the map to give the Aircraft a target. It works if I use the following line in a radio trigger "onmapsingleclick {[_pos] exec "Airstrike.sqs"}", but that command doesn't seem to work when I use it in an external script.
Does anyone know what command I should use in the external script to get it to work?
They mostly come out at night. Mostly!

Offline dr. seltsam

  • Members
  • *
Re: Problem with Radio Airstrike Script
« Reply #1 on: 30 Dec 2008, 21:39:01 »
Show us the script...
:)

Offline Mostly

  • Members
  • *
Re: Problem with Radio Airstrike Script
« Reply #2 on: 01 Jan 2009, 15:51:00 »
The part of the script that I'm having trouble with is :
Code: [Select]
#AIRSTRIKE1
Player sidechat "Standy for Target Location, over."
onmapsingleclick ([_pos] exec "Airstrike.sqs");
goto "MENU1"
MENU1 being the default radio menu.
It all seems to work but there is a problem positioning the target marker for the airstrike. This is controlled by the airstrike script and looks like this :
Code: [Select]
onMapSingleClick {}
_pos = _this select 0
[_pos, "Target at grid location ", ". Over.", ["SideChat", player]] exec "gridcoordinates_pipe.sqs"
~5
"target" setMarkerPos _pos
"target" setMarkerType "destroy"

I'm sure it's something to do with the command in the radio script but can't work it out. The airstrike script works perfectly if I use a radio trigger to activate it with the init command "onmapsingleclick ([_pos] exec "Airstrike.sqs")".
 

EDIT


Nevermind. Managed to sort it. No idea what was wrong, it just started working one time I tested it. Bloody thing.
« Last Edit: 01 Jan 2009, 19:40:47 by Mostly »
They mostly come out at night. Mostly!

Offline dr. seltsam

  • Members
  • *
Re: Problem with Radio Airstrike Script
« Reply #3 on: 02 Jan 2009, 17:06:43 »
hmm.. ok

Well, a good idea for testing your script work is always having debug messages inside the scripts. Like for example:

hint format ["Info: Script entered with %1",_this]

This here is nice at the script start. Or let you show important values with more

hint format ["%1",_importantValue]

or

player globalchat format ["%1",_whatYouWant]

during running the script. A message like

player globalchat "Script exit"

at the end is also usefull, because a scriptmaker wants to be sure that everything that is not necessary anymore, really does end. That is important, because that way you have a better control about the performance consumption of your scripts in a mission.

:) :)




Offline savedbygrace

  • Intel Depot
  • Administrator
  • *****
  • Be swift to hear...slow to speak...slow to wrath.
Re: Problem with Radio Airstrike Script
« Reply #4 on: 03 Jan 2009, 05:18:01 »
Great! Yet another lesson to be learned if thou shalt teach us?
1. Can you please explain what Format means and how it works?
2. Can you please explain what the percentage symbol is and how it works?
Thanks from me and the rest of the newbs for sharing the knowledge.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: Problem with Radio Airstrike Script
« Reply #5 on: 03 Jan 2009, 22:01:59 »
All these questions (and more) can be answered by a quick trip to the COMREF.

Offline savedbygrace

  • Intel Depot
  • Administrator
  • *****
  • Be swift to hear...slow to speak...slow to wrath.
Re: Problem with Radio Airstrike Script
« Reply #6 on: 04 Jan 2009, 04:43:55 »
Right,... the code is there, a description is there, an example is there, but a clarification of what its purpose is and why the % symbol must be used is not. For those of us who have no formal training in code, and limited mathematical education, it is just not clear. The COMREF is no doubt the most useful resource available to us but there is still some of it that is above the heads of newbs. Including my ignorant self.

Offline Gcfungus

  • Members
  • *
Re: Problem with Radio Airstrike Script
« Reply #7 on: 04 Jan 2009, 23:17:19 »
Format is used to insert variables into strings, usually so players can say you have $x or y chances left.
The percentage refers to the variable you want to use.
It is defined:
format ["text text $%1",money]
for this example, it would create the string: "text text $5" if moneyt was set to 5 and allows more fluid dialogue.
For example, rather than saying:
"I don't like player 1, he only lent me $3!"
you could say:
format ["I don't like %1, he only lent me $%2",name man1,money]
The object of war is not to die for your country, but to make the other bastard die for his.
~George Patton

Offline savedbygrace

  • Intel Depot
  • Administrator
  • *****
  • Be swift to hear...slow to speak...slow to wrath.
Re: Problem with Radio Airstrike Script
« Reply #8 on: 05 Jan 2009, 08:04:32 »
I think I see its purpose now but am still not grasping how some portions of it work.
Using your examples..
Quote
format ["text text $%1",money]
for this example, it would create the string: "text text $5" if moneyt was set to 5 and allows more fluid dialogue.
Where does the code draw the $5 variable from? If the word "money" is what determines the value, how does it calculate it for the string?
So, the numerical value behind the % symbol is collected from its corresponding define at the latter end of the array for example...
Code: [Select]
Cuttext [format ["Good morning %1%2, I've been going over the maps here with %4%5 while we waited for your arrival and noticed a valley that we could use for insertion.",rank man1, name man1, rank man2, name man2], "Plain",1] Would the above code return the rank and nic of the players playing the units named man1 and man2 in multiplayer?

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: Problem with Radio Airstrike Script
« Reply #9 on: 05 Jan 2009, 10:01:16 »
Indeed it would.

The values represented by %1, %2, etc are referenced to the variable names which follow the string construct, so in the example above 'money' would be a global variable set before the format command is called - otherwise it would return a missing variable error.

You can do some nifty things with format, not just displaying strings. For example, say you have 10 markers on your map named sequentially, i.e. m1, m2, m3, etc. and 10 loons on the map named sequentially, i.e. loon1, loon2, loon3, etc. You could move those markers with the following script:

Code: [Select]
#loop
"m1" setmarkerpos getpos loon1
"m2" setmarkerpos getpos loon2
"m3" setmarkerpos getpos loon3
etc...
~1
goto "loop"

which is a bit repetitive and unnecessary, because the same thing can be achieved using the format command:

Code: [Select]
_i = 1
#loop

call format[{"m%1" setmarkerpos getpos loon%1}, _i]

_i = _i + 1
?(_i > 10) : _i = 1

~0.1
goto "loop"
« Last Edit: 05 Jan 2009, 10:05:24 by bedges »

Offline Gcfungus

  • Members
  • *
Re: Problem with Radio Airstrike Script
« Reply #10 on: 05 Jan 2009, 23:18:48 »
Just a small nit pick  :D
Quote
Cuttext [format ["Good morning %1%2, I've been going over the maps here with %4%5 while we waited for your arrival and noticed a valley that we could use for insertion.",rank man1, name man1, rank man2, name man2], "Plain",1]
You used the number 1,2,4,5 and missed 3  :D
The object of war is not to die for your country, but to make the other bastard die for his.
~George Patton