Home   Help Search Login Register  

Author Topic: onMapsingleclick stops working.  (Read 1530 times)

0 Members and 1 Guest are viewing this topic.

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
onMapsingleclick stops working.
« on: 19 Mar 2008, 23:23:56 »
Hi all of you... superior collegues.

I'm doing a MP DM mission where the onMapsingleclick command is crucial. So far I have only tried it in the editor, but I have run into a problem.

I have a trigger set to condition: side player == west, on activation: onMapsingleclick "mapmark setpos getpos _pos". All of this works well and like expected but... after a certain amount of time the onMapsingleclick command doesn't work anymore. It is if like the trigger has run out of lifetime or something. The mission will most likely run for at least an hour, but I'm fearing that this onMapsingleclick function will not last until the end of the mission. I have read somewhere that triggers work 10000 times, switching on and off. What does that mean for a trigger that has repetedly activation and is checking something continously? 10000 seconds of lifetime... less or what?

Any input please.

What I'm searching for is a way to enable onMapsingleclick for an unlimited amount of time.

Cheers

Laggy
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: onMapsingleclick stops working.
« Reply #1 on: 20 Mar 2008, 01:22:57 »
I don't think the issue has anything at all to do with the trigger. In this circumstance, the activation will be performed once for WEST players once if the trigger is once only and once each time they (re)spawn if the trigger repeats. The reason is that triggers activate when the condition changes from being false to true, not each time that the condition is tested (which is every 0.5 seconds or so) and found to be true. In this case, this happens when you initially spawn (player changes from objNull to a WEST player character) or when you respawn (player changes from a corpse, which is always civilian, to a WEST player character).

Not sure whether that helps you solve your problem, but it should make it clearer how the trigger is operating.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Re: onMapsingleclick stops working.
« Reply #2 on: 20 Mar 2008, 11:06:08 »
Thank you Spooner.

I remember this problem occuring for me in OFP as well. Do you think a player script would be more reliable in "function lifetime" or at least equal?


#start
? side player == west : goto "loop"
exit

#loop
@ OnMapSingleClick "mapmark setpos getpos _pos"
goto "start"


Another question is how to move a marker with OnMapSingleClick,  since the syntax has changed with ArmA. I have tried the old OFP {}, but it seems like ArmA only accepts "" and with a markername you get a double "" syntax, that gives an error message. Right now I'm moving an invisible H (named mapmark) and has a marker on a loop script that follows it.

What I'm trying to accomplish is an OnMapSingleClick that creates a move position for other nonplayable groups, that are moved around by the player through the radio menu.
This function I want for both BLUFOR and OPFOR side and I just don't know how to solve that. If I use PublicVariable "_pos" I suspect that commands from both sides will mess with eachother.

I guess my final question is this: Can I have all 10 radio triggers used by both sides and make a differance in OnActivation through player definition and PublicVariable?

Activation :radio alpha
Condition: this AND side player == west
OnActivation : myvariable = true; PublicVariable "myvariable"

Is this idea possible or should I divide the radio triggers between the two sides, which would only enable 5 for each player?

Thanks again.

Laggy
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: onMapsingleclick stops working.
« Reply #3 on: 20 Mar 2008, 12:47:52 »
Using the editor-placed radio triggers doesn't work at all well in MP anyway, so create them inside scripts (otherwise, when a radio is clicked by any player, everyone's trigger will be activated without you being able to tell who clicked). By creating different radio triggers in init.sqs (or a script called from init.sqs), based on the player's side, you can then use all 10 uniquely for each side.

Yes, ArmA only accepts the "" syntax for the onMapSingleClick command now, since {} is reserved only for use in creating code blocks/functions. You can have "s inside the string by using two double-quotes for each double-quote you want:
Code: [Select]
onMapSingleClick """mapmark"" setMarkerPos _pos";

Remember also that the variable _pos, within the onMapSingleClick, is a position, not an object, so you don't need to use getPos on it to use it as a position.

As to your original issue, however, it is actually likely that the problem was being caused by the "move marker to gamelogic position" script was "running out of steam", rather than any problems with the onMapSingleClick part of your mission. Thus, this shouldn't be an issue any more...

Edit: If you are using radio triggers to initiate map-marker movement, then it makes sense to only allow a single movement click for each time the radio trigger is used. To do this, turn off map-clicks after the player has clicked:
Code: (radio trigger activation, in this case the second for the US) [Select]
_trigger = createTrigger ["EmptyDetector", [0, 0, 0]];
_trigger setTriggerActivation ["BRAVO", PRESENT", true];
_trigger setTriggerStatements ["this", "onMapSingleClick """"""westMarker2"""" setMarkerPos _pos; onMapSingleClick """""""";"";", ""];

And yes, that is a ridiculous number of quotes, but you need to double them within the onMapSingleClick and again within the trigger statement.
« Last Edit: 20 Mar 2008, 14:30:31 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Re: onMapsingleclick stops working.
« Reply #4 on: 20 Mar 2008, 21:10:01 »
Thank you so much for the extensive answer Spooner.

Will try it all out.

Cheers

Laggy




And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.