Jump to content
Sign in to follow this  
pixelmonkey

Cash system scripting help!

Recommended Posts

I've been trying to create a cash system on my Arma 2 server for about 2 days now, and I've run into one initial issue. I've added a function which the player can activate to view how much money they have and it prints the value out as a silent hint. Instead of printing "You have: $100" or something like that, it prints out 'You have: $any". Please help me find the error in my code.

Init.sqf:

money = 0;

Player Init:

this addAction ["Check Money","moneycheck.sqf"];

moneycheck.sqf:

hint format ["You have: $%1",money];

When I select the action in game, the hint pops up but displays: "You have: $any". Please help me fix this problem. Thank you in advance. :)

Share this post


Link to post
Share on other sites

is "money" defined inside of an "if (isServer) then" scope?

Because then a client wouldn't have access to it without using publicVariable.

Share this post


Link to post
Share on other sites
is "money" defined inside of an "if (isServer) then" scope?

Because then a client wouldn't have access to it without using publicVariable.

No, it's not. The only code I've written for this action is in the original post. I just don't understand why It's not working. Everyone else on the internet doesn't seem to have the same problem as I do.

---------- Post added at 14:53 ---------- Previous post was at 14:52 ----------

I've tried so many times, using so many methods, It's still not working for me.

Share this post


Link to post
Share on other sites

I would suggest checking your .rpt file. The "any" error is often seen with null, undefined or wrong data types. Usually they throw an error to the .rpt file when they occur.

For example, if you inadvertently hit "O" as in "Oscar" instead of "0" as in zero, it would read an undefined data type (O being an undefined variable) and display "any". That would log to the .rpt file.

The only other thing I can think of would be that somewhere another script is redefining your "money" setting to a null data type.

--- Edit --

In your moneycheck.sqf, put this:

diag_log money;
diag_log format ["money: %1",money];
player sidechat format ["money: %1",money];
hint format ["You have: $%1",money];

when you call the script, a sidechat should appear telling you what the money variable returns. Likely to be same as the hint.

The diag_log command will log the actual value and the format string into your .rpt file. If nil (undefined) an error is logged instead of the value.

Edited by OpusFmSPol

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  

×