Jump to content
Sign in to follow this  
Atlas1205

How do i find and delete variables with same prefix from profilenamespace?

Recommended Posts

for example, when im trying to reset my mission on a server, which has player status saved into the server's profilenamespace as variables, and they are all in a format a 'rum_(player UID)". 

what kind of code can i use to set all variables starting with "rum_" to nil?

 

call me silly, but i've tried this, and the result was disastrous...

private _gameanduid = format ["rum_%1",_i];
for "_i" from 0 to 99999999999999999 do {profilenamespace setVariable [_gameanduid,nil]};

 

Share this post


Link to post
Share on other sites

 

hint str _a;
_a = _b + _c;
_b = 1;
_c = 2;


I don't understand why this doesn't work? Please help!

  • Like 2

Share this post


Link to post
Share on other sites
4 minutes ago, killzone_kid said:

 


hint str _a;
_a = _b + _c;
_b = 1;
_c = 2;


I don't understand why this doesn't work? Please help!

I don't get it...

Share this post


Link to post
Share on other sites
4 minutes ago, shape1205 said:

I don't get it...


It was a joke, you are using variable before defining it. This is like basics, man. Anyway this is how you can clean profile namespace:

 

{
	if (_x find "rum_" == 0) then 
	{
		profileNamespace setVariable [_x, nil];
	};
}
forEach allVariables profileNamespace;
saveProfileNamespace;

 

Share this post


Link to post
Share on other sites
1 minute ago, killzone_kid said:


It was a joke, You are using variable before defining it. This is like basics, man. Anyway this is how you can clean profile namespace:

 


{
	if (_x find "rum_" == 0) then 
	{
		profileNamespace setVariable [_x, nil];
	};
}
forEach allVariables profileNamespace;
saveProfileNamespace;

 

ah, no wonder i had to rearrange their order to get 3... thanks for your help. 

really need to look through the whole wiki next time... didn't know there is such thing "allvariables"

  • Like 1

Share this post


Link to post
Share on other sites
17 hours ago, fn_Quiksilver said:

only works in editor, allvariables profilenamespace disabled in MP (praise the gods)

is there a workaround? i see there's an example on community wiki, but not sure how to do it.

currently making a mission that stores player status to server's profilenamespace, so  I myself come up with a workround, that is storing all player data to one variable, and setting it to nil would be all i need to do to reset the progress.

Share this post


Link to post
Share on other sites

you could create an array and store all UIDs since server start / last reset in it. Then you have all the variable names you need.

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  

×