Jump to content
Sign in to follow this  
-STO-Badblood

Public hints in local script: popup target script

Recommended Posts

I wrote a script to make popup targets (createvehicle)for training missions. The script is run on the local server only to avoid the duplication of the targets on the map. The script also keeps score of the targets hit/miss and presents the results in a hint message.

Question: since the script is kept on the server only - players other than the server do not see the hint messages. Any ideas on making the hint messages created on the local server display as a public message? The hint messages are updated frequently as the targets pop up and dissapear. See code below:

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

;// PopupTargets.sqs - created by Badblood [sTO] on 3/26/03

;// Feel free to e-mail questions or comments to badblood@stogroup.net

;// This program runs from trigger(s).

;// The trigger is activated when someone enters lane 1 or lane 2 of the training range.

;// PURPOSE:

;// 1) The script pops up five individual targets for each range _delay seconds apart.

;// 2) The targets are then removed in the same order they came up _delay seconds apart.

;// 3) The hit/miss score is calculated (accumulated) and displayed between each round.

;// 4) Each round of targets are placed at a greater distance (south) from each lane firing stage.

;// 5) Each target takes three hits from an M16. Max targets possible are 45 (perfect score with standard M16 loadout).

;// Calling syntax: Trigger init field --> [Lane1TriggerName, Lane2TriggerName] exec "PopupTargets.sqs"

;// Run on the local server only - need a logic named "server". Used to keep multiple (unwanted) targets from appearing.

?!(local Server): Goto "quit"

;// Get the Lane trigger positions - the target location will be based on the trigger locations

_Lane1Name = _this select 0

_Lane2Name = _this select 1

;// Break out the X,Y coordinates for Lane 1

_Lane1 = getpos _Lane1Name

_Lane1X = _Lane1 select 0

_Lane1Y = _Lane1 select 1

;// Break out the X,Y coordinates for Lane 2

_Lane2 = getpos _Lane2Name

_Lane2X = _Lane2 select 0

_Lane2Y = _Lane2 select 1

;// _inc = distance to move the targets away between each round

_inc = -30

;// Initialize some variables (some public - some local)

Ln1hit  = 0

Ln1miss = 0

Ln2hit  = 0

Ln2miss = 0

_delay = 1.8

;// Calculate how many lanes are occupied. Only report on 1 lane if there is only 1 lane active

?(Lane1_Occupied + Lane2_Occupied < 1) : goto "END"

?(Lane1_Occupied == 1 && Lane2_Occupied == 0) : _Lanes = 1

?(Lane1_Occupied == 0 && Lane2_Occupied == 1) : _Lanes = 2

?(Lane1_Occupied == 1 && Lane2_Occupied == 1) : _Lanes = 3

;// _loop used to keep track of the round

_loop1 = 0

;// _set = _loop + 1. Used for status output

_set =1

;// Initialize and publish the scoreboard at startup

?(_Lanes == 1):hint format["ROUND %3\n\n\nLANE 1\nHit  = %1\nMiss = %2\n\nLANE 2\nEmpty", Ln1hit, Ln1miss, _set]

?(_Lanes == 2):hint format["ROUND %3\n\n\nLANE 1\nEmpty\n\nLANE 2\nHit  = %1\nMiss = %2", Ln2hit, Ln2miss, _set]

?(_Lanes == 3):hint format["ROUND %5\n\n\nLANE 1\nHit  = %1\nMiss = %2\n\nLANE 2\nHit  = %3\nMiss = %4", Ln1hit, Ln1miss,Ln2hit, Ln2miss, _set]

~_delay

~_delay

;// Target Round Loop

#LOOP1

_set = _set + 1

_Ln1TargetFlag = 0

_Ln2TargetFlag = 0

;// Increase the delay a little between rounds as the targets get further away

_delay = _delay + 0.2

~_delay

;// Increase _inc (distance from stageing area to south)

_inc = _inc - 20

;// Keep track of the Round Loop

_loop1 = _loop1 + 1

;// Popup 5 Targets at _delay intervals on each lane used

?(_Lanes == 1 || _Lanes == 3):_Ln1Target1 = "TargetE" createvehicle [(_Lane1X + (1.5*(random 10))), (((_Lane1Y + _inc)-(random 5)) - 5), 0]

?(_Lanes == 2 || _Lanes == 3):_Ln2Target1 = "TargetE" createvehicle [(_Lane2X + (1.5*(random 10))), (((_Lane2Y + _inc)-(random 5)) - 5), 0]

~_delay

?(_Lanes == 1 || _Lanes == 3):_Ln1Target2 = "TargetE" createvehicle [(_Lane1X - (1.5*(random 10))), (((_Lane1Y + _inc)-(random 5)) - 10), 0]

?(_Lanes == 2 || _Lanes == 3):_Ln2Target2 = "TargetE" createvehicle [(_Lane2X - (1.5*(random 10))), (((_Lane2Y + _inc)-(random 5)) - 10), 0]

~_delay

?(_Lanes == 1 || _Lanes == 3):_Ln1Target3 = "TargetE" createvehicle [(_Lane1X + (random 10)) , (((_Lane1Y + _inc)-(random 5)) - 15), 0]

?(_Lanes == 2 || _Lanes == 3):_Ln2Target3 = "TargetE" createvehicle [(_Lane2X + (random 10)) , (((_Lane2Y + _inc)-(random 5)) - 15), 0]

~_delay

?(_Lanes == 1 || _Lanes == 3):_Ln1Target4 = "TargetE" createvehicle [(_Lane1X - (random 10)) , (((_Lane1Y + _inc)-(random 5)) - 20), 0]

?(_Lanes == 2 || _Lanes == 3):_Ln2Target4 = "TargetE" createvehicle [(_Lane2X - (random 10)) , (((_Lane2Y + _inc)-(random 5)) - 20), 0]

~_delay

?(_Lanes == 1 || _Lanes == 3):_Ln1Target5 = "TargetE" createvehicle [_Lane1X                , (((_Lane1Y + _inc)-(random 5)) - 15),0]

?(_Lanes == 2 || _Lanes == 3):_Ln2Target5 = "TargetE" createvehicle [_Lane2X                , (((_Lane2Y + _inc)-(random 5)) - 15),0]

~_delay

;// Keep track of the hit/miss status of each target then remove them _delay seconds apart.

?(getdammage _Ln1Target1 == 1): _Ln1TargetFlag = 1

?(getdammage _Ln2Target1 == 1): _Ln2TargetFlag = 1

?(_Ln1TargetFlag == 1) : Ln1hit = Ln1hit + 1

?(_Ln2TargetFlag == 1) : Ln2hit = Ln2hit + 1

?(_Ln1TargetFlag == 0) : Ln1miss = Ln1miss + 1

?(_Ln2TargetFlag == 0) : Ln2miss = Ln2miss + 1

?(_Lanes == 1 || _Lanes == 3):deletevehicle _Ln1Target1

?(_Lanes == 2 || _Lanes == 3):deletevehicle _Ln2Target1

_Ln1TargetFlag = 0

_Ln2TargetFlag = 0

~_delay

?(getdammage _Ln1Target2 == 1): _Ln1TargetFlag = 1

?(getdammage _Ln2Target2 == 1): _Ln2TargetFlag = 1

?(_Ln1TargetFlag == 1) : Ln1hit = Ln1hit + 1

?(_Ln2TargetFlag == 1) : Ln2hit = Ln2hit + 1

?(_Ln1TargetFlag == 0) : Ln1miss = Ln1miss + 1

?(_Ln2TargetFlag == 0) : Ln2miss = Ln2miss + 1

?(_Lanes == 1 || _Lanes == 3):deletevehicle _Ln1Target2

?(_Lanes == 2 || _Lanes == 3):deletevehicle _Ln2Target2

_Ln1TargetFlag = 0

_Ln2TargetFlag = 0

~_delay

?(getdammage _Ln1Target3 == 1): _Ln1TargetFlag = 1

?(getdammage _Ln2Target3 == 1): _Ln2TargetFlag = 1

?(_Ln1TargetFlag == 1) : Ln1hit = Ln1hit + 1

?(_Ln2TargetFlag == 1) : Ln2hit = Ln2hit + 1

?(_Ln1TargetFlag == 0) : Ln1miss = Ln1miss + 1

?(_Ln2TargetFlag == 0) : Ln2miss = Ln2miss + 1

?(_Lanes == 1 || _Lanes == 3):deletevehicle _Ln1Target3

?(_Lanes == 2 || _Lanes == 3):deletevehicle _Ln2Target3

_Ln1TargetFlag = 0

_Ln2TargetFlag = 0

~_delay

?(getdammage _Ln1Target4 == 1): _Ln1TargetFlag = 1

?(getdammage _Ln2Target4 == 1): _Ln2TargetFlag = 1

?(_Ln1TargetFlag == 1) : Ln1hit = Ln1hit + 1

?(_Ln2TargetFlag == 1) : Ln2hit = Ln2hit + 1

?(_Ln1TargetFlag == 0) : Ln1miss = Ln1miss + 1

?(_Ln2TargetFlag == 0) : Ln2miss = Ln2miss + 1

?(_Lanes == 1 || _Lanes == 3):deletevehicle _Ln1Target4

?(_Lanes == 2 || _Lanes == 3):deletevehicle _Ln2Target4

_Ln1TargetFlag = 0

_Ln2TargetFlag = 0

~_delay

?(getdammage _Ln1Target5 == 1): _Ln1TargetFlag = 1

?(getdammage _Ln2Target5 == 1): _Ln2TargetFlag = 1

?(_Ln1TargetFlag == 1) : Ln1hit = Ln1hit + 1

?(_Ln2TargetFlag == 1) : Ln2hit = Ln2hit + 1

?(_Ln1TargetFlag == 0) : Ln1miss = Ln1miss + 1

?(_Ln2TargetFlag == 0) : Ln2miss = Ln2miss + 1

?(_Lanes == 1 || _Lanes == 3):deletevehicle _Ln1Target5

?(_Lanes == 2 || _Lanes == 3):deletevehicle _Ln2Target5

_Ln1TargetFlag = 0

_Ln2TargetFlag = 0

~_delay

;// Report the score between rounds 1 - 6

?(_Lanes == 1 && _loop1 < 7 ):hint format["ROUND %3\n\n\nLANE 1\nHit  = %1\nMiss = %2\n\nLANE 2\nEmpty", Ln1hit, Ln1miss, _set]

?(_Lanes == 2 && _loop1 < 7 ):hint format["ROUND %3\n\n\nLANE 1\nEmpty\n\nLANE 2\nHit  = %1\nMiss = %2", Ln2hit, Ln2miss, _set]

?(_Lanes == 3 && _loop1 < 7 ):hint format["ROUND %5\n\n\nLANE 1\nHit  = %1\nMiss = %2\n\nLANE 2\nHit  = %3\nMiss = %4", Ln1hit, Ln1miss,Ln2hit, Ln2miss, _set]

;// Report the score and include "LAST ROUND" on round 7

?(_Lanes == 1 && _loop1 == 7 ):hint format["LAST ROUND\n\n\nLANE 1\nHit  = %1\nMiss = %2\n\nLANE 2\nEmpty", Ln1hit, Ln1miss]

?(_Lanes == 2 && _loop1 == 7 ):hint format["LAST ROUND\n\n\nLANE 1\nEmpty\n\nLANE 2\nHit  = %1\nMiss = %2", Ln2hit, Ln2miss]

?(_Lanes == 3 && _loop1 == 7 ):hint format["LAST ROUND\n\n\nLANE 1\nHit  = %1\nMiss = %2\n\nLANE 2\nHit  = %3\nMiss = %4", Ln1hit, Ln1miss,Ln2hit, Ln2miss]

~_delay

;// If player(s) left the range, end the process

?(Lane1_Occupied + Lane2_Occupied < 1) : goto "END"

;// Start back at the top of the loop to begin next round 2-7

?(_loop1 < 8) : goto "loop1"

;// Report the final score at completion of all target rounds or when the range(s) are clear of players

#END

?(_Lanes == 1):hint format["CLEAR\n\n\nLANE 1\nHit  = %1\nMiss = %2\n\nLANE 2\nEmpty", Ln1hit, Ln1miss]

?(_Lanes == 2):hint format["CLEAR\n\n\nLANE 1\nEmpty\n\nLANE 2\nHit  = %1\nMiss = %2", Ln2hit, Ln2miss]

?(_Lanes == 3):hint format["CLEAR\n\n\nLANE 1\nHit  = %1\nMiss = %2\n\nLANE 2\nHit  = %3\nMiss = %4", Ln1hit, Ln1miss,Ln2hit, Ln2miss]

#quit

exit

Share this post


Link to post
Share on other sites

Can you just re-use the targets?? Like set their damage to 0 and start the round, then reset their damage to 0? Then all the clients would do is check each target and calculate how much damage each one takes. The server could then send out a publicVariable that announces when each new round starts or something.

What I'm suggesting is don't use createVehicle, name all the targets, and then that way each client has a pointer to each target to check its damage.

Doolittle

Share this post


Link to post
Share on other sites

well I did something simular like that some time ago. I checked the dammage and whenever it got to 1 i started a timer to set dammage to 0 again. worked great for me.

Share this post


Link to post
Share on other sites
Guest jacobaby

You could do a couple of things here;

Use GOTO and MARKERs together with a local machine check to skip the createvehicle parts, and run the script globally.

Or,

Use globalchat and format to display the results,

Or, use TITLETEXT and format to display the results, in conjunction with step one mentioned above.

Or, Declare the results as a publicvariable and run the hints in another script on each PC.

TJ

TJ

Share this post


Link to post
Share on other sites

Thanks for all the good suggestions!

I did try keeping the targets static and reset dammage to pop them up. The problem is that once the targets were reset, the next player on the range would see them popping up and down (lag issue). Looks OK on the host machine but other players had problems.

I tried formatting my hint messages into a public variable then having a logic trigger display the message:

ex/

--------------------------------------------------

Server Script

?!(local Server): Goto "QUIT"

  ;// Format the message variable

  Message = format["Print this message globally - Score = %1", PlayerScore]

  ;// Make it public and activate the trigger

  PublicVariable "Message"

  ActiveMessage = 1

  ;// Wait for the trigget to activate and reset then continue

  @ActiveMessage == 0

  goto : "CONTINUE"

#CONTINUE

 .... more code ... blaa blaa blaa

#QUIT

exit

-------------------------------------------------------

Logic Trigger

Activation: Repeatedly

Condition: ActiveMessage == 1

OnActivation: hint Message; ActiveMessage = 0

-------------------------------------------------------

This seems to still work OK on the server. Others still can't see it. I was under the impression that triggers are public.

I will try having the trigger launch a message script but I think it will have the same effect.

Thanks again for all the good suggestions! Keep'em coming!

- SFC BadBlood[sTO]

Share this post


Link to post
Share on other sites
Guest jacobaby

The playerscore is the variable you need to make public,

then use a trigger to make the hint on all pc's using the publicvariable of the playerscore.

Do ya get me??

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  

×