OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: mad_addons on 03 Aug 2005, 05:10:38
-
Hi all,
I was working on the OnSingleMapClick with CreateUnit, and I've come to several problems.. due to lack of my intelligience.
First, how do you set up a position on the location you clicked using OnSingleMapClick? For example, moving the game logic to that clicked area. If possible, could anybody tell me the syntax for this?
Is there a way to delete the dead bodies so that I can keep spawning units regardless of 64 group cap?
If you could answer those questions, I'd appreciate it.
-
onMapSingleClick {"SoldierEB" createUnit [_pos,group player]}
_pos is automaticly defined when you click so all you need to do is stick this in the init, however you will be able to create endless guys with this so it will need more work depending upon what you intend to do.
To delete bodies just give killed event handlers and the deletevehicle command for the scrpt.
-
Okay, I'll get working on it.
Also, when I put init for soldiers I create on the script, it doesn't seem to work? Is it not supposed to?
I appreciate your help, RujiK.
-
yes, it is very much supposed to work, and does, flawlessly, when used with correct syntax/commands etc
perhaps you could post your createunit code
-
Uh.. I erased it just few hours ago.. sorry..
Okay, now I know that init works... Another question.
I was looking into another thread and I saw something with _alt and _shift in the field. Are these automatically applied to OnSingleMapClick or do I have to set them up?
-
uh... anyone? sorry, but i really need to get this done as soon as possible.
-
Sorry, but i have another thing to say.
OnMapSingleClick {"OfficerW" createunit [_pos, west1, "this addeventhandler ["killed", {deletevehicle this}]"]}
That is my code. When I try to execute it, it says. Unknown operator "killed". Why's that?
-
because ofp doesn't read quotes the way you would. it sees this:
OnMapSingleClick {"OfficerW" createunit [_pos, west1, "this addeventhandler ["killed", {deletevehicle this}]" ]}
the curly brackets( { ) can be used instead of quotes, and will always work the way you want it to
-
Yeap... that's about the size of it.
Back in the day before curly brackets came into OFP, we used to have to use a set of double quotes. It could get very confusing, but to cut a long story short this line should work for you:
OnMapSingleClick {"OfficerW" createunit [_pos, west1, "this addeventhandler [""killed"", {deletevehicle this}]"]}
Any set of quotes that's already inside a set of quotes needs to have two quotes. It gets even more fun using foreach commands... eg.
"_x setbehaviour ""Combat""" foreach units group
The 3 quotes at the end can really throw you off a bit ;)
-
#Bump
-
lol why? is this problem coming up a lot recently?
-
lol why? is this problem coming up a lot recently?
Not really, but due to the large number of topics shunted back and forth from Advanced and General, recent posts were bumped back to the top.
;D ;D
Planck
-
ahhh
i noticed that topics had been moved around. i know this is getting offtopic but is there any particular reason why?
(My curiousity is exploding!! lol)
perhaps i should pm you instead. if so, go ahaed and delete this post or i will...or something
-
is there any particular reason why?
Yes.
Read this new sticky post. (http://www.ofpec.com/yabbse/index.php?board=8;action=display;threadid=25061) ;)
PS - it's very rare that posts are deleted. Questions about why something is happening at OFPEC, or suggestions about how it could be done better, are always welcome.