Jump to content
Sign in to follow this  
Nightjay0044

Advancing in Scripting

Recommended Posts

Hey all, I've tried to attempt scripting for some time. Although some things are coming a little more clearer to me I still need a lot more studying to do.

Alright I understand the very basic of a script. Example..

-How to execute a script

-What a script is

-What a script looks like

-intro to arrays

-intro to variables

-intro to other symbols.

So I just don't know how to proceed any farther.

How to execute a script that's simple.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[] exec "script.sqs"

Now what I know of arrays is this.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[array1,array2,array3,array4,etc] exec "script.sqs"

now these arrays are assigned to the variables well the local varialbe in the script...such as...

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Unit = _this select 0

I know how to use the local varaibles to make soldiers do stuff in the game such as behaviour or addweapons and simple things like that, but once it gets to anything past that such as creating a bomb, or arty strike or anything like that I'm not sure what to do....Also I do have "Johan Gustafsson" tutorial. But that's not always easy to understand.

Perhaps someone can give me of another simple script I can study or something or some type of advice....

Thanks all...

Share this post


Link to post
Share on other sites

Hello Nightjay0044!

First, I want to make sure you know that you can also execute a script like this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">player exec "script.sqs"

and then anywhere in your script where you need to access the player, you would need to use only _this. I told you this because I don't want you to start writing [player] exec "script.sqs" and then in your script _unit = _this select 0, which would be quite pointless (to create an array for only one variable).

Hmm... then a little bit of advices... the best way to learn more advanced scripting is to sit down and start experimenting. You could simply just take the official comref and start reading through it, testing commands in the editor when finding an interesting one. What do they do, what you can use them for. That's how I started. I didn't create actual missions for a long time, I just experimented with the scripting commands. Don't think about creating a big and amazing mission right away, it is not a realistic goal. Just keep testing different things in the editor like these: how do you make a group eject a chopper, how do you get a boat to transport a group over a river et cetera. Test these things and do not even try to create a mission around it. Because if you want to learn scripting, it's not important to design a whole mission. You will just feel depressed when you notice that it's not that simple and fast thing to do. Keep your goals small and you will feel that you have succeeded in something. After that it's much easier to move on into more difficult things, like designing a mission.

Also it can help alot if you take a peek at other people's work, how did they do it? Take a mission which has artillery and nice cutscenes, unpbo it and go through the code. Make the same stuff into your own mission, starting from the more simpler things. Don't be afraid of making mistakes, I do them all the time and so do others despite of what they might like you to think.

Also take in notice, do you really need scripts? In my opinion the less stuff you have inside your mission folder, the better. If your mission still has everything needed to make the players enjoy that is.

Cheers,

Baddo

Share this post


Link to post
Share on other sites

Please see this post I just answered.

http://www.flashpoint1985.com/cgi-bin....t=51433

I discuss global variables, local variables, scripts, and arrays.

In a sense baddo is right... the less scripts the better. However, soome desires are absolutely impossible without them. Knowing about them will certainly make mission making easier.

Share this post


Link to post
Share on other sites

Okay with scripting, I think I might need some more help or a mentor or something. Because scripting is a hard subject for me to understand.. but the thing is I know that I can understand it. Because I know how to write a very basic script with soldiers and I understand local and global variables.

Alright, so maybe crashdome, you could or somebody could possible help me describe what a variable is and what it can do. I mean I'm talking like step-by-step info and descriptions.

Because I don't think I understand enough to experiment..Maybe someone could give like a variables for dummies lesson on this topic or something..

also crashdome, the topic that you gave a description on kind of went over my head.

That would help a lot...Thanks

Share this post


Link to post
Share on other sites

lol... ok. I've never heard anyone profess that so bluntly, but since you've got courage I'll try and explain as best as I can.

Please kep in mind as you are reading that I am going to speak in terms of programming in general w/o all the technicalities. This is OFP scripting... yes... but you need to know the very basics it seems.

VARIABLES

Variables are simply names or temporary IDs we give to values. You actually use something like variables everyday but probably don't realize it. For example, the word "you" can be a variable. You are Nightjay0044. In a weird way I am assigning that when I say the word 'you' that I mean NightJay0044. However, You could refer to something else at any other time. It is all based on context.

It is very important to understand context in terms of programming/scripting. Context is what we call 'scope'. In this thread I am speaking to you and giving that specific word value. However, in another thread somewhere ... the word you could mean something totally different. That would be what we call a different 'scope'.

Variables are sometimes referred to as being like a container, but that is generally not true. It doesn't have to contain anything and containers are usually something totally different in most programming languages.

There are also specific types of variables such as integer, real number, object, etc... but that will come later. For now, just lump it all together.

OBJECTS

When you open the mission editor and you place a unit on the map it is an object. Not because it is physically represented as an actual 3D object, but simply because it has properties and can be manipulated or referenced. For example, not only is the player an object, but a waypoint, a trigger, and other items can be referred to as objects.

These have properties (like skill, armor, health, etc..) which hold a value and we collect all these values together and call it an object. Since many objects are similar (e.g. M1A1 is like a T-72) we give them the same class (e.g. Tank)... Sometimes objects like Tanks inherit from other objects like the 'Vehicle' class. All vehicles have a location in 3D space, they move, and they have health... etc.. so a Tank is nothing more than a sub-class of Vehicle.

Classes and such aren't really important in scripting, but it helps to know the underlying method of the way this stuff works to help ease the understanding of scripting.

SCRIPTS

Ok now to the nitty-gritty.

Scripts are nothing more than a sequence of programming commands which will manipulate the objects of OFP and use variables to store data.

Example:

MyUnit = player

Here we assigned (=) the object player to the MyUnit variable. Now, whenever we refer to MyUnit the computer will understand that we mean the player object.

Likewise:

MyNumber = 5

Here we assigned a value (not an object). But the computer will understand that when we say MyNumber, we mean the value 5.

Note: You cannot use just any word or phrase for a variable. For example, you cannot use a variable name that is the same as a command or reserved word. i.e time is a reserved word and the code:

time = 12

will not work.

[End of lesson 1]... gotta go somewhere. I'll write more later.

Share this post


Link to post
Share on other sites

Okay, lets see if I can understand this correctly.

A Variable is something that can be given a value, such as a tank, waypoint, soldier, trigger etc?

Alright, I say if I experiment, we should start with something simple. What can we do with lets put a car and a couple of soldeirs down in the editor. What could we do to create a script using them 3 objects?

Share this post


Link to post
Share on other sites

Since I'm bored i'll give you my own rundown of the subject.

A Variable is something that can be given a value, such as a tank, waypoint, soldier, trigger etc?

Pretty much, a variable is basically any word with a value attached to it. For example, In an init field you could put 'myname="korax"' and now any time you refer to 'myname' in a script, or trigger, it will return "korax".

A variable can store a number, e.g. pi=3.14159, a TRUE or FALSE (useful later on), or it can store an OBJECT* e.g. putting 'man1 = this' within the Init field of a soldier in the mission editor, would make man1 always refer to that soldier.

*Object is a fairly loose term, it can mean a player, soldier, empty vehicle, trigger, etc

Or it can also store strings (Anything within quotations, usually meant for text, if you have an objects name within quotations, nothing will happen, like myname="man1" wont return the soldier you defined earlier, just "man1".)

And last but not least, Arrays, which can be a series of objects or strings (or even other arrays) within brackets seperated by comma's. e.g. player123=[man1,"Korax",18]

There are also 2 type of variables you need to keep in mind, global variables and local variables. global ones are the ones i've explained above, but a local variable always begins with an underline (e.g. _num1 = 234). Local variables can ONLY be used within an actual script (like init.sqs) and once that script finishes (Or exits) then that local variable will be erased. these are useful for doing calculations that dont actually need to be seen ingame.

You CAN use both global and local variables inside a script if you want, but if you try to use a local variable inside the mission editor, in an Init line, you will get an error.

And i'll post again about experimenting with the car and soldiers in a minute

Share this post


Link to post
Share on other sites

You need to know all (or atleast some) commands if you want to script anything, so you should check the official comref (or dload it here)

Now, if you want to tinker around with a script, place a few soldiers down in the editor and name them man1 and man2, and also place an empty jeep and name it jeep1

(You can name vehicles 2 different ways, either putting the name in the 'Name' box in the mission editor, or within their Init field you put jeep1 = this)

And what to do with these things is entirely up to you, say you want to put one soldier in the jeep, and have him drive to the other soldier, and when he's there to give you a hint.

First off, execute the script somewhere in the mission like [] exec "myscript.sqs" (dont worry about putting anything within the first brackets, they need to be there, but they dont need to have anything in them.)

Now make myscript.sqs and put it in the mission dir (I assume you know how to do that) and open it up. The first thing you need to do is put one soldier in the jeep. you can do this with one simple command. man1 moveindriver jeep1 - This will instantly place him in the drivers seat of the jeep. If you want him to physically move to and climb in the jeep, its a little bit harder.

Now that he's in the jeep, you need to tell him to move somewhere. This can be done with the domove command, but for this command it needs someone to move, and a position for him to move. Find the second soldiers position with _pos = getpos man2. Now _pos will tell you exactly where man2 is. So if you add this onto the end of your domove command, it should work. your script should look like this:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">man1 moveindriver jeep1

_pos = getpos man2

man1 domove _pos

*note that the _pos = getpos man2 will only save man2's position at that current point in time, and if he moves later on, the _pos will not change

Simple but effective, but say you want the script to wait untill man1 reaches his destination at man2? Use a @ condition to wait for anything to become TRUE. e.g. the command unitready soldier will return either TRUE or FALSE depending if the soldier is done his current order, since you just gave man1 an order to move, you know his unitready status must be false, and when he gets there it will be true. So you just have to use the condition like so:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">@unitready man1And the script will wait at that line untill the unit is ready. To notify yourself that the soldier has indeed arrived, you can just use a hint. the hint command just needs a string (something in quotations) and it will immediately do the annoying 'PING!' and show your message in the top left corner of the screen.<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">hint "Man1 has reached his destination"

Now that they are together, lets have man2 physically climb in the jeep, to do this you simply have to assign the soldier to a certain slot in the vehicle, and then order him in.<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">man2 assignascargo jeep1

[man2] ordergetin true

I'm not gonna explain the ordergetin command, thats simply how it is. Now you want to wait untill man2 is in the jeep with unitready again<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">@unitready man2

Now at this point of the script, both soldiers should be in the jeep, waiting for something to do. The whole script should look like this:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">man1 moveindriver jeep1

_pos = getpos man2

man1 domove _pos

@unitready man1

hint "Man1 has reached his destination"

man2 assignascargo jeep1

[man2] ordergetin true

@unitready man2

Theres your simple script, i'll leave you to decide what to add onto the end.

Some fun things to try might be:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_pos = getpos jeep1;"shell120" camcreate _pos

or

jeep1 setvelocity [(velocity jeep1 select 0),(velocity jeep1 select 1),100]

Etc... The ofp world is your virtual oyster, search the comref for cool stuff to try and play around in the editor lots, its the best way to learn

Share this post


Link to post
Share on other sites

Sorry, I was called away for something very important and couldn't finish.. but Korax has pretty much finished it off for me (thx Korax)

Side-Note: There has been a few people in here now looking for very basic info that OFPEC usually provided very cleanly. I think I am starting to believe we need a bit more redundancy... more websites mirroring this type of info.

Don't get me wrong... I love OFPEC for what it does, but man... the fact that the site is down is having a huge impact on the community like none I have ever seen before...

Share this post


Link to post
Share on other sites

It's not only OFPEC to 'blame' for such situation, but also the people for not having much self initiative, and sometimes, yes, even their lazyness.

@Nightjay0044

This is not ment (strictly) personal, it's more like a general note.

Share this post


Link to post
Share on other sites
Side-Note: There has been a few people in here now looking for very basic info that OFPEC usually provided very cleanly. I think I am starting to believe we need a bit more redundancy... more websites mirroring this type of info.

Don't get me wrong... I love OFPEC for what it does, but man... the fact that the site is down is having a huge impact on the community like none I have ever seen before...

In the future it will be much harder to "bring" OFPEC website down for this long time, because backup facilities will be greatly improved from what they have been. Without a very generous donation this would not have been possible. People, make sure you donate for OFPEC once the website gets back up and running wink_o.gif I will do it for sure.

I think there is no need to duplicating what OFPEC has. Instead the community could ensure that OFPEC has all the best resources and up-to-date information by contributing as much of their knowledge as possible to the website smile_o.gif If you are an author of a useful tool or have written tutorials but didn't submit them to OFPEC, please take the little time needed to submit them to OFPEC. That's the best way the community can help OFPEC and the best way OFPEC can help the community. Remember: by the community, for the community.

In my opinion, there should be more beginner-beginner-level tutorials at OFPEC. That has to change in the future.

Share this post


Link to post
Share on other sites

I don't really have much to add here about scripting basics (been covered pretty well), but I will throw my 2c in about learning scripting.

-------------------

The way I learned it was accidentally and a little at a time. I started out editing in the map editor, and I kept telling myself "I don't want to learn scripting". Then I'd start placing little code bits in waypoints, init fields, etc, like: dostop this, man1 addmagazine "m16", grp1 = group this, grp1 setbehaviour "combat", etc.

I didn't fully understand everything about the code I was using, but I'd read it on a website and discovered it did what I wanted. I still told myself "I don't want to learn scripting", even though these were in fact scripting commands.

Next, I started using other people's scripts in my missions, such as arty strikes, helo ejections, etc. While I was at it, I would peek inside of them and try to figure out what was going on. But I still didn't want to learn scripting.

Then I started making lists of commands in an external script file in order to enhance my mission. I wanted to do a bunch of those little bits of code I had been putting in triggers, init fields, etc. It was more convienient to put them in a script file, instead of in that little field. But I still didn't want to learn scripting.

Eventually, I started learning about conditionals, gotos, local variables, and the other things that control the 'flow' of scripts. I learned them by looking at other people's scripts and connecting it to my small amount of prior programming knowledge. I started using them in my little scripts to do stuff that I couldn't do without them. From that point on, I started learning more and more as I tried to script this or that for my missions.

-------------------------

Now what was the point of this story.... oh yeah, I remember! smile_o.gif The point is, you are prolly going to learn better if you are trying to actually script FOR something in a mission. I mean, if you have a reason to learn how to do something with scripting, because you need to put it in a mission, as opposed to just trying to think of 'something to script involving 2 jeeps and a duck'.

If I can learn scripting by accident that way, then I'm sure you can intentionally learn it pretty quick.

Share this post


Link to post
Share on other sites
Quote[/b] ]KOREX~

Hey I will be testing your script test out soon. I will post feedback once finished.

GENERAL NOTE:

Yes we do need more beginner tutorials on different parts of the game. Yes there are great tutorials out there, but then again there are poeple like me who need more spelled out information and guidence keep that in mind. I mean OFP Editor interface is one of the most userfriendly out there but some aspects are hard to learn. I mean everybody has different learning styles for OFP Editing. People learn in their own way.

I mean here's a concept that triggerhappy gave me. Understand what each command means and then put it in your own words,, something along those lines. Because everybody has different point of views how they learn things and how one person learns variables maybe completely different from what another person learns.

Yes OFPEC is one of the greatest resources out there compared to the official BIS site. Meaning OFPEC is one of the next on the list. I think it's alright for other OFP fans and users to make their own websites for OFP just like OFPEC has their own. But if they create tutorials, missions, campaigns, scritps etc they should also submit them to OFPEC database.

Because then if a lot of users have their own websites you can browse by username sites and also OFPEC. Not saying people are trying to make OFPEC obsolete. Because I hope that is around for awhile..It's like this quote from me.

"OFP is like starwars, new generations will come to experience it"

In a way that's true. Although I don't want to make this reply too long here because the origanal post I made was about learning scripting..so hmm maybe we should go too OFF topic from that....

Thanks for the replies everyone...Keep them coming..

smile_o.gif

Share this post


Link to post
Share on other sites

Well, I thought i should put a post here since i´m learning about scripting too.

I would say I´m at an intermediate level when it comes to scripting.

I can really relate to General Barrons post, i was thinking the same thing:

"I don´t want to learn scripting". Well, the rest is in his post

but that´s how i started anyway.

I understand variables, different commands, loops, making simple calculations, etc.

One of the things I am having some trouble with though, is formulating long sentances correctly in a script.

I can´t really think of an example at the moment though.

I know there is a topic on scripting syntax in the official comref but that

doesn´t really explain everything.

I don´t mean to steal the whole topic here but I was just wondering

if there is a more detailed explanation anywhere on using the more

advanced commands correctly.

I guess I will learn sooner or later but it would sure help if had something to consult

instead of the trial-and-error scripting I´m doing now.

Edit: I should say "rather than the trial-and-error scripting" instead, since that´s a great way for me to learn..

Share this post


Link to post
Share on other sites
I understand variables, different commands, loops, making simple calculations, etc.

One of the things I am having some trouble with though, is formulating long sentances correctly in a script.

I can´t really think of an example at the moment though.

What kind of long sentences are you talking about? I'm not really sure what you'd classify as long, there can be anything from this:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? (leader _group) distance _obj < 3500 : _obj move [(getpos (leader _group) select 0)+100-random 50,(getpos (leader _group) select 1)+100-random 50,0]

to large IF () THEN {} statements

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">IF ((Getpos player select 2)>10) then {player setvelocity [(velocity player select 0)+(sin (getdir player))*50,(velocity player select 1)+(cos (getdir player))*50,velocity player select 2]}

Share this post


Link to post
Share on other sites

I have a question for yas. Say i want to copy an array how would i go about doing that? Is it true if i try array1=array2 that if array2 changes array 1 changes too right so it wont be a copy of the orginal array2?

Share this post


Link to post
Share on other sites

My last post was 50% rambling since i was a bit tired..

It´s not the length of the sentances that´s the issue really, or should i say not at all.

My problem is formulating lines correctly...

"what needs brackets, what doesn´t..do i have to put this command before this one to make it work"

That kind of stuff..

What I´m doing a poor job trying to explain here is that everything needs to be written

in a specific manner for it to work. The commands themselves aren´t hard to remember or check for,

it´s just that using the more advanced ones to make a somewhat complicated script

can be hard because they need to be typed correctly and in a certain order.

I understand what the commands do and how everything works (well, maybe not everything..but you get my point).

It´s just that the actual scripting is a huge bottleneck if you will, since i know what i want to do

and how it will work in the game but then it all fails because i can´t write the whole thing correctly.

So it´s basically the order in which the commands are typed and things like that that´s the problem..

Share this post


Link to post
Share on other sites
Quote[/b] ]Say i want to copy an array how would i go about doing that?

If you want to copy a simple array, then use the + command:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Array1=[1,2,3,4,5]

_Array2=+_Array1

As you realised, variables holding arrays are just pointers. In that they point to the location of the array data. So if you had an emdedded array the + command on it's own would not work:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Array1=[1,2,3,4,5,[A,B,C]]

_Array2=+_Array1

In the above example _Array1 & _Array2 would still be sharing [A,B,C]. In other words both arrays would point to the same location of [A,B,C]. To copy that array, you would have to do something like:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Array1=[1,2,3,4,5,[A,B,C]]

_Array2=+_Array1

_Array2 Set [5,+(_Array1 Select 5)]

It looks a pain in the b&^t when you need to copy an embedded array. But array pointers are a very powerfull feature of OFP scripting. When used properly they can save a lot of time and effort. Plus they provide some otherwise hidden features, of being an alternative to sharing information across multiple scripts without using global variables.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Pointer=[[False]]

[_Pointer] Exec "Script.sqs"

;Wait for Script.sqs to finish

@((_Pointer Select 0) Select 0)

Hint "Script.sqs has finished"

Script.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Pointer=_This Select 0

~10

(_Pointer Select 0) Set [0,True]

Exit

Share this post


Link to post
Share on other sites

Thanks UNN for the quck reply and help! Much appreciated.

Now if i wanted to make a copy of an array thats in a trigger on the map how would i do that.

Say variable area = trigger on map

and say i want a copy of the orginal array first started on the map to = _copyarea

would it be something along the lines like :

_new= [,

  1. ]

_copyarea = +_new

_copyarea set [ 1, +(_new Select 1)]

Thanks in advance im not too good with arrays...

Share this post


Link to post
Share on other sites

I probably over complicated things by including all those array examples. To just take a snapshopt of a trigger array you only need:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_copyarea = +(List area)

Share this post


Link to post
Share on other sites

Thanks UNN once again got it working! Got another question for ya about arrays. Ok now that i got the array from the trigger how would i be able to get the name i defined to it in the map editor.( Say like i called a unit : :unitA:) and in the script i want it to check the trigger array for the unit named that? How would i do that? I noticed that it brings back the value like Alpha Black (player name) ect but not the name defined in the map editor.

Thanks!

Share this post


Link to post
Share on other sites

Thanks guys for this thread - very illuminating!

I often see lines like this in a script, randomising the position of an object:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_obj1 move [(getpos _marker1 select 0)+100-random 50,(getpos _marker1 select 1)+100-random 50,0]

I guess this is meant to randomise the X and Y coordinates of where _obj1 is positioned, within a 100 metre range on either axis.

However, shouldn't "+100-random 50" be the other way round? Say the script, on the X axis, subtracts the full 50 meters from the "100", then it will place the object 50 meters East of _marker1, yes?

So using "+100-random 50", objects will always appear 50-100m East (x-axis) or North (y-axis) of the reference point, and never West or South?

Shouldn't it be "+50-random 100"? Taking the x-axis again, the script would then position the object anywhere from 50 meters West of the reference point to 50 meters East.

Therefore, to get proper random positioning either side of a marker, shouldn't the syntax be:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_obj1 move [(getpos _marker1 select 0)+50-random 100,(getpos _marker1 select 1)+50-random 100,0]

Am I reading this right? Or am I "out biking"  biggrin_o.gif

Cheers,

CH

Share this post


Link to post
Share on other sites

Hmm, I'll just throw a working example for you.

This is part of a script which creates bloodsplats around a position. The bloodsplats will be created to a square area around the position.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_maxdist = _this select 2

_tmp = "FDFbloodsplatB" camCreate [(getpos _obj select 0) + _maxdist * ((random 2) - 1), (getpos _obj select 1) + _maxdist * ((random 2) - 1)]

Notice that there is only 2 lines of code in this example.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×