Jump to content
Sign in to follow this  
alleycat

Attach eventhandler to new unit created by zeus

Recommended Posts

If I wanted to attach an eventhandler to every zeus created AI unit, how would I do that? I could use the init field after I placed all my units or do it for each manually but that is so ghetto.

Share this post


Link to post
Share on other sites

I've been using the CuratorObjectPlaced event handler, adding to the GM module in my Init script, seems to work fine. You just have to check to make sure the placed object is an AI unit in whatever function you're calling from that event handler.

Although I have had some problems getting this to work in MP, but i'm not sure if it's related to the event handler or the function i'm calling.

Share this post


Link to post
Share on other sites

I have tested the handler in mp and it appears to work.

Share this post


Link to post
Share on other sites
I've been using the CuratorObjectPlaced event handler, adding to the GM module in my Init script, seems to work fine. You just have to check to make sure the placed object is an AI unit in whatever function you're calling from that event handler.

Although I have had some problems getting this to work in MP, but i'm not sure if it's related to the event handler or the function i'm calling.

just don't forget the units created by Zeus are local to this Zeus. I also played a little yesterday again with this. It's getting clearer for me how it works and locality is an issue for some functions. I still need to master some more detail, like if you add the curator event to the module but on server and player. let say the object placed event. where will the handler code be executed? on the Zeus player or on every pc that has executed the handler?

I still need some test to make sure how everything get together.

regards,

Holo.

Share this post


Link to post
Share on other sites
just don't forget the units created by Zeus are local to this Zeus.

what?

Is that true for a dedicated server too?

Edited by alleycat

Share this post


Link to post
Share on other sites

tested on dedicated only, so yes it is.

see that as if Zeus was only a player creating AI. I don't know if BI will change this though. Or maybe they plan to make locality less a problem too, any way, I'll wait until next patch to see where they are going. (I'm too lazy to put my game in dev)

Share this post


Link to post
Share on other sites

Hmm, this is actually causing me a huge headache, can't seem to figure out why the event handler isn't firing for other players during MP.

In my Init file I have:

gmZeus addEventHandler ["CuratorObjectPlaced", {
[[_this select 1],"FNC_VehicleEV"] spawn BIS_fnc_MP;
}];

and in the my function script (which is also being loaded on Init:

FNC_VehicleEV =
{
_vehicle = _this select 0;
if((_vehicle isKindOf "landVehicle") or (_vehicle isKindOf "Air")) then
{
	_vehicle addEventHandler ["GetIn", {if(player == (_this select 2)) then
	{
	[[_this select 2], "FNC_playerGetInVehicle", _this select 2, false] spawn BIS_fnc_MP;
	}}];
};

}

All of this works fine if I try it, being the server/host, but it doesnt' work for any other players, they don't get the effects of the "FNC_playerGetInVehicle" function.

Any ideas? I'm banging my head against the wall at this point. No error messages in the log, it's just something to do with locality

Share this post


Link to post
Share on other sites

Anyone have any ideas? Still can't quite figure this one out

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×