Home   Help Search Login Register  

Author Topic: distance?  (Read 597 times)

0 Members and 1 Guest are viewing this topic.

Offline dalton

  • Members
  • *
  • i R n00b
distance?
« on: 11 Feb 2004, 14:17:07 »
i want the player to add an action when he is a certain distance away

what i did was this:

? (_player1 distance vehicle)<3:[] exec "script.sqs"

then in my otha script i did:

_player1 addaction ["actionname", "script.sqs"

so which 1 is wrong with it and how can i fix it?
« Last Edit: 11 Feb 2004, 14:20:28 by dalton »
"freedom aint free"

Offline Marvin

  • Members
  • *
  • One day they will come
Re:distance?
« Reply #1 on: 11 Feb 2004, 14:20:35 »
You have to put

? (_player1 distance vehicle <3):[] exec "script.sqs"

I hope that there are defined unit _player1
and there are vehicle named vehicle


and the other myst have after addaction ] - mayby they disapiere when you copy!
« Last Edit: 11 Feb 2004, 14:24:24 by Marvin »
Is there any games than Flashpoint?

PsyWarrior

  • Guest
Re:distance?
« Reply #2 on: 11 Feb 2004, 15:01:23 »
Greetings,

What is _player1 supposed to be, exactly?

the "_" is only really used in .sqs scripts to define local variables as Marvin says, if you call your player "player1" and the vehicle "vehicle", then all you need is this:

In a script:

Code: [Select]
#loop
? player1 distance vehicle <3: player addAction ["Action", "script.sqs"]
~0.1
goto "loop"

In a trigger:

Condition: player1 distance vehicle <3
On Activation: player1 addAction ["Action", "script.sqs"]

That should solve your problems.

Regards,

-Supreme Commander PsyWarrior
-Psychic Productions

gundernak

  • Guest
Re:distance?
« Reply #3 on: 11 Feb 2004, 15:12:52 »
I would suggest you to not use these names as 'vehicle','ammo'...these are syntaxes in the scripting language of OFP, and you can have difficulties because of it.

Always add a number or something to these names....for example: 'vehicle01'

Offline Marvin

  • Members
  • *
  • One day they will come
Re:distance?
« Reply #4 on: 11 Feb 2004, 15:17:28 »
then i suggest you to not use _player1, byt use player1 without _
of course if you named your player - player1

This is jyst a way to do this in scripting!
« Last Edit: 11 Feb 2004, 15:24:28 by Marvin »
Is there any games than Flashpoint?

Offline dalton

  • Members
  • *
  • i R n00b
Re:distance?
« Reply #5 on: 12 Feb 2004, 00:39:43 »
thnx guys

but the only problem is that when i use the loop, the action keeps coming up and coming up and it neva stops

o yea btw my vehicle is not named vehicle but if i give out the name then it will ruin the surprise for what the mission is about
« Last Edit: 12 Feb 2004, 01:52:39 by dalton »
"freedom aint free"

Offline Marvin

  • Members
  • *
  • One day they will come
Re:distance?
« Reply #6 on: 12 Feb 2004, 09:56:09 »
Then Use like PsyWarrior sad! Use the trigers to activate script, and you can crate onother striger, when the player is 3 meters from car then on activation you can add removeaction!
« Last Edit: 12 Feb 2004, 09:56:58 by Marvin »
Is there any games than Flashpoint?

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:distance?
« Reply #7 on: 12 Feb 2004, 10:14:32 »
errm - why don't you simply add the action to the vehicle?

That way you wouldn't need your scripts, and it would still
be the very same effect as what you want to do by these
scripts.

Once the player gets close (let's say 3 - 5 meters) to the
vehicle, the action of the vehicle will appear.

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

PsyWarrior

  • Guest
Re:distance?
« Reply #8 on: 12 Feb 2004, 14:04:06 »
Greetings,

If you are scripting an action, you have to make sure that you remove the action when the condition is no longer true. So a solution would be:

#loop
? player1 distance vehicle1 <3: goto "engage"
~0.1
goto "loop"

#engage
action = player1 addAction ["Action", "script.sqs"]

#disLoop
? player1 distance vehicle1 > 3: player1 removeAction action; goto "loop"
~0.1
goto "loop"

gundernak, note addition of '1' to vehicle...point taken, my mistake...  ::)

Or you could do as Chris says - I temporarily forgot that you can see the actions of other units when you get close to them.  :-[

-Supr. Cmdr. PsyWarrior
-Psychic Productions