Arma 3
WopsS 25 lutego 2014 o 9:06
Scripting multiplayer?
Hi, I just brought Arma 3. This is a cool game :) But I want to make my own gamemode, I scripted in sa-mp before, my own script is called gamemode. So I have a question, how can I do a multiplayer, I mean it is like single player, or you need some functions in plus?
< >
Wyświetlanie 1-15 z 19 komentarzy
Zenophon 25 lutego 2014 o 9:40 
Having multiple machines on a network introduces extra considerations. The concept of locality, that certain machines are responsible for certain objects in the game, mean that not everything can be done on the server.

I don't know what sa-mp is, so I assume you aren't familiar with ArmA's scripting language, SQF. SQF provides more advanced control over your mission than the editor, but takes time and practice to learn. It is much like any other programming language (simpler than Python, Java, etc.). If you have programmed before you will be able to pick it up quickly, but it does have its quirks.

Your question is rather vague, so here are some links:

https://community.bistudio.com/wiki/6thSense.eu:EG
https://community.bistudio.com/wiki/Locality_in_Multiplayer

There are many more interesting pages on the wiki, try searching there or the official forums for more details.
WopsS 25 lutego 2014 o 9:47 
@Zenophon thank you. :) So I the base scripting is for single player, I finded it on google, it is correctly?

It can be used with C++? I must to get all connected computers, yes?
Ostatnio edytowany przez: WopsS; 25 lutego 2014 o 10:05
Zenophon 25 lutego 2014 o 11:49 
Unfortunately, the ArmA engine cannot call C or C++ from SQF, except for some strange business with dll's that no one uses (I don't even know if it works). There were/are plans by BIS to allow scripting in Java by letting the engine call the JRE. The idea is to implement the SQF API into Java, thus circumventing SQF entirely. No news on this has surfaced (to my knowledge) in many months. So its seems SQF is here to stay for a long time.

Every machine connected to the server gets the mission (basically packaged data that directs how the game plays). All your SQF source code is defined in the mission, and any machine can run any SQF code that the mission designer wants.

To be exact, missions start with executing SQF code in a file called init.sqf; all clients and the server execute this code. Depending on how to design your mission, different code executes on different computers.

The issue with locality is this: some commands must be execute on certain machines. In singleplayer, every command just executes on one machine, which controls everything. In multiplayer, the server and clients share control of the mission.

Everything is under the control of the mission designer, it is up to them to give players any options in the mission (you could allow players to make decisions etc.). Large, flexible, and complex missions are basically gamemodes, like you want to create. They play out differently every time, by using randomization and giving players a lot of freedom.

I would recommend learning the basic editor first, then singleplayer scripting. If you have no experience making ArmA missions, you are not going to be able to implement a complex gamemode on your first try (it is difficult even for the experts).
WopsS 25 lutego 2014 o 12:10 
@Zenophon thank you verry much :). Nothing is difficult if you want that thing. :) I will start, as you say to learn basics. After that I will do the gamemode.

Thank you, again for all information witch you give me.
WopsS 26 lutego 2014 o 13:15 
Hmm, I thinking about a DLL, but the problem is how the client download the mission file. My oppinion SQF is wired ...
Zenophon 26 lutego 2014 o 13:36 
Found the page about dll's on the wiki:

https://community.bistudio.com/wiki/Extensions

Looks like the page was written for ArmA 2, but it probably works for ArmA 3. There are some limitations and issues with, and you will still have to call the dll with SQF.

All clients that connect to the server download the entire mission, that is how they get the data from the editor and are able to run SQF code. You can find downloaded missions on your hard drive somewhere (can't remember exactly where without looking).

SQF is a little strange compared to real programming languages. It was invented by BIS specifically for ArmA. The only other example of a similar situation that I can think of is UScript. If you are not familiar with Unreal, UnrealScript is a language is designed to work inside the engine. Of course, the languages themselves are very different, I am just comparing their purpose.

SQF is somewhat based on C syntax, without pointers or structures, and with dynamic typing. SQF abstracts variables much like any scripting language, Python, etc. There is no low-level work with the hardware. SQF is entirely functional, but the results of the ArmA engine itself being OO are obvious (the engine is probably C++). Things like Object being a type in SQF are odd.

For people new to ArmA, it seems ridiculous to learn SQF. Implementing Python, Lua, etc interpreting into the engine would have been easier from the start. I don't know what motivated BIS to create SQF.

The problem is that everything done in SQF uses the BIS engine API. This is about 1500 scripting commands that allow scripts to alter the game world. These commands are integral to the SQF language, like keywords.

For people that have worked for hundreds of hours in SQF (like me) building numerous functions, switching to another language would be useless. I would continue to use SQF function I have already written (unless there was some significant increase in efficiency).
WopsS 26 lutego 2014 o 22:24 
One more question, the SQF file must be in folders, or you put it how you want?
Zenophon 27 lutego 2014 o 12:38 
All missions are stored as directories on your hard drive, organized by your ArmA profile. These folders reside at (Windows 7) C:\Users\<UserName>\My Documents\Arma 3 - Other Profiles\<ProfileName>\missions, and are named as such: <missionName>.<mapName>.

Opening a mission in the editor loads the mission.sqm file at selected mission's directory. When you chose to export a mission to singleplayer or multiplayer, the mission's specific folder is compiled into a .pbo and placed in the correct folder at (default) C:\Program Files\Steam\steamapps\common\Arma 3 (either Missions or MPMissions).

When a server hosts a mission, it must select a .pbo file from the MPMissions folder. All clients then download the .pbo archive, so that their instance of the engine can open and read the necessary data.

A path to an SQF script can be relative to the mission directory (this is by default). This also applies to sound files, pictures, etc. You can also specify a path relative to ArmA's install directory (for example, to access a texture file). These paths can be in .pbo archives; however, I believe that the .pbo file must have been loaded by the engine (all .pbo's in the Addons folder are, plus any mods loaded).

I think that you can also give an absolute path (never tried it) to any directory to find SQF files. However, you must be able to guarantee that the correct files reside at that exact path. Using relative paths ensures that all files are where you expect.

For almost all cases, I would suggest placing all SQF files that you need into your mission directory. You can organize your mission folder in any way you want, so long as you access files with the correct paths. You could have hundreds of SQF files in any number of subfolders within the mission folder. As long your code interacts interally correctly, no one will ever notice.

For some unusual case, you could access SQF files from an addon (game assets are also addons), but if the .pbo was from a mod, all clients would need to have that mod loaded (and the correct version, etc.).
WopsS 27 lutego 2014 o 12:54 
No don't mean the mission folder, I finded it in first day in Arma 3 :) I mean the "gamemode" must have for exemple, I have the main gamemode in folder /gamemodes, or custom actions in /custonactions. Or I can put it everywere in my gamemode folder?

Btw: Thank you for explication of mission folder :)
Ostatnio edytowany przez: WopsS; 27 lutego 2014 o 12:54
Zenophon 28 lutego 2014 o 11:06 
You can organize the files and folders in the mission directory any way that you want. SQF code can be compiled into functions that are independent of the location of the source code. You don't need header files, #includes, package imports, etc to access your files (SQF is preprocessed, so #include might be useful). Once you compile a block of code or source file into a SQF function, the function can be stored in a global variable.

For example, I can write function to do something, place the code in a file, then from the init call:

SomeFunction = compileFinal preprocessFileLineNumbers "Scripts\Something\SomeFunction.sqf";

The path could be anything; you can put that file anywhere in the mission directory, so long as the relative path is correct. You can now access SomeFunction from all other code.

Technically, 'gamemode' is an abstraction to characterize certain missions. This includes things like Domination, Wasteland, etc (google these, you can download the missions and open the files). The actual mission is what runs on the server. Missions like these are using SQF functions to set up what happens so that it follows a set pattern.

If you create a library of SQF functions where each SQF function achieves some part of the overall gamemode goal, you can create many missions that use the gamemode API. You might never release this API, that's your choice; however, it allows you to create the 'gamemode' as a separate entity from any mission.

Each time you want to implement the gamemode differently, you copy over your gamemode source code, make sure the mission compiles it, then use those functions to make the mission.
WopsS 28 lutego 2014 o 12:22 
Ok thank you :). One more question, here
SomeFunction = compileFinal preprocessFileLineNumbers "Scripts\Something\SomeFunction.sqf";
It don't need a type, like "int, long, string, float" ?
Ostatnio edytowany przez: WopsS; 28 lutego 2014 o 12:22
Zenophon 1 marca 2014 o 15:08 
SQF is dynamically typed, like Python. You do not directly manage how anything is stored in memory. SQF is managed by the engine, it cannot run outside of ArmA.

There are different types, and you need to be aware of what types your variables are. However, you can do something this:

test = 1; test = "string"; array = [1, "string"];

See these pages for more info:

http://en.wikipedia.org/wiki/Type_system
https://community.bistudio.com/wiki/Data_Types
Foxtrot 5 lutego 2015 o 6:34 
Hey guys I have a question regarding .sqf files... maybe you can help

So, I have edited a mission with a x_load.sqf file (script), then I extracted the mission as a mpmission in .pbo format. I loaded that .pbo file into my clan's server and initialized the mission.

Everything loads fine but when the mission starts the server shows up a message saying that "x_load.sqf file is not found" and therefore the script doesn't works.

Any idea? thanks!
Ostatnio edytowany przez: Foxtrot; 5 lutego 2015 o 6:35
Początkowo opublikowane przez Foxtrot:

Everything loads fine but when the mission starts the server shows up a message saying that "x_load.sqf file is not found" and therefore the script doesn't works.
the script is called in the init.sqf or somewhere else,using the exact directory where it is expected.maybe your file isn`t in that folder?
Foxtrot 5 lutego 2015 o 14:24 
yes, aparently the init.sqf works since is calling the script... would try to pack the mission by myself or unpack and check the content of the .pbo file

"I came for the action and fun and end up being a software engineer" :P
Ostatnio edytowany przez: Foxtrot; 5 lutego 2015 o 14:26
< >
Wyświetlanie 1-15 z 19 komentarzy
Na stronę: 1530 50

Data napisania: 25 lutego 2014 o 9:06
Posty: 19