Jump to content
Sign in to follow this  
Comradesniper

Money system question

Recommended Posts

Hey,

I am working on a Crime City style mission for ArmA, and I need to implement a money system.

I want this system to be easily modded, allowing for more player spawns to be added or taken away in the mission editor with the minimum for work for the person adding new units.

The money for the player must be accessible to other scripts, for buying stuff, selling, etc.

So far, I have come up with two different approaches, but my knowledge of scope and multiplayer scripting are stopping me going further.

My first idea is to have a universal money variable on the client that holds this players money only. This would allow all scripts to see this value, but it does seem a bit limiting. There is no way to see other peoples cash if this is needed in future additions.

My second idea is a multidimensional array. One part holds the names/IDs of the players, the other the corresponding money values. I don't know how to list all the players/playable characters in the current game though.

But then, how does this synchronise over a multiplayer game? What about Join In Progress?

If anybody has any better ideas how to implement this, please tell me! banghead.gif

Share this post


Link to post
Share on other sites

I will tell you right now it won't be easy. Someone may come along and suggest a method, but in truth there is often limitations or problems with most implementations. I suggest you look into some of the CTI missions and see how it is done.

Personally, I prefer the client request method. It works best with CoC's Network Services scripts as the code becomes a single script/functions and a few lines here and there everytime you request money. The way it works is simple:

On the server exists all monitary information (array or otherwise). There is also a single function which requests/deposits money into the arrays and handles validation (i.e. does player have enough? if no, send error. etc...)

Everytime the client performs some action which requires money, you simply request/deposit by calling the function server-side and simply providing the values. This is where CoC NS is a huge help. On the client side it can be one function call - without NS, you need to PV a bunch of data back and forth manually.

The return result should say whether or not you have enough money or what your balance is. This is the best because it completely ignores actions and such and allows you to mod very easily by implementing your own methods of buying/selling stuff.

Share this post


Link to post
Share on other sites
COC ported that stuff to arma?  Didn't know that.

Did I ever once mention or imply that in my post? wink_o.gif

I mentioned CoC_NS because that is how I accomplished it in OFP and I mentioned it was my preferred method because it reduces code. I did not say it was currently possible - nor did I say it wasn't.

Any other statements, infered or otherwise, I will not held responsible for. wink_o.gifwink_o.gifwink_o.gif

Share this post


Link to post
Share on other sites

Word lawyering huh? The way you mentioned it seemed to imply it to me, but then prehaps that was just optimisim?

wink_o.gif

@Comradesniper

That's a hard question to answer without sitting down and doing a lot of testing. Some things just work different in arma, so it's hard to say really.

Share this post


Link to post
Share on other sites

bleh, I am doing this as I am learning computer programming. I know exactly how I would do this in, say, Python, but I can't get the bloody thing to work in OFPs scripting language.

I have just resigned myself to using public variables and a load of if statements. I can't make sense of the CRCTI code, though it looks much more like what I'm looking for.

Share this post


Link to post
Share on other sites

I thought CoC is on it's way. There are quite a few videos of it out. Unless the food i ate was contaminated.

As for doing a money system, Crash has it correct. There is quite a bit to making it work (Correctly). I have been bashing my head in building scripts that allow any other script to latch onto and help control.

I use two methods for all my processes that need to send to the client or server.

1. Createvehicle and set the init field.

This is easier than using public variable as it just fires off on each client. I use this when I am starting scripts on a specific client. Since most of the scripts I am writing are not contained on the hard drive this is pretty much the only way to launch some of them.

2. PublicVariable

You will have to monitor this variable all the time to see what clients are requesting and then return results. Aka one variable for requests and another that the server sends down data or vice versa. I don't use this one to often as most of the variables I use are never created until I launch a script. So its a toss up. Mostly i use this one for dialogs on the clients. Populate them with HTML files, map information and buttons.

There are some other methods that you can use but that's even more tricky and causes the game to crash. Laugh.

On another note, try not to store things on the client that would affect the game play. I can tell you now that if you store the money on a client's computer someone will cheat the system rather fast and that is unfair to others. Try to make it so that everything has to come from the servers. I check each unit on the map all the time to make sure they have not obtained anything that the server does not know about. If so i have a wonderful script that kicks them out of the game completely (Since we cannot use a kick command from our scripts that i know of).

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  

×