Operation Flashpoint Dragon Rising OFDR Forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Help triggerzone!

5 posters

Go down

Help triggerzone! Empty Help triggerzone!

Post by juank.zero Thu 27 Jun 2013, 02:07

hello!
I want to run a triggerzone with 4 players, I used the script of SAR! but not seem to work:
Code:
function onEnter_triggerzone(zoneName, unitName)
if (OFP:isInEchelon(unitName, "Echelon")) then -- Echelon is Player´s
end
end

Any idea?.

-------------------------------------------------
Hola!

Quiero que se active un triggerzone al pasar todos los jugadores por el,, Alguna idea??.

juank.zero

Points : 19
Reputation : 0
Join date : 2013-02-26

Back to top Go down

Help triggerzone! Empty Re: Help triggerzone!

Post by TheGeneral Thu 27 Jun 2013, 02:15

try this:


Code:
function onEnter(zoneName, unitName)
if (OFP:isInEchelon(unitName, "Echelon")) then -- Echelon is Player´s
end
end

you don't really need the parenthesis in the if statement iether tbh. You can write this also:


Code:
function onEnter(zoneName, unitName)
if zoneName == triggerzone and unit name == your unit

end
end
TheGeneral
TheGeneral
Admin

Points : 780
Reputation : 35
Join date : 2012-12-15

http://maniacaldog.wix.com/keepdralive

Back to top Go down

Help triggerzone! Empty Re: Help triggerzone!

Post by juank.zero Thu 27 Jun 2013, 02:41

I have not worked!

Code:
function onEnter(zoneName, unitName)
if zoneName == "triggerzone" and unitName == "Echelon" then
OFP:displaySystemMessage("Prueba numero uno");
end
end

I will have a problem in EntityDatabase?

juank.zero

Points : 19
Reputation : 0
Join date : 2013-02-26

Back to top Go down

Help triggerzone! Empty Re: Help triggerzone!

Post by TheGeneral Thu 27 Jun 2013, 02:47

you are using the echelons name, try using the lead unit name instead.
TheGeneral
TheGeneral
Admin

Points : 780
Reputation : 35
Join date : 2012-12-15

http://maniacaldog.wix.com/keepdralive

Back to top Go down

Help triggerzone! Empty Re: Help triggerzone!

Post by juank.zero Thu 27 Jun 2013, 02:52

The only thing that always worked flawlessly for me is:

Code:
function onEnter_triggerzone_usa ()
end

any variant of onEnter me to run

juank.zero

Points : 19
Reputation : 0
Join date : 2013-02-26

Back to top Go down

Help triggerzone! Empty Re: Help triggerzone!

Post by Regg Thu 27 Jun 2013, 03:05

I think the problem is that "Echelon" is really "echelon". DR always wants to change names to lower-case, so it is best to name things that way. Try either of these options...

Code:
function onEnter(zoneName, unitName)
    if zoneName == "triggerzone" and OFP:isInEchelon(unitName, "echelon") then
        -- do something
    end
end
Or...

Code:
function onEnter_triggerzone(zoneName, unitName)
    if OFP:isInEchelon(unitName, "echelon") then
        -- do something
    end
end
Regg
Regg
Veteran

Points : 143
Reputation : 10
Join date : 2013-02-22

Back to top Go down

Help triggerzone! Empty Re: Help triggerzone!

Post by tjdagger Thu 27 Jun 2013, 07:12

Yep, it will be a upper/lower case issue like Regg said.

tjdagger
Admin

Location : Silverdale, Queensland, Australia
Points : 107
Reputation : 7
Join date : 2012-12-17
Age : 48

Back to top Go down

Help triggerzone! Empty Re: Help triggerzone!

Post by juank.zero Mon 01 Jul 2013, 01:24

sorry!
I tried different ways but it does not work.

juank.zero

Points : 19
Reputation : 0
Join date : 2013-02-26

Back to top Go down

Help triggerzone! Empty Re: Help triggerzone!

Post by TheGeneral Mon 01 Jul 2013, 13:06

juank.zero wrote:sorry!
I tried different ways but it does not work.

 Hi juank.zero! Can you explain in more detail what you are trying to create. We can help you out but, without knowing what the situation is you are doing for your mission, we are limited on resources for helping your problem. Cheers

MD.
TheGeneral
TheGeneral
Admin

Points : 780
Reputation : 35
Join date : 2012-12-15

http://maniacaldog.wix.com/keepdralive

Back to top Go down

Help triggerzone! Empty Re: Help triggerzone!

Post by juank.zero Wed 03 Jul 2013, 03:39

hello,
I wish is that all players when passing operate a triggerzone. My English is very bad and google translate does not seem to work properly, so I realisado so a couple of graphics:

Imagen 1: Al pasar jugador por triggerzone, este se activa: 
Help triggerzone! P1Imagen 2: Al pasar todos los jugadores, triggerzone se activa:

Help triggerzone! P2

Saludos!.

juank.zero

Points : 19
Reputation : 0
Join date : 2013-02-26

Back to top Go down

Help triggerzone! Empty Re: Help triggerzone!

Post by John J. Stevens Wed 03 Jul 2013, 10:30

Lets try this approach

One way others have simplified trigger coding is to group them all into one area like this:

Code:
Function onEnter(zoneName, unitName)
   --example 1 - all entities trigger an event
   if zoneName = "trigger1" then
        displaySystemMessage( “trigger1 entered” ) --execute your code
        return --use this to exit out of the "On Enter" routine 
   end

   --example 2 -- only one entity triggers an event
   if zoneName = "trigger1" and unitName = "someone_special" then
        displaySystemMessage( “someone_special entered trigger1” ) --execute your code
   end
end

what your event triggers is up to you.

I hope that translates well enough for you.


Last edited by John J. Stevens on Thu 04 Jul 2013, 19:13; edited 2 times in total
John J. Stevens
John J. Stevens
Admin

Location : WV/PA
Points : 285
Reputation : 22
Join date : 2012-12-19

Back to top Go down

Help triggerzone! Empty Re: Help triggerzone!

Post by TheGeneral Wed 03 Jul 2013, 22:19

Question @JS:

 When you use the return keyword is like saying OFP:disableEvent(myEvent) etc???
TheGeneral
TheGeneral
Admin

Points : 780
Reputation : 35
Join date : 2012-12-15

http://maniacaldog.wix.com/keepdralive

Back to top Go down

Help triggerzone! Empty Re: Help triggerzone!

Post by John J. Stevens Wed 03 Jul 2013, 22:23

RETURN forces an exit from the routine/function it is in - you would use it in situations when a routine has a lot of individual IF conditions and processing other IFs in that routine are unneeded.

Basically freeing up the processor to other things
John J. Stevens
John J. Stevens
Admin

Location : WV/PA
Points : 285
Reputation : 22
Join date : 2012-12-19

Back to top Go down

Help triggerzone! Empty Re: Help triggerzone!

Post by juank.zero Thu 04 Jul 2013, 04:11

in this example to mount all the players something happens!:


Code:
function onMount_vu25mh60s(vehicleName, unitName, echelonName)
if OFP:isAllMounted("Echelon") == true then
OFP:move("EchelonI1", "waypointI4", "ADDTOFRONT");    
end
end

I want same thing but with the function onEnter

juank.zero

Points : 19
Reputation : 0
Join date : 2013-02-26

Back to top Go down

Help triggerzone! Empty Re: Help triggerzone!

Post by TheGeneral Thu 04 Jul 2013, 23:12

OK! few things need to change here for starters.

when writing your functions I'd get in the habit of writing, things like this if you are using specific vehicle names and unit name.
Code:
function onMount_vu25mh60s(vehicleName, unitName, echelonName)

change it too:

Code:
function onMount(vehicleName, unitName, echelonName)
if vehicleName == vu25mh60s then
-- execute your code

Do that for onEnter functions too.

Also..., Regg explained about case lettering for strings in OFP commands. Always use lower case. your OFP:move command has "EchelonI1". change that to "echeloni1".

If you want something to happen in the onEnter such as mount a vehicle. Use an OFP:mount command to initialize the mounting event.

Then write a complete separate function for the onMount command. like this:

Code:
function onMount(vehicleName, unitName, echelonName)
if vehicleName == "vu25mh60s" and OFP:isAllMounted("echelon") then
OFP:move("pilot","waypointI4","ADDTOFRONT");
end
end

--


It think that last code is correct, I've not tested it.  try it out and see what happens.
TheGeneral
TheGeneral
Admin

Points : 780
Reputation : 35
Join date : 2012-12-15

http://maniacaldog.wix.com/keepdralive

Back to top Go down

Help triggerzone! Empty Re: Help triggerzone!

Post by tjdagger Sun 07 Jul 2013, 16:46

I think I now what you want juank.zero

Code:
function onEnter_triggerName(zoneName, unitName)
   if OFP:isInEchelon(unitName,"Echelon") then
      OFP:disableEvent("onEnter_triggerName")
      --do stuff eg. activate an entitySet
   end
end

function onLeave_triggerName(zoneName, unitName)
   if OFP:isInEchelon(unitName,"Echelon") and not OFP:isInTrigger("Echelon") then
      OFP:enableEvent("onEnter_triggerName")
      --do stuff eg. destroy an entitySet
   end
end


 
or a self generating table, by placeing all triggers in a single entityset and spawning at mission start...

Code:
function onMissionStart()
   OFP:activateEntitySet("triggers")
end

function onEnter(zoneName, unitName)
   if do_stuff_triggers[zoneName] and do_stuff_triggers[zoneName] == "on" and  OFP:isInEchelon(unitName,"Echelon") then
      do_stuff_triggers[zoneName] = "off"
      --do stuff eg. activate an entitySet
   end
end

function onLeave(zoneName, unitName)
   if do_stuff_triggers[zoneName] and do_stuff_triggers[zoneName] == "off" and OFP:isInEchelon(unitName,"Echelon") and not OFP:isInTrigger("Echelon") then
      do_stuff_triggers[zoneName] = "on"
      --do stuff eg. destroy an entitySet
   end
end

function onSpawnedReady( setName, setID, tableOfEntities, errorCode )
   if setName == "triggers" then
      if not do_stuff_triggers then
         do_stuff_triggers = {}
      end   
      for i = 1,#tableOfEntities do
         if debug:getTemplateName(tableOfEntities[i]) == "triggerzone" then
            do_stuff_triggers[tableOfEntities[i]] = "on"
         end
      end
   end
end

tjdagger
Admin

Location : Silverdale, Queensland, Australia
Points : 107
Reputation : 7
Join date : 2012-12-17
Age : 48

Back to top Go down

Help triggerzone! Empty Re: Help triggerzone!

Post by TheGeneral Sun 07 Jul 2013, 22:42

would I be right in saying the OFP:activateEntitySet command needs a variable to be set for it first??

then that would be used again where you have the do_stuff_triggers[zoneName]--Variable placed in here.
TheGeneral
TheGeneral
Admin

Points : 780
Reputation : 35
Join date : 2012-12-15

http://maniacaldog.wix.com/keepdralive

Back to top Go down

Help triggerzone! Empty Re: Help triggerzone!

Post by juank.zero Mon 08 Jul 2013, 03:06

Code:
function onEnter_triggerzone(zoneName, unitName)
if OFP:isInEchelon(unitName, "Echelon") then  -- players enter = activated triggerzone... script not working

OFP:displaySystemMessage("Soldiers Enter");
OFP:disableEvent("onEnter_triggerzone");

OFP:addTimer("TEMPO", 1000);   
remain = 10   

end
end

function onTimer_TEMPO ()
remain = remain - 1            
OFP:displaySystemMessage("Target Capturing:"..remain);
OFP:displaySystemMessage("\n \n \n \n \n");            
if (remain == 0) then   
OFP:displaySystemMessage("captured Target!");
OFP:removeTimer("TEMPO");
end
OFP:setTimer ("TEMPO", 1000);
end

I want is: 

1- four players (4) enter the triggerzone.
2- players entering the triggerzone activates a timer...

BUT!...triggerzone is activated by entering only one (1) player
.. I tried all the recommendations, but I still have the problem.

greetings!

juank.zero

Points : 19
Reputation : 0
Join date : 2013-02-26

Back to top Go down

Help triggerzone! Empty Re: Help triggerzone!

Post by tjdagger Mon 08 Jul 2013, 12:32

Try this...

Code:
function onMissionStart()
remain = 10
end

function onEnter_triggerzone(zoneName, unitName)
 if OFP:isInEchelon(unitName, "Echelon") then  -- players enter = activated triggerzone... script not working
 OFP:displaySystemMessage("Soldiers Enter");
 OFP:disableEvent("onEnter_triggerzone");
 OFP:addTimer("TEMPO", 1000);      
 end
end

function onTimer_TEMPO ()
remain = remain - 1            
OFP:displaySystemMessage("Target Capturing:"..remain);
OFP:displaySystemMessage("\n \n \n \n \n");
OFP:setTimer ("TEMPO", 1000);          
if (remain == 0) then  
OFP:displaySystemMessage("captured Target!");
 OFP:removeTimer("TEMPO");
 end
end

Greetings, Back at ya!

tjdagger
Admin

Location : Silverdale, Queensland, Australia
Points : 107
Reputation : 7
Join date : 2012-12-17
Age : 48

Back to top Go down

Help triggerzone! Empty Re: Help triggerzone!

Post by tjdagger Mon 08 Jul 2013, 12:55

Mdog?


mdog wrote:would I be right in saying the OFP:activateEntitySet command needs a variable to be set for it first??
then that would be used again where you have the do_stuff_triggers[zoneName]--Variable placed in here.


Are you asking about the self generating table example? If you are, then yes and no.

...because in...  do_stuff_triggers[zoneName]  inside the onEnter or onLeave function "[zoneName]" is the variableName of the zone just entered or left. 
Which is then checked to see weather or not it exists inside the table that is generated in onSpawnedReady, from the entityset spawned at mission start, which contains 
all the triggerzones that we want to have an on off switch variable.
All this in turn can then be controlled by checking the zone status and if any "Echelon" member is inside a [triggerzone] before firering an event and switching the zone value to "off"...
 or ... a whole "Echelon" leaving a triggerzone before fireing an event eg. "despawning props" then setting the zone back to "on".


hope that answers your question?

tjdagger
Admin

Location : Silverdale, Queensland, Australia
Points : 107
Reputation : 7
Join date : 2012-12-17
Age : 48

Back to top Go down

Help triggerzone! Empty Re: Help triggerzone!

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum