Jump to content
Sign in to follow this  
charliereddog

Basic MP editing

Recommended Posts

Is there a tute which explains when a Init.sqs/sqf fires when launched on a dedi server, a non dedi server etc.

I could really do with a basics MP guide for ArmA, especially considering JIP.

Share this post


Link to post
Share on other sites

See sig biggrin_o.gif If you got any questions left, please ask them, ill try to answer and put them into the Biki smile_o.gif

Share this post


Link to post
Share on other sites

Yes, I've seen this, but it's a bit advanced. For example, it talks about using the function opPLayerConnected, but where would you use it?

What I'm getting at is I don't know the order in which things happen in MP?

I have some code which I thought worked fine in OFP in the init or run from a sqs exec'd from the init. Now, it doesn't seem to work until after I press go on the mission briefing. Since the code controls which objectives are active etc, it's a bit of a PITA.

Share this post


Link to post
Share on other sites

You can use onPlayerConnected where you need it. Reviewing the BIKI's explaination tells you how it works.

The order things happen in MP is basicly outlined under the "Scripting Need to Knows" section of the guide, ill add some more stuff to it smile_o.gif

You can use debug messages or a kind of debug log to figure out when runs what, if you need to know it for your project.

For the rest, you, as developer, decide the order of things.

Apart from default script/engine initiations, its all up to you how to handle the rest.

It all comes down to what the end result must be...

Maybe if you share the code I can give a better answer smile_o.gif

Update: added section

http://community.bistudio.com/wiki....ization

Also don't forget, if you add a waitUntil of which the condition is not immediatly true, or use a sleep inside the init.sqf, the rest of the code will only be executed AFTER the briefing, not during the briefing.

Share this post


Link to post
Share on other sites
Quote[/b] ]Maybe if you share the code I can give a better answer
Ooh, I don't know about that, it's a trade secret!

No, seriously, I'm on my work pc so can't at the moment. It's sqs, rather than sqf as I haven't quite gotten my head around sqf yet, and the sqs was written for OFP.

Basically there is an init.sqf which has <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">execvm "start.sqf" That does a couple of bits and runs <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[] exec "logic.sqs"

Logic contains the routine for applying which mission is run, which markers are required and puts them in the right place.

I'm at the moment hosting this mission from my own pc, I could do to find out how to host using one of my cores, and connect via another but that's not a problem. However, the mission will need to go on a dedicated server at some point.

My problem was, that at the briefing screen, I got all the objectives visible, when the code in Logic hides the inappropriate objs.

I'll post all the code when I get home. I am looking to convert it to sqf but probably don't need to right now.

Share this post


Link to post
Share on other sites

OK,

init.sqf

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">execVM "DAC\DAC_Config_Creator.sqf";

arrShilka = [];

execvm "start.sqf";

execvm "shilkatest.sqf";

titleText ["Select radio (0,0,1) and click the map to move the Blackhawk to the location\nSelect radio (0,0,2) to send the Blackhawk back to base","plain"];

if !(alive heliPilot) exitWith

{

onMapSingleClick "";

1 setRadioMsg "null";

2 setRadioMsg "null";

"blackhawk" setMarkerType "empty";

};

if (alive heliPilot) exitWith

{

1 setRadioMsg "Blackhawk Move";

2 setRadioMsg "null";

heliPilot setbehaviour "CARELESS";

helipilot setcombatmode "BLUE";

heliPilot assignAsDriver heli;

heliPilot moveInDriver heli;

heliGunner assignAsGunner heli;

heliGunner action ["GETINGUNNER", heli];

heliGunner setbehaviour "AWARE";

heliGunner setcombatmode "RED";

};

start.sqf

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

_intrndLoc=7.5;

_intRndWth=random 6;

_intRndLoc = 1 + _intRndLoc - (_intRndLoc % 1);

if (!isServer) exitWith {};

[_intrndloc] exec "logic.sqs";

Logic.sqs (I realise there's a whole lot that can be cleaned up here, but I've not gotten around to it, including making it sqf rather than sqs.)

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

_intrndType=random 3.9

_strLocX= call compile format["getpos lgc_%1 select 0",_intlgc]

_strLocY= call compile format["getpos lgc_%1 select 1",_intlgc]

;Now we get rid of decimals, the result is a random beteen 0 and 10 plus 1 (1 -> 11)

_intRndtype2 = 1 + _intRndtype - (_intRndtype % 1)

;hint format["%1,%2,%3",_intrndtype,_intrndtype2,(_intRndtype % 1)]

goto format["T%1",_intrndType2]

#T1

;Patrol

"mkr_Patrol" setmarkerpos [_strLocX,_strLocY,0]

"mkr_Defend" setmarkertype "empty"

"mkr_destroy" setmarkertype "empty"

trgZone1 setpos [_strLocX,_strLocY,0]

trgPatrol setpos [_strLocX,_strLocY,0]

"mkr_Rescue" setmarkertype "empty"

"mkr_AA" setmarkertype "empty"

"2" objstatus "Hidden"

"3" objstatus "Hidden"

"4" objstatus "Hidden"

_N=random 1

_E=random 1

?_N>=0.5:_N=1

?_E>=0.5:_E=1

?_N<0.5:_N=0

?_E<=0.5:_E=0

?(_N==0 && _E==0):goto "PNE"

?(_N==1 && _E==1):goto "PSW"

?(_N==0 && _E==1):goto "PNW"

?(_N==1 && _E==0):goto "PSE"

#PNE

"mkr_patrolE" setmarkerpos [_strLocX+200+random 400,_strLocy+200+random 400,0]

exit

#PNW

"mkr_patrolE" setmarkerpos [_strLocX+200+random 400,_strLocy-200-random 400,0]

exit

#PSE

"mkr_patrolE" setmarkerpos [_strLocX-200-random 400,_strLocy+200+random 400,0]

exit

#PSW

"mkr_patrolE" setmarkerpos [_strLocX-200-random 400,_strLocy-200-random 400,0]

goto "end"

#T2

;Search and Destroy

"mkr_destroy" setmarkerpos [_strLocX,_strLocY,0]

"mkr_Defend" setmarkertype "empty"

"mkr_Patrol" setmarkertype "empty"

trgZone1 setpos [_strLocX,_strLocY,0]

trgDestroy setpos [_strLocX,_strLocY,0]

"mkr_Rescue" setmarkertype "empty"

"mkr_AA" setmarkertype "empty"

"1" objstatus "Hidden"

"3" objstatus "Hidden"

"4" objstatus "Hidden"

_N=random 1

_E=random 1

?_N>=0.5:_N=1

?_E>=0.5:_E=1

?_N<0.5:_N=0

?_E<=0.5:_E=0

?(_N==0 && _E==0):goto "DNE"

?(_N==1 && _E==1):goto "DSW"

?(_N==0 && _E==1):goto "DNW"

?(_N==1 && _E==0):goto "DSE"

#DNE

AM1 setpos [_strLocX+200+random 200,_strLocY+200+random 200,0]

Net1 setpos getpos AM1

exit

#DNW

AM1 setpos [_strLocX+200+random 200,_strLocY-200-random 200,0]

Net1 setpos getpos AM1

exit

#DSE

AM1 setpos [_strLocX-200-random 200,_strLocY+200+random 200,0]

Net1 setpos getpos AM1

exit

#DSW

AM1 setpos [_strLocX-200-random 200,_strLocY-200-random 200,0]

Net1 setpos getpos AM1

exit

goto "end"

#T3

;AA

"mkr_destroy" setmarkertype"empty"

"mkr_Defend" setmarkertype "empty"

"mkr_Patrol" setmarkertype "empty"

trgZone1 setpos [_strLocX,_strLocY,0]

trgZone2 setpos [_strLocX,_strLocY,0]

trgDestroy setpos [_strLocX,_strLocY,0]

"mkr_Rescue" setmarkertype "empty"

"mkr_AA" setmarkerpos [_strLocX,_strLocY,0]

"1" objstatus "Hidden"

"2" objstatus "Hidden"

"4" objstatus "Hidden"

[trgZone2] call DAC_Activate

exit

goto "end"

#T4

;Downed Chopper

"mkr_Rescue" setmarkerpos [_strLocX,_strLocY,0]

"mkr_destroy" setmarkertype "empty"

"mkr_Patrol" setmarkertype "empty"

"mkr_Defend" setmarkertype "empty"

trgZone1 setpos [_strLocX,_strLocY,0]

"mkr_AA" setmarkertype "empty"

trgZone2 setpos [_strLocX,_strLocY,0]

"1" objstatus "Hidden"

"2" objstatus "Hidden"

"3" objstatus "Hidden"

[ChopWreck] exec "smokescript2.sqs"

[trig1,grpCrew] exec "triggertrack.sqs"

_N=random 1

_E=random 1

?_N>=0.5:_N=1

?_E>=0.5:_E=1

?_N<0.5:_N=0

?_E<=0.5:_E=0

?(_N==0 && _E==0):goto "RNE"

?(_N==1 && _E==1):goto "RSW"

?(_N==0 && _E==1):goto "RNW"

?(_N==1 && _E==0):goto "RSE"

#RNE

ChopWreck setpos [_strLocX+400+random 200,_strLocY+400+random 200,0]

_x=getpos ChopWreck select 0

_y=getpos ChopWreck select 1

Crew1 setpos [_x+2,_y+2,0]

crew2 setpos getpos crew1

crew3 setpos getpos crew1

exit

#RNW

ChopWreck setpos [_strLocX+400+random 200,_strLocY-400-random 200,0]

_x=getpos ChopWreck select 0

_y=getpos ChopWreck select 1

Crew1 setpos [_x+2,_y+2,0]

crew2 setpos getpos crew1

crew3 setpos getpos crew1

exit

#RSE

ChopWreck setpos [_strLocX-400-random 200,_strLocY+400+random 200,0]

_x=getpos ChopWreck select 0

_y=getpos ChopWreck select 1

Crew1 setpos [_x+2,_y+2,0]

crew2 setpos getpos crew1

crew3 setpos getpos crew1

exit

#RSW

ChopWreck setpos [_strLocX-400-random 200,_strLocY-400-random 200,0]

_x=getpos ChopWreck select 0

_y=getpos ChopWreck select 1

Crew1 setpos [_x+2,_y+2,0]

crew2 setpos getpos crew1

crew3 setpos getpos crew1

mkrcrew setmarkerpos getpos crew1

goto "end"

#end

Exit

Share this post


Link to post
Share on other sites

You will have to find a solution for logic.sqs

Your problem is that you only execute logic.sqs on the server.

objStatus is a local function, thus must be executed on every computer.

I understand you want it to only execute on the server due to the mission type determination, plus the marker settings are global (altough you could use the setMarker***Local functions etc).

Quickly thought I believe there's only 2 options:

[*] Let the users decide which objective type they gonna play, by using param1/param2 through description.ext

[*] Hide all markers and objectives until after Briefing, let the server broadcast the chosen mission type, and let the clients wait for this variable to then show the correct markers and objectives. This is afaik only possible after Briefing.

Though maybe it's possible to publicVar the variable through init.sqf and that the clients receive this variable during briefing because the server is faster ready with loading the mission than the clients... Prolly have to test smile_o.gif

Share this post


Link to post
Share on other sites

Argh. I was sure that this worked in OFP.

Most of what you've written has gone above my head, I really need to sit down and understand with ArmA in front of me. It's not good sitting at work trying to follow stuff you barely grasp.

Thanks for the help. Unfortunately, allowing the player to determine which mission type they want to do is only half the random element, it would still be a pain in the ass because of the random location too.

I'll have to test your theories. I take it, that the problems only really exist in MP, every time I've tested in SP I've had no problems although I've not actually brought up the briefing before playing (shift+preview) yet. Maybe it won't work there either?

Thanks for the help. This will teach me to run before I can walk.

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  

×