Home   Help Search Login Register  

Author Topic: SPON Money v0.1.2 (ACCEPTED)  (Read 18622 times)

0 Members and 1 Guest are viewing this topic.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
SPON Money v0.1.2 (ACCEPTED)
« on: 04 Nov 2007, 23:39:51 »
SPON Money v0.1.2
- Released: 2007-11-06
- Install size: 59k + SPON Core (Core v0.1.2 used in demo)
- 100% scripts
- No addon dependencies
- See attached README.html for full details

Overview
Players have a cash balance (what they are carrying) and can buy and sell things at shops. Optionally, they can also have a bank balance and can deposit and withdraw money at a bank.

This script pack requires that SPON Core scripts pack is installed in the mission (v0.1.2 or higher). Both SPON Money and SPON Core are script-based and do not require any addons to be installed on client or server.

Features
- Standard (Shopping)
    * Player cash balance is recorded.
    * Can buy specific weapons, magazines and one-use items (explosives, grenades, etc) or vehicles at specific shops (which can be any object that can have actions added).
    * Can sell any weapons and one-use items at any shop. Magazines can't be sold because you can't query how many rounds are left (well, except the one in the weapon, but you can't specifically remove that magazine).
    * Information display for last item selected to buy/sell.
    * Accurately tracks what you are carrying and so does not allow you to buy anything you can't carry.

- Optional (Banking)
    * Can transfer money into and out of the universal bank at any banker (which can be any object that can have actions added) using a dialog.

Limitations
    * If you log into an MP game for a second, or subsequent time, then your cash and bank balance is reset to the initial value.

Plans
    * Transfer of money and/or items between players in MP.
    * More and clearer documentation.

Design Aims
    * Improve gameplay in RPG- and GTA-style games.
    * Maintainability, configurability and inter-operability.
    * Avoid addons, in favour of scripting, as far as possible.
    * Compatibility with SP/MP/COOP/JIP (except Team-switch).

Credits
    * Cash (wad of banknotes) icon provided by Ultimate (john dot e dot osterman at gmail dot com)
    * Testing and suggestions from LeeHunt
    * Significant testing and feedback by members of the Regiment of Grenadier Guards [RGG] ArmA squad. Thanks fellas!

Change Log
v0.1.2
- Added
    * Demo: Added a poor independent soldier that can be played, demonstrating how to change initial bank balance based on side.
    * Demo: Added a medic soldier that can be played, demonstrating that the shop can recognise different inventory limits for soldiers.

- Modified
    * Demo: Moved the shops and banks into the centre of town, changed the models and put them into stalls to make them look more like "traders".
    * Shop: Rewrote the function that calculated slot size of magazines to guarantee the correct result for items that aren't in vanilla ArmA (i.e. from expansions and addons).
    * Shop: Rewrote the code that calculated the number of small and large slots available for the player to guarantee the correct result for player models, or configurations, that aren't in vanilla ArmA (i.e. from expansions and addons).

- Fixed
    * Shop (demo): One of the shopkeepers buys for higher prices than he buys (this is just because the shopkeeper was misconfigured in the demo, not because there is anything wrong with the scripts)!

v0.1.1
- Added
    * Shop: Item icons added to inventory lists.

- Modified
    * Bank: Created a proper banking dialog, to replace actions.
    * Shop: Removed the bank balance from the shop dialog.

- Fixed
    * Shop: Some item pictures are stretched in the blown-up item image.

v0.1.1
- Fixed
    * Shop: Can select items in both buy and sell boxes (at same time).
    * Shop: Buy/sell buttons are still enabled when the selected item is not able to be bought/sold.

v0.0.21
    * Original release as part of SPON Scripts

Get SPON Money
« Last Edit: 19 Aug 2009, 22:00:46 by hoz »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: SPON Money (DO NOT SUBMIT)
« Reply #1 on: 06 Nov 2007, 15:13:54 »
Small update to 0.1.2 (just a couple of bugfixes and improvements to the demo, mainly at the suggestion of LeeHunt). Nothing major.
« Last Edit: 06 Nov 2007, 15:15:34 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: SPON Money (DO NOT SUBMIT)
« Reply #2 on: 17 Nov 2007, 15:36:30 »
Found this post at Armaholic:
Quote from: [ LoneWolf ]
Well I've been trying out some of Spooner's nifty little scripts. I got curious with SPON Money and tired it out. I've got a anchorman2 as a arms dealer and a king as the bank. I can't understand some of his directions though. I am just dipping into this huge world of scripting and editing .

I came to a halt when I read this
Quote from: README.html
    For each shopkeeper,
    [_shop] call SPON_setShop;

    By default, this shop will only buy second-hand goods at 50% of standard price.

    0. Man, or other object, that the shop is attached to [Object]
    1. Buying second-hand goods mark-down [Number 0..N, defaults to 0.5]
    2. Selling new goods mark-up [Number 0..N, defaults to 1.0]
    3. Stock-items for sale (defaults to [[], [], []], which means the shop will not sell anything):
        0. Weapons for sale [Array of String]
        1. Magazines for sale [Array of String]
        2. Vehicles for sale [Array of String]

I don't get what's in bold, and I can't use an examples to learn from. Also he tells you to copy and paste this into init command in the editor:
Code: [Select]
    [_shop] call SPON_setShop;

For the shopkeeper, and this:
Code: [Select]
    [this] call SPON_setBank;

For the banker. Seems simple enough. When I ran the mission though I couldn't use either the shop or the bank. I also got an error about my prices.sqf about an invalid number.

=/

I admit that the documentation for setting up your own shops and banks leaves something to be desired and does assume you can fathom some things out yourself and/or aspects of the demo mission to suit yourself. Oh, and the documentation is actually wrong, which doesn't help (mainly because I changed how things worked and didn't actually make functions for setting shops and banks since the wouldn't be available at init time). Very sorry!

Setting up a shop:
Code: (init) [Select]
[this] execVM "SPON\Money\setShop.sqf";
or
Code: (in script after initMoney.sqf has been run, where shopkeeper is the name of a person or object) [Select]
[shopkeeper] execVM "SPON\Money\setShop.sqf";

As I state, this would just create a shop that doesn't sell anything and buys things from players at 50% of the full price. What my documentation was supposed to say is:
  You must pass an array of parameters to the setShop.sqf which should be arranged in this way (the numbers refer to indexes within arrays):
    0. Man, or other object, that the shop is attached to [Object]
    1. Buying second-hand goods mark-down [Number 0..N, defaults to 0.5]
    2. Selling new goods mark-up [Number 0..N, defaults to 1.0]
    3. Stock-items for sale contains three arrays (Array: defaults to [[], [], []], which means the shop will not sell anything):
        0. Weapon classes for sale [Array of String]
        1. Magazine classes for sale [Array of String]
        2. Vehicle classes for sale [Array of String]

e.g.
Although you can create a shopkeeper from the init line, it is best to create his stock list in init.sqf
Code: (init.sqf) [Select]
_stock =
[
// Weapons.
["M16A2", "Binocular", "LaserDesignator", "NVGoggles", "M136"],

// Magazines.
["PipeBomb", "SmokeShell", "30Rnd_556x45_Stanag", "M136"],

// Vehicles.
["HMMWV50", "HMMWV"]
];

// Shopkeeper sells items in _stock at 110% of normal price and buys anything 30% of normal price.
[shopKeeper, 0.3, 1.1, _stock] execVM "SPON\Money\setShop.sqf";

Setting up a banker:
Code: (init) [Select]
[this] execVM  "SPON\Bank\setBank.sqf";
or
Code: (in script after initMoney.sqf has been run, where banker is the name of a person or object) [Select]
[banker] execVM "SPON\Money\setShop.sqf";

Well, the formatting of prices.sqf is required to be very specific since it is a big nested array in a file (so is parsed just like a script). Look at my example file, but here is a simple example that just defines a couple of item types. It is an array containing 3 arrays, each of which contain arrays of [CLASS, PRICE] for each item of that type which can be bought/sold:
Code: (prices.sqf) [Select]
[
[ // Weapons.
["M9", 200],
["M9SD", 700]
],

[ // Ammo
["15Rnd_9x19_M9", 50],
["15Rnd_9x19_M9SD", 200]
],

[ // Vehicles
["HMMWV50", 100000],
["HMMWV", 50000]
]
]

Beyond that, I can't give much more help without seeing your broken prices.sqf file.

I will improve the documentation significantly in the next release, though I can't promise that will be very soon.
« Last Edit: 17 Nov 2007, 16:16:49 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: SPON Money (DO NOT SUBMIT)
« Reply #3 on: 17 Nov 2007, 16:21:36 »
I have a random question:

How does the shopkeeper determine which vehicles are "for sale" by you?  :blink: Does it just simply grab them from the immediate surroundings or what? Anyway, yus. I need to test this out some more too, and see if I can break it. :D Question: does it work with teamswitch (so that you can outfit your whole squad to suit, without having to go through the gear dialog and dropping weapons and all kinds of argh like that)? If it does...woot!  :D

Also: how much does it rely on info found in the dialog itself? I.e., is it possible to redesign the appearance of the dialog without it breaking too fast? I have to admit, your way of using #includes and having a million scripts for a million different things all tied together in some unfathomable manner doesn't make it easy for someone else to get a proper overview of what the heck is going on.  ;) I'm sure it's very efficient coding though!

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: SPON Money (DO NOT SUBMIT)
« Reply #4 on: 17 Nov 2007, 16:34:33 »
Shopkeepers don't buy vehicles at all because there are just too many issue involved (which vehicles are yours? How much is the price affected by damage and ammo? Does ammo/damage matter much in missions with free repair/reammo? Keeping the price updated every frame based on damage/ammo. Enabling/disabling selling the vehicle based on whether someone is in the crew so it couldn't be sold. etc, etc, etc.). Sorry!

Well, you can make colour/font changes to the dialog by editing "SPON\Core\ui\schema.hpp" which safely affects the dialogs in ALL SPON components without breaking anything (yay for consistency!). If you edit "SPON\Core\ui\common.hpp", then you could easily break something outside Money, even if the shop/bank looked fine.The layout #includes are mainly to make every dialog a lot more consistent within SPON and to make small modifications easier without having to recalculate all the numbers. If you don't like the layout, you should just be able to change it, as long as you keep the same controls with the same IDCs. On the other hand, if you feel the design is lacking, you could ask me to fix it ;P

You point about script complexity is valid, but my design ethos is to make the code understandable to experts, but to allow configuration options for non-experts to get exactly what they want. So, you are probably better asking for me to add options before you dig into the code.

EDIT:
Incidentally, I'm planning to add a cash machine interface when I get around to it (same as bank, but just for withdrawals). I need to make a bank with MP money transfer in it too at some point.Ack!

The script isn't Teamswitch compatible, though it could be made so with a bit of effort. Possibly worth doing in a future version, since you aren't the first one to ask for it.
« Last Edit: 17 Nov 2007, 16:53:11 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline [ LoneWolf ]

  • Members
  • *
Re: SPON Money (DO NOT SUBMIT)
« Reply #5 on: 18 Nov 2007, 19:40:13 »
 :P For some reason I didnt want to post here....

Anyway, thanks for clarifying things. I've seemed to lost that silly script though  :dunno:

« Last Edit: 21 Nov 2007, 00:47:42 by [ LoneWolf ] »

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: SPON Money (DO NOT SUBMIT)
« Reply #6 on: 18 Nov 2007, 19:52:45 »
Yes, I realise that you had to register so you could post here, but I had to register at ArmAholic just to post there to say that I wasn't prepared to answer you on a forum I never look at :whistle:

Anyway, just shout if you need more guidance, since this is a relatively complex script to set up (always a problem when you make things complex and generic ;P).
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline [ LoneWolf ]

  • Members
  • *
Re: SPON Money (DO NOT SUBMIT)
« Reply #7 on: 21 Nov 2007, 00:48:56 »
 :dry: Hmm... I reworked the prices.sqf and the init.sqf, and I get a different error. I've attached the init.sqf, prices.sqf, and the error message.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: SPON Money (DO NOT SUBMIT)
« Reply #8 on: 21 Nov 2007, 11:58:01 »
You forgot a [ in the init.sqf:
Code: [Select]
_stock1 =
[
// Weapons
["AK74", "AKS74PSO", "G36A", "G36C", "M16A4", "M16A4_ACG", "M4", "M4AIM", "SVD", "M107", "M9", "RPG7V", "Binocular", "NVGoggles", "MP5A5"],

// Magazines
["30Rnd_545x39_AK", "30Rnd_556x45_G36", "20Rnd_556x45_Stanag", "30Rnd_556x45_Stanag", "10Rnd_762x54_SVD", "10Rnd_127x99_M107", "15Rnd_9x19_M9", "PG7VR", "30Rnd_9x19_MP5"]
];

As you can see from the error message, the |#| shows that it detected the error at the end of the stock array, so it was likely that the error was somewhere in that array.

I see you added some Russian weapons into the prices file (which looks fine to my eye, but I haven't run with it). Sorry, I had intended to add them to the example file in the next version, but I got sidetracked with other things.

Good to see in your init.sqf that someone is using SPON RearView. Not had a single comment about it, so I wasn't sure if anyone even liked it or even if everyone just thought it was dumb (but didn't hate it enough to complain ;P)!

EDIT: Just noticed that you call initMoney.sqf twice. Definitely not a good plan (the first one just uses default parameters and the latter one is called with the specified parameters)!
« Last Edit: 21 Nov 2007, 12:39:48 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline [ LoneWolf ]

  • Members
  • *
Re: SPON Money (DO NOT SUBMIT)
« Reply #9 on: 22 Nov 2007, 01:46:09 »
 ;) Lol oops, After all that checking I still missed that little "[" . At least the shopkeeper's bank dialogs come up now (No items or cash in the bank  :confused:) . I don't see where I called "initMoney.sqf" twice though. Could you be a little more specific? Your gonna have to penetrate the granite layer in my skull if you know what I mean  :P.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: SPON Money (DO NOT SUBMIT)
« Reply #10 on: 22 Nov 2007, 02:08:53 »
From your init.sqf:
Code: [Select]
[["prices.sqf"]] call compile preprocessFileLineNumbers "SPON\Money\initMoney.sqf";

[
["prices.sqf"],
"$", // Dollars is teh currency
{ 100 }, // 100 bucks in ur wallet
0.33333 // You keep 1/3 of cash when u get pWn3d by the mafia.
] execVM "SPON\Money\initMoney.sqf";

"SPON\Money\initMoney.sqf" has therefore been run twice (With unpredictable results), though, as you say, only called once. The first time is using the example from the REAME, the second is using the example from the "init.sqf" in the demo mission. Both call and execVM run the script, but in slightly different ways, so I should have been more clear by saying you ran it twice, not that you called it twice.

If you look back at my demo init.sqf, you'll actually see that you missed out a parameter (you can't just miss out parameters in the middle of a list, though if my readme says there are defaults, you can use nil as a parameter to choose the default value for that parameter). You should use something like this if you actually don't want players to have a bank balance:
Code: [Select]
[
["prices.sqf"],
"$", // Dollars is teh currency
{ 100 }, // 100 bucks in ur wallet
        { 0 },  // No initial bank balance.
0.33333 // You keep 1/3 of cash when u get pWn3d by the mafia.
] execVM "SPON\Money\initMoney.sqf";

I'm not sure if you meant your comment in that way, but I never thought of actually storing items in the bank. Although not something usual in games like ArmA, this is very usual in MMORPG games. I'll certainly consider doing something like this one day, though not for the next version.

On a completely different note, I made SPON Money teamswitchable (each person has separate cash, but a common bank account) and also went most of the way towards making it compatible with SPON Attachments (you can buy and sell attachments and any other "abstract item" like bags of cocaine) today. I think I might need to fix a couple of things in SPON Attachments before this will work properly, so I'll probably re-release them at the same time. Still some more work and testing to do, but getting there.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline [ LoneWolf ]

  • Members
  • *
Re: SPON Money (DO NOT SUBMIT)
« Reply #11 on: 22 Nov 2007, 09:33:14 »
 :D It Works! It Works!
You did a good job of penetrating through that granite mate.  :good:
This will be great for those Rebel, Mercenary games. Any way to sell vehicles? Used car dealer wouldn't really fit the description If you can't.

 :good: Neat script anyway. Would be cool to buy/sell other objects. (Not necessarily bags of coke though  :whistle:) Kinda like in Sahrani Life. The makers of S.L should use this over their own shops because I like your layout much better.

 :cool2: I like were this script is headed

EDIT: Lol I just read your reply to Wolfrug, so I just solved my question,
« Last Edit: 22 Nov 2007, 09:39:13 by [ LoneWolf ] »

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: SPON Money (DO NOT SUBMIT)
« Reply #12 on: 22 Nov 2007, 12:21:47 »
I did offer the script to both Sahraniville and Sahrani Life, but they had already put a lot of effort into making their own shops by the time I properly released mine or, although mine has a lot of advanced features that neither of their missions have, mine lacked features they had implemented, such as being able to transfer money to other players (though I plan to add this to mine eventually). I also assume that they didn't want to totally rely on my finishing/bug-fixing my script ;P

Still, I'm very hopeful that SPON Money will get used eventually, since the other shops/banks I've seen are all integrated into specific missions rather than being separate scripts. On the other hand, by making such a generic script, it means that I have to do things like allow all sorts of user configuration, write extensive documentation and do more general testing, which is making progress a lot slower than it would be if I was just making a script within a specific mission.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Supergrunt

  • Members
  • *
Re: SPON Money (DO NOT SUBMIT)
« Reply #13 on: 29 Nov 2007, 23:33:31 »
alright i found out one thing these scripts are not to be used with XAM (1.3 atleast probably 1.4 will be compatible) or they will not function properly

are extended eventhandlers used in these scripts ?


Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: SPON Money (DO NOT SUBMIT)
« Reply #14 on: 30 Nov 2007, 00:11:35 »
None of my scripts require or use the extended event-handlers addon, since that addon is just required in order for multiple addons to use the same event handlers. My scripts use scripted event handlers extensively though, but there are no "sharing" problems with scripted event handlers in the same way as with configured event handlers (the kind in addons).

Can you give me some sort of idea what goes wrong with SPON Money when used with XAM 1.3 and how can you say that 1.4 will be compatible since it isn't released? The issue is whether I am at fault or if they are...
« Last Edit: 30 Nov 2007, 00:19:33 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)