OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: RujiK on 15 Mar 2005, 18:55:21

Title: Nearest?! WORK!
Post by: RujiK on 15 Mar 2005, 18:55:21
I did a search on this and all I could find was nearestobject, so I tried the comref to but its not in there! Every command used in OFP? HA!

So here we go, I cannot get this stupid command to do smack. Is this command used only for conditions like distance? I cant figure this stupid command out!

-thanks
Title: Re:Nearest?! WORK!
Post by: macguba on 15 Mar 2005, 18:59:56
It only works out to 50m or something.
Title: Re:Nearest?! WORK!
Post by: dmakatra on 15 Mar 2005, 19:44:15
I think there's a function in the ed depot that handels bigger distances. Don't quote me though.

:beat: *Gets Shot* :beat:
Title: Re:Nearest?! WORK!
Post by: RujiK on 15 Mar 2005, 20:54:07
ok... so it only works about 50 m... I thought that was nearestobject... maybe both, but that wasnt my question, the question is how do I use it?!
like {_x say "Howdy"} nearest _listeddude player
Title: Re:Nearest?! WORK!
Post by: Planck on 15 Mar 2005, 21:09:00
From the comref:


nearestObject pos
Operand types:
    pos: Array
Type of returned value:
    Object
Description:
    Nearest building of given type to given position or object. pos may be [x,y,z, "type"] or [object, "type"]. Although you can give it coordinates, you have to pass an object or unit to search from. Also, this command can only find objects up to 50 meters away from the stated object.

Example:
    nearestObject [player, "StreetLamp"]

Also:

nearestBuilding obj
Operand types:
    obj: Object
Type of returned value:
    Object
Description:
    Nearest building to given object.

Example:
    neareastBuilding player


Those are the only 'nearest' commands.

Hehehe......the nearest you will get to nearest


Planck
Title: Re:Nearest?! WORK!
Post by: Kyle Sarnik on 15 Mar 2005, 21:45:35
I did a search on this and all I could find was nearestobject, so I tried the comref to but its not in there! Every command used in OFP? HA!

So here we go, I cannot get this stupid command to do smack. Is this command used only for conditions like distance? I cant figure this stupid command out!

-thanks

Thats because there is no "nearest" command, only nearestobject or nearestbuilding, anyways nearestobject is what you want, it will detect any type of object, be it vehicle (includes soldiers), ammo, buildings, bushes (correct me if im wrong), and maybe some others that I can't think of.
Title: Re:Nearest?! WORK!
Post by: RujiK on 16 Mar 2005, 00:37:59
Go into the game, type "ne" and nearest pops up.
Title: Re:Nearest?! WORK!
Post by: General Barron on 16 Mar 2005, 00:54:54
Go into the game, type "ne" and nearest pops up.

Interesting... it does. However, there are other examples of commands showing up like this that do not really exist. Perhaps "nearest" was intended to be a command, but was never fully implemented. That's the best I can do. If you do manage to get this "nearest" command working, please tell us how, because you will have discovered a command that has never been used before :)
Title: Re:Nearest?! WORK!
Post by: RujiK on 16 Mar 2005, 03:23:03
:( oh well.. thanks for the help, better go look up nearest object...
Title: Re:Nearest?! WORK!
Post by: johan_d2 on 17 Mar 2005, 00:38:56
Its fun to pick up any soldier of your side to join you for example:

; follow me.sqs
; get nearest soldier to join your team, if slots open, and assuming your rank


_victim = nearestobject [((getpos player select 0) + 3*(sin getDir player)), ((getpos player select 1) + 3*(cos getdir player)), getpos player select 2];
hint format ["%1",_victim," joined"]
[_victim] join pteam
exit

start with init field of player:

_follow = player addaction["Follow me","follow.sqs"]

name yourself pteam

have fun!