Jump to content
Sign in to follow this  
tj72

Multiplayer Server Scripts

Recommended Posts

Im trying to make my Airlift script available for Multiplayer. Ive ben trying to run the script on a server to isolate the problem but I cannot ensure that the server is running my scripts. And therefore I cant proceed untill I know what is happening server/local.

So how can I confirm that the server is running the script? Argh.

I assume Init runs on all clients AND the server. And the init is executing scripts from there. The user calls the Airlift from an action which I assume is happening on that client only but Im not sure. When I test in Editor I get a message for server as I put the isserver check in the script. So in SP (editor preview) mode the mission runs like its own server?  This confusion is stopping me cold.

 But everytime I start the server (arma server.exe I found in the Arma root directory didnt download but I assume it was part of 1.08 patch) I get the not server message (probably from my client) but never the "this is server message" I get in Editor.  Im probably assuming too much because I can get the chopper to take off  with straight commands in the init (without the action). But I cannot start the chopper moving when using the Action at any time ever no matter what I try.  

  Im not certain if this is the server side script or my client. I dont want the client to run the script because I want the confirmation that the server alone is running it and I think all the sidechat is not coming from server. So if I put

?! isServer: exit then the script does not seem to continue since nothing happens past that line in MP. So when I try to make the server alone run the script I cant confirm! or at least it seems like its not. But I must make sure.

Sometimes it seems my copy of the game is a special version sent from hell with built in tricks to drive me nuts.

The messages are all set as a static single group unit and sidechat.  Does this mean my client machine can make a editor placed unit sidechat and domove should work the same or does domove HAVE to be on server side. Argh.

Share this post


Link to post
Share on other sites

Few hints:

1.) Init is executed on each client onJoin. Most times the major part of init.sqf will come after a if( !isServer )exitWith because otherwise there will arise problems with JIP.

2.) To get a message from a server you create

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

in the mission (see my post at the end of the thread).

to know whether a script is running on a server you use isServer.

Has that been enough to help you?

Share this post


Link to post
Share on other sites

Not sure if that helps...

When I start MP I can see sidechat in briefing before I hit continue. Then in mission I get repeat messages. i.e "Start server script" at the top of the script.  So are the briefing messages coming from server? and in mission are the client/s starting when joined in?

In the briefing Im getting my "not the server messages" but I want to get the "this is a server message" in MP. Its jsut not happening as Im expecting. If I put

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

?! isserver: unit1 sidechat "not the server"

?! isserver: exit

unit1 sidechat "this is the server"

or

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

? isserver: unit1 sidechat "this is the server"

Im expecting the server to get to that sidechat. When I get nothing back Im completely confused and I cant move forward untill I can clarify why this wont work.

Im using isserver to get these responses but out of desperation Ive tried using the old server logic as well. And in either case no message back. Are my sidechats happening on the server but not reaching the client? Is my server failing to run the script at all? This is what I cannot determine.

I like to try everything possible before making a post like this so I truly am stumped here and I could try some other things but they are just dumb guesses.

Share this post


Link to post
Share on other sites

All these chat things (globalchat, sidechat) and so on have effect local, so if you run em on the server and you are not the server - you can't see them.

Use the suggestion of Manday is the only way to debug something which only runs on the server.

If you have a chopper transport script which does not run yet in MP remember the vehicle is always local to the driver wink_o.gif

Share this post


Link to post
Share on other sites

Sorry - it's a bit difficult to me to actually follow you with what you want to achieve. It's a bit confusing too, since sidechat is normmaly supposed to used ingame. Will you tell us your final aim?

Mission loadead (Serverside):

init.sqf (serverside)

Mission loaded in:

init.sqf (all sides locally, serverside again)

That's what I think

Share this post


Link to post
Share on other sites

Ok so that suggest that all the chats Im looking for are possibly happening but since they are local then Im not seeing them. This is helpful.

The choppers are all created in editor and have AI loaded into them (movin command) instead of the green choppers that have the crew pre-loaded. In either case Im assuming the vehicles/crew are local to the server and the domove commands and all the reference positions need to be handled there.

 The reason I assume this is because I can domove the chopper from the init or any scripts that are fired from the init.

 But when I fire off the action the chopper never moves. My problem is that the Action command will not work where the hard code init etc above does.

So if my action fires a script that says:

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

chopper1 domove getpos unit1

it doesnt work. But if the exact same code is in the init or linked script off it then it does.

So Im assuming I have to use publicvariable to update a global array (or just a variable) and the server needs to recognize the update and then start the code either with an @ condition or in if/then if it needs to check a list of global variables. This is what drives me nuts because logically it should work but I cant even verify if anything is working.

Ok Manday, what Im asking, in the simplist terms, is to get your code from the other post to work in my mission so that I can get feedback from the server about what is happening with my scripts over there. Can your solution give me the "this is a server" message? I have to read that post again because I did come across it allready but Im having trouble applying it to my problem.

I have to look at my scripts to decide the best way to phrase the question for you without bogging everything down into all the internal aspects of the script.

But for now. I want to set up the isserver:exit condition and then confirm that only the server is running the script using your code.

Thanks and sorry for any confusion.

Share this post


Link to post
Share on other sites

To make it as simple as possible I'll write you a script now. So look:

What you gotta do is you gotta put it into your missionfolder and RUN it. It will send a message to all clients

(Wont paste here since this forum NEVER managed to display code)

http://paste-it.net/2748

start that script in the init and call

"I say hello" call f__bool_serverSendMessage;

to make the server (and only the server) to say hello. (or something else)

Share this post


Link to post
Share on other sites
Sometimes it seems my copy of the game is a special version sent from hell with built in tricks to drive me nuts.

I have the very same version.

May I ask you how you got isServer to work in SP?

mine is "scalar bool blablarofl"

e.g.

hint format ["%1", isServer]

returns

scalar bool array string 0xe0ffffef

when I preview the mission.

So i'm back to checking

if(local myGameLogic)then{};

if(local player]then{};

And I have another take on the manDay thingy

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

//This here is within the server-scope

SOME_TEXT = "OMG I*M THE SERVER!";

sleep 0.6;

publicVariable "SOME_TEXT";

and then having a player local script running

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

while{true} do{

_tmpSOME_TEXT = SOME_TEXT;

waitUntil{

sleep 0.2;

_tmpSOME_TEXT != SOME_TEXT

};

hint format["%1",SOME_TEXT];

sleep 0.2;

};

Share this post


Link to post
Share on other sites

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

? isServer: unit1 sidechat "this is server"

When I %1 hint isserver in preview mode I get True.

You did give me some good pointers before very similar to Manday and they were very helpful so thanks.

So I managed to get the chopper moving off the action and Im now onto the next problems. Basically the feedback systems underly the further issues. I have to have loops or @ waiting server side to recieve the Pubvar from the clients Action. Then handle everything from there nice and neat. But the logic is driving me buggy.

So now Im trying to research all the PublicVariable caveats.

Such as:

Can local variables be used in Pubvar

like PublicVariable (transportnames select _i)?

Or can it be Transportnames select 1 (or another number)

Can a pubvar be an array and can the pubvar be updated with

client does:

array = newarry

pubvariable "arry"

server (gets the new with @ _arry != arry : Goto "blah") then takes the arry and passes those values into its local variables and proceeds with moving the chopper out.

AND

do variables meant for Pubvar HAVE to be initialized in the init or can they be declared "on the fly"

Phew... So I have more testing but I just wanted to ask incase it saves me a few tests.

P.S.

I have my dedi server running and I export my missions to multiplayer and run a test. Then when I want to change something back in the editor. I have to exit the game completely to delete/overwrite my multiplayer mission! THis is a real time killer. I would think just closing the server would allow me to modify the mpmissions directory but apparently Arma holds files open and thus denies any changes to said file EVEN when runing other mission! Only complete exit of Arma seems to release the Mpmission file. Also I cant save copies of my mission in Mp mission even though they are binarized because it leaves all the scripts etc behind just like in editor. It pays to back up those mission folders for that reason but I have to do the same to prepare copies of my MP missions if I want ot test a string of maps. Am I missing something to flush memory or such to save that precious time.

Thanks again y'all.

Share this post


Link to post
Share on other sites

A:Can a pubvar be an array ?

Q: No.

It took me many hours to realise that.

Build a String out of your Array and Pubvar the String and Compile that back to an Array if you need it.

Share this post


Link to post
Share on other sites

I thought so! Thanks for the heads up.

ok so:

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

arrystring = "" (initialized everywhere)

arry [1,2,3,4,5]

arrystring = format ["%1", arry]

publicvariable "arrystring"

then over at server:

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

_arrystring = arrystring (initialized on server)

@ _arrystring != arrystring

newarry = compile arrystring

Im not sure if this is right, just a first try.

I havent used compile command but I will research and see in OFP editing if there are examples of this technique.

Share this post


Link to post
Share on other sites

compile makes string to code, call executes the code. so if you want to have the code

newarry = [1,2,3,4]

you need a string

"newarry = [1,2,3,4]"

and compile this and call it then. so what you need is

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">call compile("newarry = " + arrystring)

Share this post


Link to post
Share on other sites

about the game "holding" your MP-mission tidily.

Just start another MP-game, with another mission and that other mission will be released from the grip of Arma.

i.e.

Then you will be able to edit and export it to MP-and try it again.

I add v.x.x.x to my description of the mission

e.g.

v.1.0.1

and before I save and export it again I add

v.1.0.2

to see when the mission loads(lobby) that it got exported properly.

here's another example of the passArray thingy

client-side

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

_unpackArray = call compile ArrayAsString;

hint format["Element 2(index 1)=%1",_unpackArray select 1];

server-side

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

_a1V1 = 10;

_a1V2 = 20;

_a1V3 = 30;

_a2V1 = "MoNkEY";

_a2V3 = "BOPP";

_a2V4 = "RACKANISHU";

_myArray1 = [_a1V1,_a1V2,_a1V3];

_myArray2 = [_a2V1,_a2V2,_a2V3];

_myOtherArray = [_myArray1,_myArray2];

ArrayAsString = format["%1",_myOtherArray];

publicVariable "ArrayAsString";

Share this post


Link to post
Share on other sites

Gentlemen,

I must say that the help Ive recieved in this matter at this forumn has ben nothing less than essential. Just outstanding really.

I know have the script working in MP with enough stability that I can now complete the scripts in SP with near 100% confidence they will work over dedicated server. I just have small bugs and basic reassembly since the script got slightly broken during the furious testing sessions....but the core MP issues are squashed at this point. More importantly I learned alot during the process.

I learned to use Compile Pubvar and did my first .sqf's and probably 18 other things on this upgrade so I am also fully confident that all of this knowledge will apply to any future scripts I do to ensure that they will be MP compatible. It appears reaching out to other editors here to get the answers I needed was a key part of getting this script to exist in the MP version of the game. Without your help it would have taken a month just to isolate all the issues involved and proceed from there.

So all those who toiled over the answers you gave me should know that the work was not for nothing.

All who helped can expect a reference in the illustrious read me.txt I failed to include in the first version.

Thanks again. notworthy.gif

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  

×