Jump to content
SpaydCBR

missionNamespace vs player namespace

Recommended Posts

Hello, quick question.

 

Let's say a player can spawn an ATV through an addAction attached to a flag post. The player can only spawn 1 ATV at a time and when he dies, his ATV gets deleted so he can spawn another one at the flag post after he respawns.

 

My method is to assign the ATV to a variable that can reference the player so that I can retrieve the ATV "assigned" to him and delete it.

 

Is it better to use the player's namespace

player setVariable ["atv",_atv]

or missionNamespace?

missionNamespace setVariable [format["atv_%1",player],_atv]

I'm not sure which method to choose. Is there a reason to choose one over the other, or some preferred convention I should follow? Is there even a better way to do this?

Share this post


Link to post
Share on other sites

Setting a variable on the player, is in objectNamespace, so the value only exists when defined and when the object itself exists. missionNamespace is essentially the same thing as "myGlobalVariable = true" and is persistent through respawn/death, so in your case I would recommend missionNamespace over setVariable on the player. Though either would work, depending on your setup for respawn and your general knowledge base on locality and when you can access certain information :D.

Share this post


Link to post
Share on other sites

Alright, thanks. I guess I'll use missionNamespace just to keep everything in one place

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

×