Home   Help Search Login Register  

Author Topic: a few things  (Read 1856 times)

0 Members and 1 Guest are viewing this topic.

Offline OFPfreak

  • Members
  • *
  • Who is da operation flashpoint freak now, freak?!
    • OFP NFS mod
a few things
« on: 11 Aug 2005, 07:24:36 »
Sorry for the undescriptive title, but I couldn't find a short title for these few questions and notes.

Firstly, I'm back after a week not online. (I live in another house now)

Secondly, I have 3 questions. My first question is:

I found out about the onmapsingleclick command in an executable comref. I know how to spawn a soldier with it. How do I spawn things like tanks, other soldiers, or if possible, OBJECTS?

Second question:

Is it possible to spawn something or do something wherever your pointing at? E.G. I want to launch an artillery strike at the crosshair with my binoculars.

Last question:

I only just found out about parameters. I know how to do a basic thing like this:

Code: [Select]
_tank = _this select 0
_selection = _this select 1

? _selection == 1 : goto "selection1"
? _selection == 2 : goto "selection2"

#selection1
hint "You have chosen option 1. The tank will explode in 10 seconds."
~10
_tank setdammage 1
goto "end2"

#selection2
hint "you have chosen option 2. The tank will revive without crew in 10 seconds."
~10
_tank setdammage 0
goto "end2"

#end
hint "please use selection 1 or 2 only.

#end2

exit

How do I use a parameter to set the number of something e.g. the height that the tank will teleport to like this:

Code: [Select]
_tank = _this select 0
_selection = _this select 1

#selection1
hint "You have chosen to spawn the tank in the air in 10 seconds."
~10
_tank setpos [getpos this select 0,getpos this select 1,_selection]
goto "end2"

#selection2
hint "you have chosen to launch the tank into the air in 10 seconds."
~10
_tank setvelocity [0,0,_selection]
goto "end2"

#end
hint "please use selection 1 or 2 only.

#end2

exit

And how can I use a parameter for multiple units e.g. I can put both of these commands in the console without having to add anything to the second example.

Code: [Select]
[tank1,tank2,tank3,tank4,tank5,option1] exec "test.sqs"
Code: [Select]
[tank1,option1] exec "test.sqs"
looking forward to a reply, thank you.
ofp nfs REBORN! All new nitro, neon, customized cars, off-road, on-road, rally, bikes, racer models and more!
ofp nfs's homepage

Offline 456820

  • Contributing Member
  • **
Re:a few things
« Reply #1 on: 11 Aug 2005, 11:27:33 »
okay i think i get them so ill have a bash

1. you just need the name of the tank wich im not sure what they are but it might be in the editors depot then change the 'soldierw' or whatever into the name of the tank

2. i wish so much i asked this a while a go and apparntaly its not possible but with the Laser designator it is (a tut in the ed depot by snYpir)

3. erm how about
[tank_name, height_you_want] exec "script.sqs"

im not sure on that one

and last question
4. im not totally sure but i think its something like this
[[tank1, tank2, tank3], the rest of the array here] exec "script.sqs"

thats not certain but i think its like that

hope any of that helps

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:a few things
« Reply #2 on: 12 Aug 2005, 03:39:02 »
1. onmapsingleclick {tank_name createvehicle _pos}
tank_name would be the type (find it in the config vehicles of the comref, or the ed. depot.  _pos is defined by the click so that is all you need

2. 456 has it, you need a laser designator

3. all a parameter is is a varibale defined upon execution of the script, so you could make it whatever you want, as long as you use the value of that variable correctly in the script

4. 456 has the basic idea, but what you are asking isn't something with just one answer, it depends on what you're trying to do with the array of tanks. Perhaps a better explaination?

Offline OFPfreak

  • Members
  • *
  • Who is da operation flashpoint freak now, freak?!
    • OFP NFS mod
Re:a few things
« Reply #3 on: 12 Aug 2005, 06:35:05 »
Both of you, thanks a lot. Heres some stuff about question 3 and 4.

3: Erm. I'm sorry, but could you please show an example? I don't get it. Don't blame me, blame the brain size and quality of my brain.

4: Well it kind of explains it already. I want to e.g. set the velocity or "setpos [getpos]" command
with a given number e.g.

[tank1,500] exec "speedytank.sqs" >>> make the tank go 500 kmph/mph
[tank1,200] exec "speedytank.sqs" >>> make the tank go 200 kmph/mph

with inside the script something like this:

Code: [Select]
_tank = _this select 0
_speed = _this select 1

_tank setvelocity [0,0,_speed]

exit

or

Code: [Select]
_tank = _this select 0
_speed = _this select 1

_tank setpos [getpos this select 0, getpos this select 1,_speed]

exit
« Last Edit: 12 Aug 2005, 06:36:32 by OFPfreak »
ofp nfs REBORN! All new nitro, neon, customized cars, off-road, on-road, rally, bikes, racer models and more!
ofp nfs's homepage

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:a few things
« Reply #4 on: 12 Aug 2005, 09:57:29 »
I am not sure I fully understand what you want to do:

Code: [Select]
_tank = _this select 0
_speed = _this select 1

_tank setvelocity [0,0,_speed]

exit
will fire the tank upwards at whatever speed you provide when calling the script

This:
Code: [Select]
_tank = _this select 0
_speed = _this select 1

_tank setpos [getpos this select 0, getpos this select 1,_speed]

exit
Will not work or will generate an error because this in getpos this is undefined.  Try instead:

_tank setpos [getpos _tank select 0, getpos _tank select 1,_speed]

This will then teleport the tank to a height of _speed
« Last Edit: 13 Aug 2005, 09:33:28 by THobson »

bored_onion

  • Guest
Re:a few things
« Reply #5 on: 12 Aug 2005, 11:59:25 »
Quote
And how can I use a parameter for multiple units e.g. I can put both of these commands in the console without having to add anything to the second example.

research the foreach command - that may be of some use

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:a few things
« Reply #6 on: 12 Aug 2005, 21:32:08 »
if you want to send the tank off at 500 kmph, you would need some trig to have even a chance at getting it, but i doubt it would work right anyway, due to ofp friction and other stuff, it tends to stick in place

I believe i tried teaching you some trig (along with THobson) in another thread and you gave up on it.

as for the parameters, here's how they work in a nutshell

[parameter1,parameter2,parameter3] exec "script.sqs"

that passes on those three parameters to script.sqs, which can be defined in the script.
in the script, whatever you pass to the script is defined as _this

in general, we use an array (a list inside [] brackets) and therefore to choose which one we use select:

_param1 = _this select 0
_param2 = _this select 1
_param3 = _this select 2

would then select each of the 3 parameters that you passed to the script in the array.

parameters are simply variables. they can be any value you want (string,another array, a unit, a number, etc ,etc)

you can then use whatever varible you gave that value to however you want (within the boundaries of ofp of course)

therefore if you wanted a height, you put in as a parameter and then use it where you need, if you want a variable number of units in a list, you would use another array inside the array of parameters that contains your units, and then you'd need commands like foreach which deal with arrays, or a loop that goes through each individually

Offline OFPfreak

  • Members
  • *
  • Who is da operation flashpoint freak now, freak?!
    • OFP NFS mod
Re:a few things
« Reply #7 on: 12 Aug 2005, 23:15:03 »
Yea I learned that stuff about the parameters completely now. Thanks for all your help. The only problem is the uhm.. No wait It wasn't possible anyway. I guess the thread is solved!

P.S. Beginning to go in the forums more eh TriggerHappy?
ofp nfs REBORN! All new nitro, neon, customized cars, off-road, on-road, rally, bikes, racer models and more!
ofp nfs's homepage

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:a few things
« Reply #8 on: 13 Aug 2005, 04:41:16 »
yeah, i've returned after a little while off from ofp.  
(getting back on topic....)
you might as well ask what you were going to because there are many workarounds and ways of "faking things" there's a good chance it is possible