OFPEC Forum
Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting Multiplayer => Topic started by: laggy on 26 Jun 2009, 01:30:20
-
Hi all,
Working on a dog tracking script and YES I know .sqs is obsolete, but this script is so simple it won't matter and I always start by making my scripts in .sqs before implementing them in .sqf anyway >:(
What I'm worried about is if the unit name "trackDog1" will be recognized by all clients and thus making everyone hear the barking effect.
The script works through the init field of a unit that is deleted and replaced by a dog. The script is called by: [this] exec "dogtrackingparty.sqs", which looks like this:
_dummy = _this select 0
_trackers = group _dummy
deleteVehicle _dummy
~ 1
? isServer : trackDog1 = _trackers createUnit ["Pastor", position leader _trackers, [], 0, "FORM"]; publicVariable "trackDog1"
[trackDog1] join grpNull
trackDog1 joinAs [_trackers, 2]
~ 1
trackDog1 setskill 1
trackDog1 setSpeedMode "FULL"
trackDog1 allowFleeing 0
~ 1
[trackDog1] exec "dogBark.sqs"
? ! isServer : exit
#choice
_preyNum = count preyList
_preyChoice = floor random _preyNum
_chosenPrey = preyList select _preyChoice
#trackloop
? ! (alive trackDog1) : exit
_trackers move getpos _chosenPrey
@ unitReady leader _trackers
if (! (alive _chosenPrey)) then {goto "choice"} else {goto "trackloop"}
The: [trackDog1] exec "dogBark.sqs" must be recognized by all clients... Will it be?
Thanks in advance... and please no jokes about .sqs :-[
Laggy
-
i'd put a
waitUntil { !isNil {trackDog1} };
before you start using the trackDog1 variable after the isServer thing, so the clients won't execute anything with an undefined variable (which arma2 now creates an error report for in the rpt-file).
I have no idea how to write that in sqs though (sqs is so 2003 ;))
-
.sqs ;)
@ ! isNil trackDog1
-
Mikey, your code is so 2006 and would only work in A1; it would cause an error is A2 :D. The other thing is to remember to quote the name of the variable rather than give it, just like with publicVariable.
waitUntil { !isNil "trackDog1" };
@ !isNil "trackDog1"
But seriously, if you want to check a variable, always use the "" version:
isNil "trackDog1";
The alternative bracketed form should only be used for "derived" values, such as array elements or variables on things:
isNil { array select 5 }; // Where you are sure that 'frog' is defined, but not sure about 6th element.
isNil { obj getVariable "fish" }; // Where you know obj exists, but not sure about "fish" on it.
-
Mikey, your code is so 2006 and would only work in A1; it would cause an error is A2 :D.
You sure? cause i dont see any errors in the rpt, and I even saw it being used in the modules.
But ok, when using variable names, pass it as a string if you wanna be hip and contemporary :)
-
Yes, this is a key change in Arma 2. That is, that you now get error reports when you try to reference an undefined variable. There are situations, though, where Arma suppresses the error messages (from even RPT) which is very annoying.
Just because a random BIS contractor did something in a module, doesn't mean they know what they are doing any more than the community member they were before they signed a contract (though generally they do ;)).
-
Thanks all :D