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.

Why doesn't this work?

Go down

Why doesn't this work? Empty Why doesn't this work?

Post by Guest Mon 24 Dec 2012, 18:08

Need some help with a bit of code not working as it should.

Code:


function onDeath(victim, killer)
  if OFP:wasInGroup("plaset1group") then
      local grp_size = OFP:getGroupSize("plaset1group")
     
      if grp_size == 0 and plaspawn == true then
        OFP:destroyEntitySet(pla_set)
        OFP:disableEvent("spawnEntitySetAtEntityPosition_plaset_plaspawn1")
        OFP:despawnEntity("mitsutrigger")
 
  OFP:setObjectiveState("obj1", "COMPLETED")
  OFP:setObjectiveState("obj2", "IN_PROGRESS")
  OFP:setObjectiveVisibility("obj2", true)
 
  objstate = 1
 
   
    if OFP:isInTrigger("plyr", "mitsuzone") and plaspawn == true then
 
    plaarm_set = OFP:spawnEntitySetAtEntityPosition("plaarmset", "plaspawn2")

    OFP:displaySystemMessage("HQ: All AAA infantry neutralised")
    OFP:displaySystemMessage("Tracking multiple Armoured units advancing on MITSULEVKA.")
    OFP:displaySystemMessage("Advise you get the **** out of Dodge")
    OFP:displaySystemMessage("and RTB immediately - OUT")
   
    OFP:disableEvent("spawnEntitySetAtEntityPosition_plaarmset_plaspawn2")

    onSpawnedReady(setName, setID, tableOfEntities, errorCode )

    if setID == plaarm_set then
 
    OFP:searchAndDestroy(tableOfEntities[1], "armobj", 100, false, "ADDTOFRONT")
    end
   
    OFP:activateRVChain("extractrvpath")
    OFP:setRVChainVisibility("extractrvpath", true)
   
    end
  end
 
 elseif OFP:wasInGroup("usmcgroup") then
 
  local usgrp_size = OFP:getGroupSize ("usmcgroup")
 
      if usgrp_size == 0 then
      OFP:destroyEntitySet("usmcset")
      OFP:disableEvent("activateEntitySet_usmcset")
      OFP:setObjectiveState("obj1", "FAILED")
      OFP:missionFailed()
      end
    end
end


Basically, when the plaarm_set spawns (an armoured group of 8 vehicles), they're supposed to S&D at the player's location to force a retreat back to his base. This completes the mission. They spawn with no problems but fail to carry out the S&D order, just sitting at their spawn point.

Any ideas???

Thank

RC
Anonymous
Guest
Guest


Back to top Go down

Why doesn't this work? Empty Re: Why doesn't this work?

Post by Guest Mon 24 Dec 2012, 18:13

OFP:wasInGroup(victim,"plaset1group")

onSpawnedReady is a separate function.

You cannot disable a spawn. Remove that line. I'm typing this on my cell or I'd post fixed code.
Anonymous
Guest
Guest


Back to top Go down

Why doesn't this work? Empty Re: Why doesn't this work?

Post by Guest Mon 24 Dec 2012, 19:07

OK... easier to type on a real keyboard.

Code:

function onDeath(victim, killer)
   if OFP:wasInGroup(victim, "plaset1group") then
      local grp_size = OFP:getGroupSize("plaset1group")
      if grp_size == 0 and plaspawn == true then
         OFP:destroyEntitySet(pla_set)
         OFP:disableEvent("spawnEntitySetAtEntityPosition_plaset_plaspawn1")
         OFP:despawnEntity("mitsutrigger")
         OFP:setObjectiveState("obj1", "COMPLETED")
         OFP:setObjectiveState("obj2", "IN_PROGRESS")
          OFP:setObjectiveVisibility("obj2", true)
         objstate = 1
         if OFP:isInTrigger("plyr", "mitsuzone") and plaspawn == true then
            plaarm_set = OFP:spawnEntitySetAtEntityPosition("plaarmset", "plaspawn2")
            OFP:displaySystemMessage("HQ: All AAA infantry neutralised")
            OFP:displaySystemMessage("Tracking multiple Armoured units advancing on MITSULEVKA.")
            OFP:displaySystemMessage("Advise you get the **** out of Dodge")
            OFP:displaySystemMessage("and RTB immediately - OUT")
         end
      end
    elseif OFP:wasInGroup(victim, "usmcgroup") then
      local usgrp_size = OFP:getGroupSize ("usmcgroup")
      if usgrp_size == 0 then
         OFP:destroyEntitySet("usmcset")
         OFP:setObjectiveState("obj1", "FAILED")
         OFP:missionFailed()
      end
   end
end

function onSpawnedReady(setName, setID, tableOfEntities, errorCode )
   if setID == plaarm_set then
      OFP:searchAndDestroy(tableOfEntities[1], "armobj", 100, false, "ADDTOFRONT")
   end
   OFP:activateRVChain("extractrvpath")
   OFP:setRVChainVisibility("extractrvpath", true)
end

This is untested, but should work in the context of your code.

Cheers and Merry Christmas! Very Happy
Anonymous
Guest
Guest


Back to top Go down

Why doesn't this work? Empty Re: Why doesn't this work?

Post by Guest Tue 25 Dec 2012, 13:49

Thanks tvig, making corrections now. Smile
Anonymous
Guest
Guest


Back to top Go down

Why doesn't this work? Empty Re: Why doesn't this work?

Post by Guest Tue 25 Dec 2012, 14:53

Np. Note that this may not solve the s and d problem.
Anonymous
Guest
Guest


Back to top Go down

Why doesn't this work? Empty Re: Why doesn't this work?

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

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