OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Multiplayer => Topic started by: Pathy on 23 Feb 2007, 02:09:05

Title: Viewdistance in MP script
Post by: Pathy on 23 Feb 2007, 02:09:05
Hi. *waves*

I'd like to set up a script that will give certain players different viewdistances in ArmA MP.

Ie, infantry have 1500m viewdistance, pilots have 6000m view distance, Armour crewmen have 2000m viewdistance.

I have previously used something similar in OFP - only it doesnt apparanetly transfer to ArmA well, instead causing crashing when you try and select a 'modified' unit. In OFP what you'd do is put say, a chinnook down, put your pilot in, and call the chinook, say, ch1.

You'd then have an init.sqs with


Code: [Select]
?(Player == Driver ch1): SetViewDistance 4000;

The script would then detect at startup the driver of that vehicle and give him the viewdistance value specified.

I am, however, no scripting guru, and i'm clueless as to how to get a similar thing working in ArmA - my attempts so far seem to work in SP, but in MP, they give a CTD to whoever tries selecting a unit that has viewdistance upped via script. Any advice, hints or outright solutions would be much appreciated.
Title: Re: Viewdistance in MP script
Post by: Maverick2002 on 23 Feb 2007, 08:42:07
This may work:  if(typeOf driver ch1 != "SoldierWPilot" )then{SetViewDistance 4000}
May no need the "{}"...
Title: Re: Viewdistance in MP script
Post by: Pathy on 23 Feb 2007, 08:50:59
Will give it a go. Many thanks.
Title: Re: Viewdistance in MP script
Post by: Pathy on 23 Feb 2007, 17:41:18
Still no luck i'm afraid. It's strange actually, the script i originally posted works in ArmA singleplayer beautifully, but put it in MP and it just causes crashes to whoever has modified viewdistance.
Title: Re: Viewdistance in MP script
Post by: WhisperOFP on 23 Feb 2007, 18:41:49
Your best solution is to use eventHandlers get in and get out to change the view distance on the fly.

One point, though : your viewDistance is local to your machine, that means it can go further than only your soldier : all the AI units under command of the player share the same viewDistance, which effects their spotting capabilities. the max scan Range is dependant on view distance setting.
So, if a player enters a vehicle, and has other disembarked AI units, all his AIs (the one in his squad) will suddenly be able to spot things farther away than any other AI in the same game.