![]() |
|
|
||||||
| Operation Flashpoint: Dragon Rising - Mission Editing and Modding Chat Zone A little area for all you mission editors and modders to chat and discuss ideas. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
28-10-2009, 04:12 AM
|
#1 (permalink) |
|
Member
Join Date: Oct 2009
Location: USA - GA
Posts: 61
|
In a mission I'm making, units spawn when you enter a triggerzone and despawn when you leave that same triggerzone.
I give you the following code: Code:
function onEnter_ts1(zoneName, unitName)
OFP:activateEntitySet("s1");
end
function onLeave_ts1(zoneName, unitName)
OFP:destroyEntitySet("s1");
end
Does anyone see any problems?
__________________
MAKE YOUR OWN ZOMBIE MISSIONS! http://community.codemasters.com/for...54#post5850554 |
|
|
28-10-2009, 05:01 AM
|
#2 (permalink) |
|
Senior Member
Join Date: Sep 2009
Posts: 212
|
you don't need the " ; " after your commands. I'm not sure if that will make a difference though it may be worth a try.
__________________
Dumpster Babies If your looking for like minded team players check out Tactical Gamer Map Usage & Advanced AI Control Guide "The ideal tyranny is that which is ignorantly self-administered by its victims. The most perfect slaves are, therefore, those which blissfully and unawaredly enslave themselves." Dresden James |
|
|
28-10-2009, 06:01 AM
|
#3 (permalink) |
|
Member
Join Date: Oct 2009
Posts: 46
|
The semicolon is optional in LUA. Assign your entity to a setID first, then use that setID to despawn them.
Code:
function onEnter_ts1(zoneName, unitName)setID1 = OFP:activateEntitySet("s1");end function onLeave_ts1(zoneName, unitName)OFP:destroyEntitySet(setID1);end |
|
|
28-10-2009, 11:22 AM
|
#4 (permalink) |
|
Senior Member
Join Date: Oct 2009
Posts: 239
|
I've found that destroyEntitySet can be unreliable, to the point that at times it just doesn't work at all. Using despawnEntity, on the other hand, seems to get 'em every time - but it does involve a lot of tedious coding.
__________________
Code:
function onFinishedTyping(userName, messageName)
talking_sh*te=OFP:isUserName("private_pile")
if talking_sh*te==true then
OFP:clickButton("submit", "OVERRIDE")
end
end
|
|
|
28-10-2009, 01:04 PM
|
#5 (permalink) |
|
Member
Join Date: Oct 2009
Location: USA - GA
Posts: 61
|
Thanks for speedy replies everyone
![]() ![]() Its true, the destroy entity set is really annoying. But its not working even after I've assigned IDs to everything. Here is the revised code: Code:
function onMissionStart()
ts2spawn = 0;
ts1spawn = OFP:activateEntitySet("s1");
end
function onEnter_ts1(zoneName, unitName)
ts1spawn = OFP:activateEntitySet("s1");
end
function onLeave_ts1(zoneName, unitName)
ts1spawn = OFP:destroyEntitySet("s1");
end
function onEnter_ts2(zoneName, unitName)
ts2spawn = OFP:activateEntitySet("s2");
end
function onLeave_ts2(zoneName, unitName)
ts2spawn = OFP:destroyEntitySet("s2");
end
__________________
MAKE YOUR OWN ZOMBIE MISSIONS! http://community.codemasters.com/for...54#post5850554 |
|
|
28-10-2009, 01:21 PM
|
#6 (permalink) |
|
Member
Join Date: Oct 2009
Posts: 46
|
@Demonfire, did you use 'despawn' or 'destroy'? You said destroy was annoying and not working but your code uses destroy.
@Pile, I have the exact opposite results. Destroy works for me and despawn doesn't. Here's my mssn sample: http://www.filefront.com/14812401/test_despawn.rar Move to the left to destroy 'EntityLeft' and move to the right to despawn 'EntityRight'. Leaving the triggerzones respawns the respective entity. The code: Code:
SetID1 = 0;
SetID2 = 0;
function onMissionStart()
-- Spawn both entity sets when the mission starts
setID1 = OFP:activateEntitySet("EntityLeft");
setID2 = OFP:activateEntitySet("EntityRight");
end
-- this function displays messages in the log
function showMsg(strMessage)
OFP:displaySystemMessage(strMessage);
end
-- uses destroyentityset to remove entities
function onEnter_tzDestroy(zoneName, unitName)
showMsg("Destroying left entity..");
OFP:destroyEntitySet(setID1);
end
-- uses despawnentity to remove entities
function onEnter_tzDespawn(zoneName, unitName)
showMsg("Despawning right entity..");
OFP:despawnEntity(setID1);
end
-- respawns entities on the left when player leaves the zone
function onLeave_tzdestroy(zoneName, unitName)
showMsg("Re-activating left entity..");
setID1 = OFP:activateEntitySet("EntityLeft");
end
-- respawns entities on the right when player leaves the zone
function onLeave_tzdespawn(zoneName, unitName)
showMsg("Re-activating right entity..");
setID2 = OFP:activateEntitySet("EntityRight");
end
Last edited by ZipD; 28-10-2009 at 01:31 PM. |
|
|
28-10-2009, 04:31 PM
|
#7 (permalink) |
|
Member
Join Date: Oct 2009
Location: USA - GA
Posts: 61
|
Thanks ZipD, this works!!
I'll upload my mission when its done (conversations might take a while though) Thanks everyone XD
__________________
MAKE YOUR OWN ZOMBIE MISSIONS! http://community.codemasters.com/for...54#post5850554 |
|
|
08-11-2009, 06:09 AM
|
#8 (permalink) |
|
Junior Member
Join Date: Apr 2003
Posts: 5
|
I find I still can't get this to work, no matter what I try. I get the "Entered South Middle Zone" msg, but never the "Despawned Radio Tower Set" msg (or the tank "test2").
Any ideas? I can get one group to spawn, but can't then switch them off so I can spawn others ![]() Code:
function onEnter_sthmiddlezone_usmc(zoneName, unitName) --When entering the South Middle Zone
OFP:activateEntitySet("sthmiddleset") --Turn on South Middle Zone entity set
OFP:destroyEntitySet("radiotowerset") --Destroy RadioTower set
OFP:destroyEntitySet("villageset") --Destroy Village set
OFP:destroyEntitySet("nthmiddleset") --Destroy North Middle set
OFP:displaySystemMessage("Entered South Middle Zone")
end
function onDespawnEntitySet_radiotowerset( setID )
OFP:destroyVehicle("test2")
OFP:displaySystemMessage("Despawned Radio Tower Set")
end
|
|
|
08-11-2009, 06:38 AM
|
#9 (permalink) |
|
Member
Join Date: Oct 2009
Location: USA - GA
Posts: 61
|
Code:
function onEnter_sthmiddlezone_usmc(zoneName, unitName) --When entering the South Middle Zone
OFP:activateEntitySet("sthmiddleset") --Turn on South Middle Zone entity set
OFP:destroyEntitySet("radiotowerset") --Destroy RadioTower set
OFP:destroyEntitySet("villageset") --Destroy Village set
OFP:destroyEntitySet("nthmiddleset") --Destroy North Middle set
OFP:displaySystemMessage("Entered South Middle Zone")
end
__________________
MAKE YOUR OWN ZOMBIE MISSIONS! http://community.codemasters.com/for...54#post5850554 |
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|