Jump to content
Sign in to follow this  
A.Cyprus

Alternative approach to setVariable

Recommended Posts

Hello chaps

Entirely new to Arma scripting, I've been enjoying having a go at my own add-on.

It started off as a simple idea at first and, although inflicted a little by feature creep, is almost finished - bar one feature:

My use case has a particular need to determine the previous 'owner' of an 'item' when the player picks it up, where 'owner' is the player that originally dropped it and 'item' in this particular case is a secondary weapon (a launcher).

It appears I cannot use setVariable/getVariable to store this information with the weapon itself because I cannot obtain the object reference to it, needed to pass to these functions.

player secondaryWeapon returns a String, as opposed to unitBackpack player, for example, which would work in the scenario above.

Persisting owner information in the weapon holder instead is not really a viable option, since the secondary weapon might have been picked up, moved and dropped by another player already.

Would the collective knowledge and experience of this forum be able to help by advising me of another possible approach to solving this issue please?

I'm not necessarily looking for a fully coded solution, a nudge or hint in the right direction would be good enough.

Hope my description is clear. Many thanks.

Share this post


Link to post
Share on other sites

For me, I would do this with event handlers. On a put event, store player, weapon, location and time information somewhere, whether it be on the holder, a game logic that you spawn, a global variable or publishing it to the server to hold on to.

On a take event, check for information related to this weapon wherever you stored it and match them up. You would probably only need to match location and weapon type for it to work, then grab the player information from the rest of the info that you stored.

I might even keep a public variable somewhere that has a whole list of these, and every once in a while iterates through and checks to see if the weapon is still around or if a certain amount of time has elapsed as the condition to remove the element from the list. A take event would also remove it from the list.

Share this post


Link to post
Share on other sites

Thanks for the advice.

I had considered doing something similar with a location check but ruled it out as an option because the logic would break if somebody had already picked it up and moved it.

I'm planning this as a client side add-on, and other players might not be running it, so if anybody else took the weapon or moved it from the drop location, there would be no way to match up the original position in the stored data when the owning player eventually picked it up, right?

I like your idea on the expiration checks, might work that into the concept some how.

Edited by ACyprus

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  

×