Jump to content
Sign in to follow this  
Col. Ben Sherman

[Help] Issues with values.

Recommended Posts

Hi there,

So I've been working with ArmA 2 Net now the load a value from the Database, just started to work on it real fast to see maybe I make a complete system later.

But as it is now I jus want to see how the server is handling it and all that so I made a Value that will be displayed in the hint function.

Anyways, I can't seem to figure it out what the problem is since it allways says "Any" nothing else.

So from the begining I created the value so it looked like this for example:

Value = 50;

Now it loads it from the database and insert it like this which returns it to "Any":

Value = _dbvalue;

This is the full code which some how returns it to "any" and not a number:

_guid = getPlayerUID vehicle player;
_query = format ["SELECT Handic FROM users WHERE uid = '%1'", _guid];
_dbquery = "Arma2Net.Unmanaged" callExtension format ["Arma2NETMySQLCommand ['Database', '%1']", _query];

_dbvalue = _dbquery;
_dbvalue = call compile _dbvalue;
_dbvalue = _dbvalue select 0;

diag_log format ["------------------------Loading-----------------------"];
diag_log format ["Loading from UID: %1", _guid];
diag_log format ["Loading Value: %1", _dbloadbank];
diag_log format ["------------------------------------------------------"];

Value = _dbvalue;

Do anyone have an idea what I've done wrong here?

-Sincerely

Staffan

Share this post


Link to post
Share on other sites

I'd look what _dbquery returns using a hint:

hint str _dbquery;

This way you can make sure that no malformed data is returned, thus leading to "Any" upon compiling the returned string.

You should consider looking into _dbvalue as well using the above hint to check if the array your working with is being created correctly.

Share this post


Link to post
Share on other sites

use format ["%1",_value] instead of str _value. "any" will not show with str but will show with format (due to error trying to str undefined value)

Edited by Killzone_Kid

Share this post


Link to post
Share on other sites

Hi everyone,

Thanks for those posts, Sadly it's not under diag_log works great there, but not under "Value = _dbvalue;".

Sincerely,

Staffan

Share this post


Link to post
Share on other sites

So how do you actually hint the value?

Do you use "hint Value" or "hint str Value" ?

Share this post


Link to post
Share on other sites

So how is "kontostand" associated with "Value"? Or is this just an example?

Does it work if you forward-space your variable ("kontostand", "Value" or whatever) with a "str" ?

Something like

lbAdd [1, format ["Value: %2", localize "STRS_statdialog_value", str kontostand]];

(it's weird to use "str" in a format but as we are grasping at straws here we have to try everything out)

Share this post


Link to post
Share on other sites

Kontostand, is an other thing. Where to tired to so I copied the one above. But it looks the same just without konotostand.

Before I didn't load it from the database, so I did just have "Value = 1;" for example.

And now I'm loading the value, I printed the value to the logs and it says the number.

from the server log.

5:02:04 "----------------Loading Character Data----------------"
5:02:04 "Loading Character: 995862"
5:02:04 "Loading Value: 55556"
5:02:04 "------------------------------------------------------"

Source Code

_uid = _this select 0;
_query = format ["SELECT bank FROM users WHERE uid = '%1'", _uid];
_dbloadouts = "Arma2Net.Unmanaged" callExtension format ["Arma2NETMySQLCommand ['life', '%1']", _query];
_dbloadouts = call compile _dbloadouts;
_dbloadouts = _dbloadouts select 0;
_myValue = (_dbloadouts select 0) select 0;
Value = _myValue;

diag_log format ["----------------Loading Character Data----------------"];
diag_log format ["Loading Character: %1", _uid];
diag_log format ["Loading Bank: %1", Value]; [b]// Works perfect here[/b]
diag_log format ["------------------------------------------------------"];

Since it's printing it out it's working, but some how it's just placing "any" in the dialogs. I feel like it's not really worth to re-write the dialog code and thats because this "Value" is connected to more then one sqf file.

The only thing I need to do is to get "Value" to a Int or how I now spell it. My guess is that it's adding all details like if it was a string and not a int value.

Sadly I have no clue at all how to convert it.

But at the same time I have no clue even what I'm talking about. Pritty new to this.

Share this post


Link to post
Share on other sites

Well if "Value" is used in more than one sqf-file, maybe it get's altered before you show it on your dialog.

You could test for this occurance naming your variable "Value" to something unique, like "iWantToTestThis = _myValue"; and try to output that in your dialog.

If this works, you know the cause of your problem and have to search every of your files in which "Value" is used.

Share this post


Link to post
Share on other sites

I came to the conclution that it's being altered, since it's printing it to the dialog.

Anyways I'm going to go over all scripts to see what I'm doing wrong.

I'm working on a script that my friend where creating, well we kinda where together but I don't really have that much of scripting knowledge on ArmA 2.

A few month ago he passt away because of his hart condition so now took over all his work because this was his dream.

It's some time kinda pain in the ass, but I can't really quit I'm doing this for him.

Just one questions, a time ago I got "any" and an other time "Scalar" what is the difference?

UPDATE:

Okey, scratch that now it's even printing it as "any" must be that when I return it form the database it's returned as a string and when I place it on the variable it's giving me "any"

Found out that I must call the Value with a function which I'm doing now. Now it even returns "any" to the log.

Edited by Staffan
UPDATE

Share this post


Link to post
Share on other sites

Scalar is the result of mathematical calculations - mostly returned when devided by zero or when other strange calculations are made.

Never got that result in valid calculations though xD

Share this post


Link to post
Share on other sites

scalar means that the engine knows the type of variable (which is scalar i.e. number) but value is undefined.

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  

×