Jump to content
Sign in to follow this  
Postduifje

Randomly removing objectives

Recommended Posts

I made a mission which randomly removes some objectives when less than 15 players join in. It works fine on my system, but once put on a server it seems to show some weird behaviour. I really have no clue what I'm doing wrong, so maybe some of you can help me.

init.sqs:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (("alive _x" count [f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,p1,p2]) <= 15) then {[] exec "reduced.sqs"}

reduced.sqs:

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

if (aa_rnd >= 1) then {[] exec "aa_one.sqs"}

if (aa_rnd < 1) then {[] exec "aa_three.sqs"}

camp1_rnd = random 2

if (camp1_rnd >= 1) then {[] exec "camp_ruins.sqs"}

if (camp1_rnd < 1) then {[] exec "camp_pass.sqs"}

camp2_rnd = random 2

if (camp2_rnd >= 1) then {[] exec "camp_alpha.sqs"}

if (camp2_rnd < 1) then {[] exec "camp_bravo.sqs"}

town_rnd = random 2

if (town_rnd >= 1) then {[] exec "trosky.sqs"}

if (town_rnd < 1) then {[] exec "kvidla.sqs"}

exit

aa_one.sqs

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

"4" ObjStatus "Hidden"

deleteVehicle aa1_eastdead

deleteVehicle aa4

deleteVehicle aa5

aa6 setPos [0,0,0]

deleteVehicle aa6

deleteVehicle aa1_fire

deleteVehicle aa1_tent

deleteVehicle aa1_pallet

brdm2 setPos (getPos brdm)

"AA1" setMarkerPos [0,0]

exit

aa_three.sqs:

Quote[/b] ]obj6=true

"6" ObjStatus "Hidden"

deleteVehicle aa3_eastdead

deleteVehicle aa7

deleteVehicle aa8

aa9 setPos [0,0,0]

deleteVehicle aa9

deleteVehicle aa3_fire

deleteVehicle aa3_tent

deleteVehicle aa3_pallet

brdm setPos (getPos brdm2)

"AA3" setMarkerPos [0,0]

exit

So either aa_one.sqs or aa_two.sqs is executed based on the value of aa_rnd. However, sometimes both aa sites are completely removed besides one of the markers... I can't understand how the script can remove all units but let the marker stay... From a search I understand that adding some delay will prevent the lag in multiplayer from messing up the script and skipping certain lines. However, this made no difference.

Anyone has some suggestions?

Thanks in advance, Post

Share this post


Link to post
Share on other sites

All i can think about is that maybe it is a problem related to the locality of the script.

And so possibly all the players can actually be executing the script selecting the random result, and with each of them could have one different, with the consequence of having sometime both your 2 object deletion script being activated in the same time.

Try this :

in your mission, put a game logic and name it

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

according to the wiki

Quote[/b] ]In multiplayer, a game logic will always be local to the host computer. This works on both dedicated and player-hosted servers.

So adding this game logic will allow the initial script to run only on the server, never on the clients if we add a check for the locality of it.

This way there will be only 1 script with the random number generation running on the whole server+clients.

So in the init.sqs of your mission try this :

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

[] exec {playercheck.sqs}

Enlarge the delay if necessary to be sure every player has initialised.

And in the playercheck.sqs, you should have

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">?!(local server): exit

if (("alive _x" count [f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,p1,p2]) <= 15) then {[] exec "reduced.sqs"}

exit

This way the playercheck.sqs script will first see if the game logic named server is local or not (and if it is not local , it will mean the script is read on a client and so will exit right away).

If it does not solve the problem, i have no idea.

Share this post


Link to post
Share on other sites

Ah that makes sense, thank you!

It seems to work, but now the markers and objectives remain in place as they need to be removed locally for each client I asume. I'll fix that by using the publicvariable command.

Thanks a lot, I was starting to go insane on this on. wink_o.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  

×