Home   Help Search Login Register  

Author Topic: Spawn a Tent  (Read 2489 times)

0 Members and 1 Guest are viewing this topic.

LooseKannon

  • Guest
Spawn a Tent
« on: 09 Sep 2006, 12:45:57 »
Hello all.

I am working on a mission which gives the player the opportunity to pitch a tent during the evening. I have hit a snag however, I do not know the command to check if time is 1600 or more but less than 0400 and give the player the option to spawn "aTent" two or so meters in front of themselves, with a fire if possible  :thumbsup:

If somebody could help me out with this one I would greatly appreciate it.

Cheers,
LooseKannon

Offline Cheetah

  • Former Staff
  • ****
Re: Spawn a Tent
« Reply #1 on: 09 Sep 2006, 12:58:15 »
There's a few options for the time of day. First, you can use the time command. With it you can determine how much time has passed since the beginning, and with it I'm sure you'll be able to figure out how  to detect 0400 hours.
I didn't use this for a mission that was just for testing and developing my skills, I made my own time script which I ran from the init.sqs and gave the mission time, hours/minutes/seconds as the test mission required a lot of coordination (bus traffic, police traffic etc.).
If you want I could send it to you, but I think that it's too much for your purpose.

About the tent, you can create it by using this line:
tent = "CampEast" createVehicle [0,0,0];
A fire:
fire = "Fire" createVehicle [0,0,0];

After creation you want it two metres in front of the player, you should use getDir and getPos together with a bit of maths to place them two metres in front of the player. Possible setting the direction of the tent with setDir. If you can't make it on your own, just ask for help and I or someone else will help you. But you learn the best by trial and error, so I'd say try it yourself if it doesn't work or you run into problems ask for help.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

LooseKannon

  • Guest
Re: Spawn a Tent
« Reply #2 on: 09 Sep 2006, 13:02:31 »
Cheers for the help!

I had a go in the editor with it, i ended up spawning it in the middle of the ocean :P

Could you please throw it together for me if possible?

Cheers.

Ill have another go at it now...  :banghead:

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: Spawn a Tent
« Reply #3 on: 09 Sep 2006, 13:03:34 »
You could also use the daytime command to find out the time of day.


Planck
« Last Edit: 18 Jan 2009, 02:28:52 by Planck »
I know a little about a lot, and a lot about a little.

Offline JasonO

  • OFPEC Patron
  • ****
  • Oh no...
    • The New Life RPG
Re: Spawn a Tent
« Reply #4 on: 09 Sep 2006, 13:14:53 »
The reason its in the sea is because you need to use the setpos and setdir commands as Cheetah said.

Quote
tent = "CampEast" createVehicle [0,0,0];
fire = "Fire" createVehicle [0,0,0];

fire setpos [(getpos unitname select 0)+#, (getpos unitname select 1)+#, getpos unitname select 2]
tent setpos [(getpos unitname select 0)+#, (getpos unitname select 1)+#, getpos unitname select 2]

That makes the tent and fire and puts the tent at your position.
Change unitname to your units name and the '#' to a number (all are in bold) to what ever you want. Experiment with the numbers to get the position you want.

The position is in the format [X,Y,Z] . Z is the height, and you probably wont use it in this script.

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re: Spawn a Tent
« Reply #5 on: 09 Sep 2006, 13:29:10 »
INIT.SQS
Quote
Player addaction ["Set Up Camp", "campsetup.sqs"]


CAMPSETUP.SQS
Quote
?(daytime > 4)&&(daytime <18): hint "Cannot set up camp at this time"; exit
_user = _this select 0
_id = _this select 2
_tent = "tentclass" createvehicle [0,0,0]
_fire = "fireclass" createvehicle [0,0,0]
_dist = 1
_height = 0
_camp = [_tent,_fire]
{_dist = _dist + 1; _x setpos  [(getpos _user select 0)+sin(getdir _user + 180)*_dist,(getpos _user select 1)+cos (getdir _user + 180)*_dist,_height]; _x setdir (getdir _user); _user reveal _x}foreach _camp
_fire inflame true
_user removeaction _id

To optimise this, and if only 1 player can set up camp, then instead of createvehicle objects, create them in the mission editor and set them in some lonely non playable area, then add their names to the _camp array


__________________________________________________________________________________________________ _
Additional info
The following line could be further simplified, by removing the _height and replacing it with a 0, and the reveal command is not required, however i use this piece of code for lots of different things, so i have left it in its most useable state

Replace the 180 to get different positions in relation to the _users position
_dist can be edited to get things closer or further away
_height, normally set to 0, but if you wanted to stack a set of sandbags etc, then simply add additional lines such as "_height = _height + 0.9"  after the distnace increment

{_dist = _dist + 1; _x setpos  [(getpos _user select 0)+sin(getdir _user + 180)*_dist,(getpos _user select 1)+cos (getdir _user + 180)*_dist,_height]; _x setdir (getdir _user); _user reveal _x}foreach _camp


OOPS Sorry Jason, you replied while i was typing !!!
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

LooseKannon

  • Guest
Re: Spawn a Tent
« Reply #6 on: 09 Sep 2006, 13:40:13 »
Excellent. I shall go-a-testing now. Cheers for the help all!  :good:

Offline JasonO

  • OFPEC Patron
  • ****
  • Oh no...
    • The New Life RPG
Re: Spawn a Tent
« Reply #7 on: 09 Sep 2006, 21:22:38 »
OOPS Sorry Jason, you replied while i was typing !!!

He he, I havnt tested my method so it probably dont work. I suggest trying Terox's script first :P

LooseKannon

  • Guest
Re: Spawn a Tent
« Reply #8 on: 10 Sep 2006, 06:16:16 »
Success!

Thanks for the help all  :D

Yes you were right Jason0  :P