Editors Depot - Mission Editing and Scripting > OFP - Editing/Scripting Multiplayer

My script isnt working

(1/2) > >>

Yasirotta:
Hey, im making multiplayer map, where i have big problem. Idea is, that there is 3 bases. FDF (resistance), West and East. If you playing East side (as this problem) you can order AI controlled tanks to attack FDF or West base. Now, there is 2 tanks and leader of tanks is named as "t72a". East side commander, is named as "e1". Here is my scripts what i have made now:

easttanks.sqs

--- Code: ---easttanksoption1done = 1
easttanksoption2done = 1

#check
?( e1 distance t72a < 3):goto "actions"
~1
goto "check"
#actions
?(easttanksoption1done == 1):easttanksoption1 = e1 addaction ["Attack FDF Base","easttanksoption1.sqs"]
?(easttanksoption2done == 1):easttanksoption2 = e1 addaction ["Attack West Base","easttanksoption2.sqs"]
#check2
~1
?( e1 distance t72a < 3): goto "check2"
e1 removeaction easttanksoption1
e1 removeaction easttanksoption2
goto "check"
--- End code ---

easttanksoption1.sqs

--- Code: ---[table][tr][td]_pos = getmarkerpos "FDF"
e1 removeaction easttanksoption1
e1 removeaction easttanksoption2
easttanksoption1done = 2
t72a domove _pos
t72a setbehaviour "combat"
exit
--- End code ---

easttanksoption2.sqs

--- Code: ---[table][tr][td]_pos = getmarkerpos "West"
e1 removeaction easttanksoption1
e1 removeaction easttanksoption2
easttanksoption2done = 2
t72a domove _pos
t72a setbehaviour "combat"
exit
--- End code ---

When playing in multiplayer as "e1" named officer, i cant get those actions to show up.
Is problem that this just wont work on multiplayer, or whats wrong ???

Edit:
Oh, and if you have better tips to do this please suggest ones.
Basic idea, is that Player as Officer (only officers) can order tank attack to enemy base. Not by radio, need to dot that yourself at base. Otherwise its too easy to order attack by radio.

RKurtzDmitriyev:
Hi there Yasirotta. Please place your code inside of code tags.

Anyway, just from skimming your script (I'm not on a good computer now), your problem sounds like a locality issue. Addaction only gives an action to the computer it is executed on. Is addaction being executed on every computer? If not, then only the server host will see the action.

You may also need to use the publicvariable command on some of those number variables such as easttanksoption1done.

Walter_E_Kurtz:
I came across a tutorial on this very topic: Triggers, Scripts & AddAction in Multiplayer by Baddo.

Yasirotta:
Well, its ment that ONLY east side commander is able to see (and use) the action. So, its only good that action is executed from only that computer, where east side commander is playing.

From the tutorial:
"A script started from addAction is only executed locally i.e. only on the computer of the player who uses the action."

Somehow, when im testing that mission myself i still cant see that action. Im not using preview, i made that complete multiplayer mission and hosted that myself. I took east commander, went to tanks but still, theres no action to choose.

Walter_E_Kurtz:
1. I don't concur. My understanding is that instructions for AI to move should be given on all computers, so that they all agree to move the units in question.

2. The main reason you're not seeing the action is that you cannot get close enough to the T72. Without crawling under it, the player is always going to be at least 3.1 metres away from the centre of the tank (from where distances are measured) - BIS tanks at least.


I'm appending my test version, which works also when exported to MP. The main changes are:

A. Triggers
   Add two:
      First, Condition: easttanks_optionWest,   On Act: [] exec "easttanks_West.sqs"
      Second, Condition: easttanks_optionFDF,   On Act: [] exec "easttanks_FDF.sqs"

B.
--- Code: (Init.sqs) ---easttanks_optionFDF = false
easttanks_optionWest = false

e1 exec "e1_monitor.sqs"
--- End code ---

C.
--- Code: (e1_monitor.sqs) ---if !(local _this) then {exit}

#check
? (e1 distance t72a < 5): goto "actions"
~1
goto "check"

#actions
? !(easttanks_optionFDF):  easttanksoption1 = e1 addaction ["Attack FDF Base", "easttanks_FDF.sqs"]
? !(easttanks_optionWest): easttanksoption2 = e1 addaction ["Attack West Base","easttanks_West.sqs"]

#check2
~1
?( e1 distance t72a < 8): goto "check2"

e1 removeaction easttanksoption1
e1 removeaction easttanksoption2
goto "check"
--- End code ---

D.
--- Code: (e1_West.sqs) ---e1 removeaction easttanksoption1
e1 removeaction easttanksoption2

easttanks_optionWest = true
publicVariable "easttanks_optionWest"
--- End code ---

--- Code: (e1_FDF.sqs) ---e1 removeaction easttanksoption1
e1 removeaction easttanksoption2

easttanks_optionFDF = true
publicVariable "easttanks_optionFDF"
--- End code ---

E.
--- Code: (easttanks_West.sqs) ---_pos = getmarkerpos "West"

t72a domove _pos
t72a setbehaviour "combat"
exit
--- End code ---

--- Code: (easttanks_FDF.sqs) ---_pos = getmarkerpos "FDF"

t72a domove _pos
t72a setbehaviour "combat"
exit
--- End code ---


Issues:
   e1_monitor.sqs doesn't exit, so if the player was to get close enough to t72a he could send the tanks in the other direction still.
   There is room to reduce the number of scripts used, particularly easttanks_West / FDF.

Navigation

[0] Message Index

[#] Next page

Go to full version