Home   Help Search Login Register  

Author Topic: Problems with global booleans, publicVariable, and trigger  (Read 2214 times)

0 Members and 3 Guests are viewing this topic.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Please help me! I'm losing my mind again!!!!

I have two objects.  A game logic named "logicAntenna" and a game object (vysilacka radio) named "Radio".

To logicAntenna I have added the following action in its init:
Code: [Select]
idAntenna = this AddAction [""Adjust Antenna"",""adjustantenna.sqs""]";
To Radio I have added the following action in its init:
Code: [Select]
"idRadio = this AddAction [""Radio HQ"",""radiohq.sqs""]";

If the radio is used before the antenna is adjusted a message appears.  If a player adjusts the antenna and then uses the radio,  a message appears and the next ojective is activated.  Both these actions are handled by boolean variable triggers.   It works in SP but in MP the code in the script radiohqmsg.sqs does not seem to get executed on all clients and the hints, new objective, and sidechats are not displayed. The Ceiling function simply rounds up to the nearest integer.

Here is the mission.sqm code for the two triggers.
Code: [Select]
      {
         position[]={959.180298,0.397639,6675.228516};
         a=0.000000;
         b=0.000000;
         rectangular=1;
         age="UNKNOWN";
         expCond="Antenna";
         expActiv="[] Exec ""adjustantennamsg.sqs""";
         class Effects
         {
         };
      };
Code: [Select]
      {
         position[]={717.915405,0.397639,6705.841797};
         a=0.000000;
         b=0.000000;
         rectangular=1;
         repeating=1;
         age="UNKNOWN";
         expCond="RadioHQ";
         expActiv="[] Exec ""radiohqmsg.sqs""";
         class Effects
         {
         };
      };

 Here is the code for the four scripts involved:
adjustantenna.sqs
Code: [Select]
AntennaOp = _this Select 1
Hint "You have adjusted the antenna"
logicAntenna RemoveAction idAntenna
Antenna = TRUE
PublicVariable "AntennaOp"
PublicVariable "Antenna"
Exit

adjustantennamsg.sqs
Code: [Select]
AntennaOp GroupChat "I've adjusted the antenna. Now radio HQ!"
AntennaOp = NIL
If (Local Server) Then {DeleteVehicle logicAntenna}
Exit

radiohq.sqs
Code: [Select]
RadioOp = _this Select 1
If (Not Antenna) Then {Hint "You've hacked into the radio but the antenna needs adjusting."}
RadioHQ = TRUE
PublicVariable "RadioOp"
PublicVariable "RadioHQ"
Exit

radiohqmsg.sqs
Code: [Select]
RadioHQ = FALSE
If (Not Antenna) Then {RadioOp GroupChat "I've hacked into the radio junction box, but the signal is still too weak. Someone must climb up and adjust the antenna!" ; RadioOp = NIL ; RadioHQ = FALSE ; Exit}
Radio RemoveAction idRadio
;setup endgame
RandomInt = -99
If Not (Local Server) Then {Goto "client"}
RandomInt = [Random 10] Call Ceiling
PublicVariable "RandomInt"
#client
~1
@RandomInt!=-99
;radio exchange
RadioBox Say "static"
RadioOp SideChat "Firefly Base Come in! Firefly Base do you read me?"
RadioOp = NIL
~5
RadioBox Say "static"
FireFly SideChat "Zulu Red. This is FireFly Base..."
~5
RadioBox Say "static"
FireFly SideChat "Proceed to emergency extraction point at old ammo cache. Defend position until helicopter arrives."
;endgame markers
RandomMark = Format ["MarkerX%1",RandomInt]
RandomHMark = Format ["MarkerXH%1",RandomInt]
ExtractPos = GetMarkerPos RandomMark
ExtractHPos = GetMarkerPos RandomHMark
"MarkerExtract" SetMarkerPos ExtractPos
"MarkerExtract" SetMarkerType "END"
"3" ObjStatus "HIDDEN"
"6" ObjStatus "DONE"
"7" ObjStatus "ACTIVE"
Obj6 = TRUE
Mash1 SetPos [5 + (ExtractPos Select 0), ExtractPos Select 1, ExtractPos Select 2]
ammoEast3 SetPos ExtractPos
Mash1 SetDamage 0
ammoEast3 SetDamage 0
LZPad SetPos ExtractHPos
TriggerLZ SetPos ExtractPos
;
Hint "Objectives and Map Updated"
~5
RadioBox Say "static"
FireFly SideChat "Signal helicopter to approach extraction point with red flares."
~5
RadioBox Say "static"
FireFly SideChat "Signal helicopter to land with green flares."
~5
RadioBox Say "static"
FireFly SideChat "Flares must be fired within 200m of extraction point."
~5
.
.
.
Exit
« Last Edit: 11 Jul 2005, 16:40:38 by Mr.Peanut »
urp!

hermano

  • Guest
Re:Problems with global booleans, publicVariable, and trigger
« Reply #1 on: 11 Jul 2005, 17:25:53 »
Hints, titles and say are local on all machines (I thought sidechat would be displayed on all clients, it seems it is local too then).
Create a 'client-loop' script and execute it on all clients (and the server if a player is local).

Code: [Select]
showHint1 = false
showHint... = false
...
#loop
?(showHint1):showHint1=false;hint "Everybody can see this."
?(showHint...):showHint...=false;hint "Another text."
...
~0.25
goto "loop"

In your script you just publish the variable:
Code: [Select]
showHint1 = true;publicVariable "showHint1"
Hope this helps,
h
« Last Edit: 11 Jul 2005, 17:26:28 by hermano »

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re:Problems with global booleans, publicVariable, and trigger
« Reply #2 on: 11 Jul 2005, 17:35:09 »
If you look at my code, the triggers execute the code that should run on all machines.  The booleans that activate the triggers have been publicVariabled.  The question is if the booleans Antenna and RadioHQ are both true why is the trigger not executing the code on all clients?
« Last Edit: 11 Jul 2005, 17:39:17 by Mr.Peanut »
urp!

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Problems with global booleans, publicVariable, and trigger
« Reply #3 on: 12 Jul 2005, 06:54:17 »
I looked thru all of your code, and I couldn't find any reason why it wouldn't work. But then, I'm not that experienced in MP editing.

I'd suggest using the CoC's Network Services II. It makes MP editing like this about 1,000 times easier. :)
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re:Problems with global booleans, publicVariable, and trigger
« Reply #4 on: 12 Jul 2005, 18:54:07 »
The problem is that the LOL server has no CoC...

I have inserted short delays before and between the calls to publicVariable.  I won't know if it works until it gets tested again on a dedicated server.  What I should really do it take a look at the CoC code ...
urp!

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Problems with global booleans, publicVariable, and trigger
« Reply #5 on: 14 Jul 2005, 00:41:22 »
try declaring all your global booleans in your init.sqs

for some reason in mp, triggers like to have the boolean variables initially declared at the start of the mission in the init.sqs

to get your message broadcast to all clients on the same side or group, use the sideradio rather than sidechat
The actual radio class message would have to be declared in the  in the description.ext

also, tag all your global variables, eg, i use tx_
this prevents any clash with addon globals or bis globals
« Last Edit: 14 Jul 2005, 00:47:47 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re:Problems with global booleans, publicVariable, and trigger
« Reply #6 on: 14 Jul 2005, 13:47:46 »
I did declare the booleans in my init.sqs.  My guess is that for some reason, either or both of the boolean variables Antenna and RadioHQ and not being set to TRUE on a dedicated server, so the server side code is not being executed.  Renaming the booleans is probably as good a guess as anything....

I renamed Antenna and RadioHQ to smb_Antenna and smb_RadioHQ, and made sure there was a one second pause after the final publicVariable in all scripts.  One or the other of these changes has solved the problem.
« Last Edit: 14 Jul 2005, 21:27:51 by Mr.Peanut »
urp!

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re:Problems with global booleans, publicVariable, and trigger
« Reply #7 on: 14 Sep 2005, 16:26:40 »
I am not actually unsolving this.  Recently someone sent me a message about the scripts referred to in this thread but I accidentally deleted it.  Could this person please resend it.  I would be happy to help you.
urp!

Offline trinec

  • Members
  • *
  • I'm a llama!
Re:Problems with global booleans, publicVariable, and trigger
« Reply #8 on: 15 Sep 2005, 04:56:08 »
That was me I was just asking if everything was solved on the scripts and if I could use the  fixed ones for a mission I was making.  And if you had some info or a readme on how to implement the scripts it doesnt seem to hard to figure out by what you have shown in this forum thread but i wasnt sure how much was changed since you first started this.

trinec