Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
zorilya

addaction on vehicle creation.

Recommended Posts

hi there,

I am currently trying to get my head around writing configs as i believe this will solve the problem i'm having.

the problem is that i would like to execute a piece of code when a specific item is created. I theorised that there must be some way to add an init code for this item in the config file and therfore when it is created my code will run.

failing that i was looking around for some way to detect when an item has been created. from there i would check what it is and run the code if the item was appropriate.

the item is a explosive and i have developed a function that allows you to place the explosive on an object. but i need somewhere to add the action for the explosive and this is my problem.

i could just run a trigger on the player and check the contents of the trigger every few seconds but that seems a bit overkill.

any ideas?

Share this post


Link to post
Share on other sites

The problem is that addAction is local, so you'd create the vehicle then have to tell the clients to addAction to it. publicVaribles would be a good way to do this. Have a PV eventhandler waiting for some sigh from the heavens then when it receives it add the action.

Quick google search seems to show this as a good example.

Share this post


Link to post
Share on other sites

i'm afraid this doesn't deal with my issue... i'm looking to add an action to an explosive when it is placed. the reference material you gave deals with adding an action to an already placed object.... it is the sensing when the explosive has been placed that is the problem here

Share this post


Link to post
Share on other sites

Here's a probably better example.

You pre-setup a publicvariable event handler which watches an array and when it's triggered (when the array is broadcast) it adds actions to whatever is in the array. Then when you spawn explosives just add them to that array, broadcast it and the PVEH will add the action for anyone listening.

Share this post


Link to post
Share on other sites

the only problem i have is gathering the explosives in the first place. i thankyou for the suggestions and i can see how i might apply them in other circumstances but i can't seem to get the explosives when they are placed in the first place... just to be clear, i am not creating these explosives with a create vehicle command they are being places normally by units in the game. any idea how i might execute code on the placement of a given explosive?

Share this post


Link to post
Share on other sites

Oooh, in that case you might want to use fired eventhandlers on the players to register that an explosive has been placed. Or something even worse like looping nearest object checks? :)

Share this post


Link to post
Share on other sites

tried the fired EH... sadly doesn't trigger when an explosive is placed. so i went with the nearobjects check with a 0.5 second sleep on the loop. this sadly was my worst idea i thought but hey it's done now. thanks anyway :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

×