Forum Jump :

Author Message


Posts: 3
Rank:


Level: Member

Country: br
Location: RS
Occupation:
Age: 25
In-game name: DeWitt

 
#1 Posted at 2014-11-29 22:35        
     
Hi guys, I'm new on scripting, and I'm stuck in a script to get a string from MySQL and put into a variable:

I tried everything, but nothing seems to work...

...
_db = "armadb";
_query = format ["SELECT uniqueid FROM ppersistent WHERE pid = _uid"];

_checkeduid = "Arma2Net.Unmanaged" callExtension format ["Arma2NETMySQLCommand ['%2', '%1']", _query, _db];
...

All ok here, Arma2net logs says that a value was got from mysql, and it returns an Array:
"[[[31645987316458754]]]"
All above is ok, no errors. The problem happens next, when i try to remove the brackets using "select" and try to attribute the output to _checkeduid2:

_checkeduid2 = (((call compile format["%1",_checkeduid]) select 0) select 0) select 0;

I'm pretty sure that I'm doing something wrong here, but, not sure. Anyway..
I've tested with "typeName" and now the value is a string, not an array anymore:

31645987316458754

But, when I try it:

if (_uid == _checkeduid2) then {player sidechat format ["%1",_variable3]} else {player sidechat format ["%1",_variable4]};

It return's an error:
Error Undefined variable in expression: _checkeuid2

Using diag_log, the variable shows as defined:

diag_log format ["Returned value for checkeduid2 is %1",_checkeduid2];

In .rpt file it works as expected:
"Returned value for checkeduid2 is 31645987316458754"

But I don't understand why it does not work in the condition statement?

So, I read a lot of stuff about Arma2NET and ARMA3 scripting, I've tried a lot of things and nothing works, I'm stuck here for days trying to solve the problem.

Any ideas? Any help would be appreciated. Thank you.

This post was edited by DeWitt (2014-12-01 00:41, 1054 days ago)

Don't give up... *THUMBS UP*

Author Message


Posts: 250
Rank:


Level: Member

Country: ca
Location:
Occupation:
Age:
In-game name: austinXmedic

 
#2 Posted at 2014-11-30 01:46        
     
Check the structure of where the variable is defined. If it's inside some commands or code blocks it might not be accessible outside of that code block or command. I had this problem a while back and was stuck scratching my head for a few days until I fixed it off dumb luck.

Some of my work:
http://steamcommunity.com/sharedfiles/filedetails/?id=287343671 -- Unit Play/ Unit Capture Functions Guide
http://steamcommunity.com/sharedfiles/filedetails/?id=265454265 -- Zeus Guide
add me on steam: austin_medic

Advertisement


Author Message


Posts: 3
Rank:


Level: Member

Country: br
Location: RS
Occupation:
Age: 25
In-game name: DeWitt

 
#3 Posted at 2014-11-30 03:19        
     
# austin(medic) : Check the structure of where the variable is defined. If it's inside some commands or code blocks it might not be accessible outside of that code block or command. I had this problem a while back and was stuck scratching my head for a few days until I fixed it off dumb luck.

Thanks for the reply, but, there is no code blocks yet, is just codes line after line...

I've tried to place the "problematic" part into a single function, but it still failing when runs.

The fun thing, is that "diag_log" placed after all the code works just fine.
Somehow, just the function is not recognizing the variable. *DONT_KNOW*

Don't give up... *THUMBS UP*

Author Message


Posts: 250
Rank:


Level: Member

Country: ca
Location:
Occupation:
Age:
In-game name: austinXmedic

 
#4 Posted at 2014-11-30 04:24        
     
are you passing that variable to the function? or is the variable defined or all scopes (global)

if your not passing it to the function - obviously theres a problem there. If its defined in all scopes then it will be recognized by everything, anywhere.

Some of my work:
http://steamcommunity.com/sharedfiles/filedetails/?id=287343671 -- Unit Play/ Unit Capture Functions Guide
http://steamcommunity.com/sharedfiles/filedetails/?id=265454265 -- Zeus Guide
add me on steam: austin_medic

Author Message


Posts: 3
Rank:


Level: Member

Country: br
Location: RS
Occupation:
Age: 25
In-game name: DeWitt

 
#5 Posted at 2014-12-01 00:34        
     
Solved... *YAHOO*

I used "if (isDedicated)", passed through a PublicVariableEventHandler "packing" the value in array format.
Then I selected the "packet" and "value" in "else", and the statement now works just fine.

Thank you.. austin(medic) *THUMBS UP*

Don't give up... *THUMBS UP*