DirtySanchez Posted June 18, 2015 Report Share Posted June 18, 2015 Hey guys just looking for a little helpIm trying to do a check on a variable which on first join is a null responseIve 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 testedI 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 More sharing options...
0 Halvhjearne Posted June 18, 2015 Report Share Posted June 18, 2015 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 More sharing options...
0 DirtySanchez Posted June 18, 2015 Author Report Share Posted June 18, 2015 Thanks HalvYour example isEqualTo []) will suffice to resolving my issue. Link to comment Share on other sites More sharing options...
Question
DirtySanchez
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
It does its job as testedI 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
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 accountSign in
Already have an account? Sign in here.
Sign In Now