Home   Help Search Login Register  

Author Topic: speed command not working  (Read 1169 times)

0 Members and 1 Guest are viewing this topic.

Swatdog

  • Guest
speed command not working
« on: 22 Dec 2005, 00:16:07 »
Hey all, I'm making a convoy mission much like Desert Ambush on Malden, but with many many enhancements. Anyway, I'm trying to make a time calculator, by finding the current speed of the convoy, and then dividing that by how many meters away the convoy is from the player. I know how to do it, but the speed command isn't working for me.

I have:
_convoyspeed = speed conlead

conlead is the leader of the convoy's group. I tried that and it returns the value as '0', so I tried:

_convoyspeed = speed brdm

brdm is the lead vehicle's name. The BRDM is an empty vehicle with conlead assigned as the driver. Would that make a difference?

Anyway, help would be MUCHLY appreciated.

Thanks
« Last Edit: 22 Dec 2005, 00:17:12 by Swatdog »

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:speed command not working
« Reply #1 on: 22 Dec 2005, 00:20:33 »
From the description I am not sure why it isn't working but have you tried:

_convoyspeed = speed vehicle conlead

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:speed command not working
« Reply #2 on: 22 Dec 2005, 00:22:39 »
Don't use strings that occur in the game (such as BRDM) for vehicle names, it can lead to .... undocumented outcomes.    Call it "BRDM1" or something.

Don't use a named unit when you can avoid it:  he might have been killed.   Much better to use

leader grp1

which will work as long as somebody in the group is still alive.
Plenty of reviewed ArmA missions for you to play

Swatdog

  • Guest
Re:speed command not working
« Reply #3 on: 22 Dec 2005, 00:27:06 »
Ok, thanks guys. I'll try your suggestions.

Swatdog

  • Guest
Re:speed command not working
« Reply #4 on: 22 Dec 2005, 02:05:32 »
Ok, I got it to work. Thanks guys. But I still have a problem with another part of my script, but I dont feel like creating a new topic just to discuss it so I'll post it here.

Here is the code I have to calculate the time it'll take for the lead vehicle in the convoy to reach the player's group:

#loop
;Get the speed of the lead vehicle
_convoyspeed = speed vehicle brdm1
;Get the distance to group's leader
_convoydist = leader convoy distance leader marines
;Establish estimated time
_convoytime = (_convoydist) / (_convoyspeed)

; Show speed (debug)
hint format["Current speed:\n%1\nDistance:\n%2\n------\nEstimated time:\n%3",_convoyspeed, _convoydist,_convoytime]

~2
goto "loop"

I go and load up the mission and I get this error:
'_convoytime = (_convoydist) / (_convoyspeed)|#|': Error Zero division

At first I figured that maybe _convoyspeed isn't defined before it reaches that part of the script to display it causing it to divide something that isn't defined. BUT it works once the convoy starts going and gets some speed and then it displays the estimated time.

Is there a way to avoid this error being shown? I don't mind having an error in the script because it obviously works, but I just don't want it to be seen.

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re:speed command not working
« Reply #5 on: 22 Dec 2005, 02:54:43 »
Simply change the last line:
Code: [Select]
_convoytime = (_convoydist) / (_convoyspeed)to this:
Code: [Select]
? _convoyspeed > 0 : _convoytime = (_convoydist) / (_convoyspeed)Or you can do this:
Code: [Select]
? _convoyspeed == 0 : _convoyspeed = .000001
_convoytime = (_convoydist) / (_convoyspeed)

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re:speed command not working
« Reply #6 on: 22 Dec 2005, 02:58:12 »
I just noticed another problem.  The speed command gives speen in k/h, but the distance is in meters.  So your time will not be correct.  You have to convert the speed to m/s.  So:

Code: [Select]
_convoyspeed = _convoyspeed * 1000 / 3600
? _convoyspeed == 0 : convoyspeed = .0001
_convoytime = (_convoydist) / (_convoyspeed)

LoTekK

  • Guest
Re:speed command not working
« Reply #7 on: 22 Dec 2005, 06:07:48 »
Check the bugged command thread. I recently submitted an entry relating to speed and velocity. The long of the short of it, is that neither commands work properly on a unit in a vehicle, instead returning the last recorded speed/velocity of the unit before entering the vehicle.