Jump to content
  • 0

variable <null> need to populate but not 0 out


DirtySanchez

Question

Hey guys just looking for a little help

Im trying to do a check on a variable which on first join is a null response

Ive got some startup code started that checks for that null variable and populates it with a 0

_cR = profileNameSpace getVariable [_pR,[]];
if(isNil {profileNamespace getVariable "_cR"}) then {profileNameSpace setVariable [_pR, 0]};
It does its job as tested

I then ran a setVar to place a 1 in it.

ran a hint to verify, then ran the code again, then another hint.

The final result was a 0 again....

any help is appreciated

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Hey guys just looking for a little help

Im trying to do a check on a variable which on first join is a null response

Ive got some startup code started that checks for that null variable and populates it with a 0

 

_cR = profileNameSpace getVariable [_pR,[]];
if(isNil {profileNamespace getVariable "_cR"}) then {profileNameSpace setVariable [_pR, 0]};
It does its job as tested

I then ran a setVar to place a 1 in it.

ran a hint to verify, then ran the code again, then another hint.

The final result was a 0 again....

any help is appreciated

 

im not sure why you are using profilenamespace, as it is slow and depriciated since it can become corrupt, not to mention the fact that you have to secure it somehow or it can easily be changed before entering a game.

 

but in your example you should probly do something like this:

_cR = profileNameSpace getVariable [_pR,[]];
if(_cR isEqualTo [])then{profileNameSpace setVariable [_pR, 0]};

this is becourse a variable that is nil will return the value you set as default.

 

if you want it to be nil, you should do something like this:

if(isNil (profileNameSpace getVariable _pR))then{profileNameSpace setVariable [_pR, 0]};
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...