Home   Help Search Login Register  

Author Topic: My script isnt working  (Read 2349 times)

0 Members and 1 Guest are viewing this topic.

Offline Yasirotta

  • Members
  • *
My script isnt working
« on: 04 Oct 2010, 00:50:48 »
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: [Select]
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"

easttanksoption1.sqs
Code: [Select]
[table][tr][td]_pos = getmarkerpos "FDF"
e1 removeaction easttanksoption1
e1 removeaction easttanksoption2
easttanksoption1done = 2
t72a domove _pos
t72a setbehaviour "combat"
exit

easttanksoption2.sqs
Code: [Select]
[table][tr][td]_pos = getmarkerpos "West"
e1 removeaction easttanksoption1
e1 removeaction easttanksoption2
easttanksoption2done = 2
t72a domove _pos
t72a setbehaviour "combat"
exit

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.
« Last Edit: 05 Oct 2010, 06:44:04 by Yasirotta »

Offline RKurtzDmitriyev

  • Former Staff
  • ****
Re: My script isnt working
« Reply #1 on: 05 Oct 2010, 00:01:59 »
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.
The OFP Editing Center wishes to remind you that the faithful COMREF will never threaten to stab you and, in fact, cannot speak.
However, in the event that it does speak, you are encouraged to heed its advice. ;)

Walter_E_Kurtz

  • Guest
Re: My script isnt working
« Reply #2 on: 05 Oct 2010, 01:41:57 »
I came across a tutorial on this very topic: Triggers, Scripts & AddAction in Multiplayer by Baddo.

Offline Yasirotta

  • Members
  • *
Re: My script isnt working
« Reply #3 on: 05 Oct 2010, 06:41:30 »
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

  • Guest
Re: My script isnt working
« Reply #4 on: 05 Oct 2010, 21:12:39 »
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) [Select]
easttanks_optionFDF = false
easttanks_optionWest = false

e1 exec "e1_monitor.sqs"

C.
Code: (e1_monitor.sqs) [Select]
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"

D.
Code: (e1_West.sqs) [Select]
e1 removeaction easttanksoption1
e1 removeaction easttanksoption2

easttanks_optionWest = true
publicVariable "easttanks_optionWest"
Code: (e1_FDF.sqs) [Select]
e1 removeaction easttanksoption1
e1 removeaction easttanksoption2

easttanks_optionFDF = true
publicVariable "easttanks_optionFDF"

E.
Code: (easttanks_West.sqs) [Select]
_pos = getmarkerpos "West"

t72a domove _pos
t72a setbehaviour "combat"
exit
Code: (easttanks_FDF.sqs) [Select]
_pos = getmarkerpos "FDF"

t72a domove _pos
t72a setbehaviour "combat"
exit


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.

Offline Yasirotta

  • Members
  • *
Re: My script isnt working
« Reply #5 on: 06 Oct 2010, 05:31:52 »
Beatiful, seems working NICE !

Quote
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.
This issue isnt bad, cos e1 can send them to attack West base after that (if they alive). Thats not bad at all.

One more thing, asking here cos its about same mission...
Idea of this MP mission is, that there are 3 diffrent sides (West, East, FDF). Each team trying eliminate main officer/general at enemy base, so how i can manage that if example West General is dead, so all players on West would lose the game but East and FDF could continue the fight ? Other words, i dont want West players just running around and bugging the game if their General is dead, they been lose the game afterall.

I been thinking, is there possibility to eliminate all West players if General is dead ? It can be only PLAYERS of West, not AI of west. I also use basic respawn, so "this setdamage 1" wouldnt be the key.

Best for me is, that if General dies, that side human players will lose and cant do anything more. AI players can still defend the remains of base. Game would end when there is one team leaft  :scratch:

I hope you know what im trying to say.