OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Resources Beta Testing & Submission => Topic started by: Spooner on 04 Nov 2007, 23:39:51
-
SPON Money v0.1.2
- Released: 2007-11-06
- Install size: 59k + SPON Core (http://www.ofpec.com/forum/index.php?topic=30274.0) (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 (http://www.ofpec.com/forum/index.php?topic=30274.0) 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 (http://www.ofpec.com/ed_depot/index.php?action=details&id=581)
-
Small update to 0.1.2 (just a couple of bugfixes and improvements to the demo, mainly at the suggestion of LeeHunt). Nothing major.
-
Found this post at Armaholic:
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
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:
[_shop] call SPON_setShop;
For the shopkeeper, and this:
[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:
[this] execVM "SPON\Money\setShop.sqf";
or
[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
_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:
[this] execVM "SPON\Bank\setBank.sqf";
or
[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:
[
[ // 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.
-
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.
-
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.
-
: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:
-
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).
-
: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.
-
You forgot a [ in the init.sqf:
_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 (http://www.ofpec.com/forum/index.php?topic=30471.0). 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)!
-
;) 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.
-
From your init.sqf:
[["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:
[
["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.
-
: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,
-
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.
-
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 ?
-
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...
-
@Spooner
Not exactly, but if you look at our two missions here O-Team (http://www.ofpec.com/forum/index.php?topic=30421.0) and Piper Warrior Tour Guide (http://www.ofpec.com/forum/index.php?topic=30430.0) you'll find they won't work with Solus' default Extended Init Eventhandler (only the latest version, which adds some bollocks to the end which screws with our missions). LCD figured it out and fixed it, but...you can never say that an addon like that won't bug your mission; or in consequence your scripts. :)
Wolfrug out.
-
@Wolfrug:
As far as I can tell, Supergrunt was implying that my scripts didn't work with XAM-1.3 because XAM-1.3 doesn't use extended event handlers (XAM 1.3 is known to be incompatible with any addon that utilises Solus' extended event handlers, but they are making it compatible for XAM-1.4), but since my work is not an addon, so uses scripted, rather than configured, event handlers, this particular issue cannot be affecting my scripts.
The idea that my scripts are incompatible with XAM and/or the extended event handlers for a different reason, however, is quite a different issue! Hopefully, Supergrunt can give me some more details of what he was meaning, since he was being a little cryptic (e.g. does my script make XAM not work properly or does XAM make my script not work properly? Are there particular circumstances when there is a failure or does it just happen when you load a mission? Is there an error message and if so, any idea what it says? Or does it just not work or CTD?). I appreciate the fact that Supergrunt has brought this issue to my attention, but I can't replicate the problem so that I can fix it, without having a bit more information.
EDIT: Had a look around in the extended event handlers (v1.1), but couldn't see anything that would interfere with other scripts. Any idea what exactly was going wrong with your missions, or was it in fact a problem with the addons required by your missions that didn't use the extented event handlers addon so were incompatible?
-
Hey spooner, heh been a few years since iv posted at OFPEC, i must say this is an excellent set of scripts you have here, im currently using them for a MP zombie RPG like mission im making but i have a few questions:
Firstly i read earlier that:
On a completely different note, I made SPON Money teamswitchable (each person has separate cash, but a common bank account)
By this do you mean that a players bank account is not specific to the player but can be access by others to? as for example theres 0 in the bank, but player 1 deposits 100 player 2 can withdraw that 100? or did i just misunderstand this? If this is the case how can i have bank accounts separate for each player?
Also how can i pay specific players money? For example once an objective is complete or an AI is killed a specific player receives money? In my case I want players to receive money every time they kill a Zombie.
-
Glad to see that people are actually using the scripts! We also do need a lot more zombie missions in the game too; preferably about 200 more!!!
I meant that in SP when you teamswitch then you will still have access to the same bank account, but that each individual character has their own cash value. In the currently released version, both cash and bank balance are for all characters, which is a bit silly (I had originally ignored the idea of teamswitching, just because I don't like it personally ;P ). In any sort of COOP/MP, then cash and bank balances are always entirely separate for each player.
With the current SPON Money v0.1.2, you can just add or remove money directly from the two global variables, SPON_playerBankBalance and SPON_playerCashBalance on the machine that is local to the player in question. If I remember rightly, if these values are affected while the shop dialog is open then the values shown in the dialog don't update until something is bought or sold. Just something to bear in mind if you are testing changing players money values. In the current WIP version, I've added functions to do this so that you can affect these values on any person from any machine. I'd like to get the new version out before Christmas, but I can't promise anything since I'm very busy on other projects right now and it also relies on some major changes I'm planning to make to SPON Core...
-
Thanks very much for the reply, much appreciated!
-
Ok i have another, hopefully simple question!
I have Zombie units spawn with a even handler attached:
_x addEventHandler ["killed","SPON_playerCashBalance = SPON_playerCashBalance +50"]
Now this works all fine and dandy in SP however i am not sure how it will behave in MP. Being my scripting is pretty rusty these days at best I'm a little bit confused when it comes to MP scripting and whole Local and global thing. Of course I only want the player that killed said zombie to be rewarded with £50 but im guessing that when the zombie is killed, the killed event handler will activate globally and give all players 50, since i guess every machine would detect the death of the said zombie?
Could something along the lines of this work?:
_x addEventHandler ["killed",{_this exec "checklocal.sqs}"]
Checklocal.sqs:
_this select 0 = _killer
?!_killer=local:exit
SPON_playerCashBalance = SPON_playerCashBalance +50I haven't actually tried the line above and no doubt iv cocked it up.
EDIT!:
I just read on the BIS wiki that:
MP notes: "Killed" and "Hit" eventhandlers are executed where given unit is local.
All other eventhandlers are executed on all computers.
So im guessing i don't need to change anything at all and that the player that killed the zombie, will be the only one that is rewarded? in less iv misunderstood this.
-
Er, no, since the zombies will be local on the server and that will be where the killed handler runs, not on the player's machine. Fortunately, since you are using SPON Core (required by SPON Money), you can communicate this info relatively easily (even simpler in the next version of SPON Money...but you have to wait for that!):
_zombie addEventHandler ["killed",
{
zombieKiller = _this select 1;
publicVariable "zombieKiller";
["zombieKilledEvent", []] call SPON_publishGlobalEvent;
}
]
["zombieKilledEvent",
{
if (player == zombieKiller) then
{
SPON_playerCashBalance = SPON_playerCashBalance + 50;
};
}
] call SPON_addEventHandler;
Also remember that if you run a zombie over, then you, the player, aren't considered the "killer" (and neither is the vehicle, I think). Whether you need to worry about that rather depends if you have vehicles in your mission.
Incidentally, you would use local like:
?!local _killer:exit
-
Thanks for the reply! It seems to work like a charm!
But alas! things never seem to go smoothly. I am now having problems with one of my shops. Or more precisely my vehicle shop.
I have this in my init.sqf:
[
["Prices.sqf"],
"£",
{ 1000 }, // Always $50 in pocket.
{ 10000 }, // Americans have more money in the bank.
0.33333 // You keep 1/3 of cash when you respawn.
] execVM "SPON\Money\initMoney.sqf";
//---------------------Guns
_stock1 =
[
// Weapons.
["RPG7V", "G36K","G36A","G36C", "Makarov", "PK", "SVD", "AKS74U", "AK74", "MP5A5", "M16A2", "M16A4", "M16A4_ACG", "M4SPR", "M4", "M4A1", "M24", "M240", "M249", "M9","PipeBomb", "SmokeShell", "Flare","Binocular", "NVGoggles"],
["PG7V","PG7VR", "30Rnd_556x45_G36", "10Rnd_762x54_SVD", "100Rnd_762x54_PK" ,"8Rnd_9x18_Makarov" ,"30Rnd_545x39_AK" ,"30Rnd_556x45_Stanag" ,"20Rnd_556x45_Stanag" ,"5Rnd_762x51_M24" ,"100Rnd_762x51_M240" ,"200Rnd_556x45_M249" ,"15Rnd_9x19_M9" ,"30Rnd_9x19_MP5"]
];
[Gunstore, 0.5, 1.0, _stock1] execVM "SPON\Money\setShop.sqf";
//-------------------vehicles
_stock2 =
[
["UH60MG", "MH6","HMMWV50", "HMMWV","Skoda","Skodablue","skodaRed","Skodagreen","datsun1_civil_1_open","datsun1_civil_2_covered","datsun1_civil_3_open","car_hatchback","car_sedan","LandroverMG","UralCivil2","UralRepair","UralRefuel","UAZMG","BRDM2","M1030","TT650G","TT650C","Truck5tMG"]
];
[equipmentstore, 0.5, 1.0, _stock2] execVM "SPON\Money\setShop.sqf";
//--------------------bank
[banker1] execVM "SPON\Money\setBank.sqf";And when i try to access the 'Equipmentstore' and error is thrown up somthing along the lines of 'Error Zero devisor' and shopdiologui.sqf line 436.
Im sure its most likely some mistyping on my part or something iv missed out. Iv checked my price SQF over and every thing seems to be in order there so im guessing its my init.sqf
-
Well, one thing is that all the "execVM" used for my scripts in the init.sqf should be "call compile preprocessFileLineNumbers" (this was discussed earlier in the thread; blame my shoddy documentation). execVM might work fine, but best to be safe.
The thing is that the first array in the stock is for weapons, the second for ammo and the third is vehicle. Thus you need some empty arrays for your vehicle array, so the shop knows that it is selling vehicles:
_stock2 =
[
[], // No weapons
[], // No ammo
["UH60MG", "MH6", etc., etc., etc.]
];
(the reason I have 3 lists of different item types, rather than one big list, is that some weapons and magazines have exactly the same name, so it needs to be specified which is which. Although no weapons/magazines share class names with vehicles, it is a lot simpler and clearer to keep them separated as well).
-
Ah that makes perfect sense now, thanks again Spooner, very much appreciated! Now that thous main things cleared up for me i should hopefully be able to complete a beta of this Zombie MP RPG soon!
-
Hey again Spooner, I just have a quick question!
Is it possible to Clearmagazinecargo and clearweaponcargo vehicles that are brought? its just that the civilian Urals are loaded up with ammo and things when they are spawned, which could be abused by players buying Urals and selling all the flares, grenades and rockets out of it to make some quick profit.
Also i tried contacting you on MSN about the fix you mentioned to me for the Language issues when players use SPON_money in other game languages. I wasnt at my pc at the time you mentioned it so i thought id ask again! plus might come as benefit to all if you put the quick fix here in the forums.
Cheers!
-
To perform commands on a newly created vehicle, edit SPON\Core\showShopDialog.sqf and change:
case TYPE_VEHICLE:
{
_itemClass createVehicle (getPos player);
};
to:
case TYPE_VEHICLE:
{
_veh = _itemClass createVehicle (getPos player);
clearWeaponCargo _veh;
clearMagazineCargo _veh;
};
I'll add a better way of doing this so you can automatically perform commands when a vehicle is created in the much promised new version of SPON Money...*coughs*
(I've told D.murphy man a possible way to fix the non-English language things, but I haven't been able to test that. Hopefully that issue will be resolved now).
-
Couple of questions -
1st do you have or know a way of converting a units value in points into money and rewarding the killing player with that money?
i.e. in a PvP game if someone destroys an enemy tank they will recieve the tanks value in points as well as the crews in money?
2nd do shopkeepers buy items they dont sell? Or do they only buy wht they sell?
Is what they buy added to their stock or does it dissappear?
-
1. It is possible and it is done successfully to give a zombie-killing bounty in the Quarantine mission. Look a few posts up in this thread to where I explained how to implement this (http://www.ofpec.com/forum/index.php?topic=30551.msg210636#msg210636). There isn't a way to "convert a unit's value in points into cash" as such, since this game doesn't assign points values to units. Well, I suppose there are the points in the scoreboard (infantry = 1, vehicle = 2, tank = 3), but I don't think you can find out those numbers. There is no reason that you couldn't give a different bounty based on what vehicle has been destroyed by using different killed handlers on each vehicle type.
2. Shopkeepers always have unlimited numbers of everything that they sell. They buy all items that have been put in the main prices.sqf, regardless of what they sell (They will only buy weapons and grenades, however, never magazines and vehicles). There are so many issues involved in having stock-levels in shops that I can't see it is worthwhile having a system to manage that (not least of which is synchonising stock levels in MP, which although possible is a lot of effort for the limited usefulness). You'd need to develop a complex economy based on numbers of players online and sales rates to stop shops from running out of goods or the shops always being full. Overall, I really don't think it is worth the effort to develop this kind of system, especially since the parameters would be horrendously mission-specific.
-
1) The rating (http://www.ofpec.com/COMREF/index.php?action=list&game=All&letter=r#261) command sort of does that : it gives more points for units with higher rank/more dangerous and such. For instance a tank will be worth upwards a thousand points, whereas a simple infantryman is considerably less. You could probably work with that to some extent :) Suggest you first research the command and the returns given properly though! (also note that you start with different amounts of rating depending on your rank).
Wolfrug out.
-
I agree I don't think shop stock monitoring is important. I was just wondering as, If it was too much effort to get kill bounty points scripted then I could just price Blufor weapons higher so that Opfor can collect and sell them for a profit when they kill a blufor guy. I will look into the points system.
Basically, i'm working on a map for GOL clan.
It will be called insurgency and is on the Sakakah al Jawf map.
The basic idea is this - USMC spawns at airbase and has various vehicles that are unlocked when objectives are completed.
USMC spawns with pre-selected equipment, they cannot buy or sell anything. They can however take out the various arms sources in the city if they like to stop insurgents from getting better equipment.
There are 4 zones in the city that must be captured. For every zone captured by USMC, the next level in the 'tech tree' is unlocked for them.
Insurgents will start off with a basic AK47 and an IED. They can only get more equipment by scavenging or killing for money, they will have access to an enourmous selection of Russian equipment thanks to the new GOL addon pack.
The hard part will be assigning US vehicles with points and pricing all the weapons.
Well, ok the hard part for me is making the bounty reward scripts, any help/advice you can give me that may help is appreciated.
I will be using a few of your other scripts including VBIED.
Dacs 2.0 will be used to create a dynamic civillian presence in the city.
I will let you know when it is finished. It will end up being like a cross between Sahraniville and Evo, with multiple objectives to unlock equipment but the only objectives that win the mission are the capture of the 4 zones.
pls link to any scripts or anything at all that i may need as I am not experienced with missions of this complexity.
also, simple question, you mention scripts that need to run on the server.. as an editor how do i tell the script that it only runs on the server.
-
That is interesting, I'm developing an MP mission loosely based on BF2 Project Reality Insurgency mode that sounds a lot like that too (the Insurgents can take weapons from the caches that the US are trying to destroy)! Fortunately, I'm moving in a quite different direction (not going to use shops, for example), so I don't think we will end up with anything at all similar ;P The more the merrier!
This should get you started:
_unit addEventHandler ["killed",
{
_victim = _this select 0;
_killer = _this select 1;
// Don't give bounty to player killers or after someone dies without a specific killer (e.g. fallen or run over)
if ((not (isNull _killer)) and ((side _killer) != (side _victim))) then
{
giveBountyTo = _killer;
publicVariable "giveBountyTo";
_bounty = rating _victim;
["payBountyEvent", [_bounty]] call SPON_publishGlobalEvent;
};
}
]
["payBountyEvent",
{
_bounty = _this select 0;
if (player == giveBountyTo) then
{
SPON_playerBankBalance = SPON_playerBankBalance + _bounty;
};
}
] call SPON_addEventHandler;
also, simple question, you mention scripts that need to run on the server.. as an editor how do i tell the script that it only runs on the server.
I'm sorry, but if you don't know this yet, you haven't scripted for any MP missions yet and perhaps don't have much SP editing experience either (you might be an expert in SP, but just never noticed this command, but that is less likely). I'd seriously advise you, and most of the other people who've suggested similar projects to me for that matter, not to start by trying to make a competetor to the most complex MP missions, such as Evo, Sahraniville or Sahrani Life. Starting with MP PVP is also even more complex than MP COOP! The phrase "walk before you can run" comes to mind...
OK, that is maybe harsh, but whether you want to continue on the super-complex mission path or start on a more sensible scale, the answer is:
// Do stuff on all machines up to this point.
if (not isServer) exitWith {}
// Do stuff only on the server after this point.
EDIT: Changed script to using the rating command (I'd previously incorrectly used the rank command)
EDIT: Oops; based the code on some I copy and pasted. Have changed to putting the the money into the bank account, not player's cash.
-
this is the thing, I have made literally hundreds of MP Coops, but have never ventured into PvP beyond having an east and a west respawn.
I'd like to get into it, and reckon I could learn it very quickly, but I have to make the jump at some point regardless of the difficulties..
I don't write scripts, as you have noticed. My skills lie in the design and actual making of the missions, I don't plan on making something the same level of complexity as evo, but it will be the same scale in terms of objectives etc. What I need from the community for this project to go ahead, are the scripts and snippets required to incorporate your work into this mission. Assume I dont understand scripting, only how to use and modify it to some extent.
// Do stuff on all machines up to this point.
if (not isServer) exitWith {}
// Do stuff only on the server after this point.
so basically any MP script will run on the server automatically and this code is just to tell it not to run on clients?
-
I realise, as I said, that I was being harsh, but you are far from the first person to suggest an "expert" MP mission and yet not understand "basic" MP commands. As usual, though, I complain about the Nth person to make such a suggestion, who is not necessarily as noobish as the ones that originally set my teeth on edge ;P Sorry!
Any script that is started from "init.sqf" or by something put in the mission editor (e.g. init line for an object or a trigger activation), will run separately on every machine, including the server. Since we don't always want that script being run on every machine, we often need to limit on which machines these scripts are being run. Sometimes you need to limit it to the server (e.g. when the script only wants to be run once on the network), other times just to the clients (e.g. when we want purely client-side effects, such as a series of titleTexts) or just a specific client (e.g. so that the above bounty payment only occurs on the correct player's machine).
If you start a new script from within an existing script, the new script will only run on machines that are running the original script. Thus, if you ran another script after the "if (not isServer) exitWith {}", it too would only run on the server. This might be obvious, but I thought it worth clarifying.
This thread probably isn't the place to discuss general MP wisdom though, since it is specific to SPON Money ;P
-
Now here is a question:
How do you gain money besides selling weapons?
How would you identify items to be sold that is not a basic BIS model such as vodka?
How would you add sound effects after a transaction such as the storekeeper saying "It has been a pleasure doing business with you."?
Where do you determine the exact prices to be sold and bought?
-
There is no way scripted into SPON Money to gain or lose money apart from buying or selling items (or visiting the bank, which just converts cash into bank balance, of course). You can set how much players start with in the parameters you send when starting the script. You can directly modify the values of SPON_playerBankBalance and SPON_playerCashBalance, from your own scripts if you need to add other systems of gaining and losing money (need to be changed local to the player, of course).
Vodka is implemented in addon packs as a magazine, so set it up in SPON Money in the same way as you would a regular magazine (bullets or grenades).
The problem with adding a long sound after a transaction is that it would play too many times if you, for example, bought 5 magazines at once. I do have a "kerching" sound added in my long-shelved WIP version of this script, which doesn't cause problems if you do it multiple times (compared to long chat).
The prices.sqf determines the global prices of all items in the game (anything not on the list can't be bought or sold). Each shopkeeper has an individual list of what they sell, as well as a configurable percentage markup for selling and reduced price for buying things from the player.
It is usual to add a little action or radio trigger to give you a hint showing SPON_playerBankBalance and SPON_playerCashBalance. Otherwise you can't tell how much you have except at a bank or shop.
-
First off Thank you tonnes Spooner for this excellent script. I am new to script use in missions and without this script being made my latest mission I am making would not be possable.
The mission I am making is for the FDF mod called "Podaga Drug War". I am using some custom weapons, ARMA ROLEPLAY OBJECTS, RH's AK pack and Schapdrossels mercs. I am hoping to make MP and SP versions.
In the mission there are 3 sides against each other. The "west" side is unplayable and is a Narco government supported by the CIA. They run most of the island. The Ind and East sides are playable but opposed to each other with up to 12 players on each side. The players start out with nothing but $1000 on them and $1000 in the bank (local currency). To start the players can scrounge for items (roleplay objects and free weapons and mags) and buy drugs for cheap from a "pot grower" and sell for a higher price to other merchant types. Eventually you gain enough money to buy weapons and vehicles and can start warring with the opponant sides. Certain areas in the government controlled zone contain high priced goodies.
I did run into a hic-up however. One of the things I would like to do is implement a recruitment option. So the player can hire a medic, gunman or whatever to control. I tried adding a unit class in the vehicle section of the script. It will spawn the unit, but the unit will not do anything it just stands like it is holding a rifle and blinks.
I realise that a "join group" script would have to be integrated as well but is there a way to have units purchaseable and functional like a vehicle purchase is with the script?
Here is the link to that objects pack, you can set the price and merchant avail as a "magazine object" in the script:
http://www.armaholic.com/page.php?id=2880 (http://www.armaholic.com/page.php?id=2880)
Jan 21:
I have found a script that allows recruiting of units by Odin. The interface is different that using shop keepers and bankers, but it avoids problems with units spawning in areas that they cannot get out of etc. The units themselves parachute near you and automatically join group. It is also a nice script because you can cancel the units from your group without destroying them so they could stay in a location as guards.
My question is this. Is there a way to have a script check to see if the player can recruit the unit if it meets a condition (in this case having enough money) to recruit the unit using the Spon Money system. Is there a way to assign a cost in $ to the units that get recruited?
-
The reason it doesn't work at the moment is that it only allows you to buy non-ai vehicles (createVehicle) and not ai soldiers (createUnit). That is why your created man just stands there like an idiot; he has no more intellegence than a Humvee :P Not a massive amount of extra work to implement, but not something that is a priority at the moment.
I know that people have modified SPON Money in order to allow the purchase of units. I had thought that the Quarantine mission by DMuphy had made this very alteration, but don't hold me to that.
Really, SPON Money needs a lot of work doing to it, including this additional feature, to live up to its potential, although it works well enough as it is (that is, it does what it says it will do; it just doesn't do all the things people might want it to do!). The main problem is that although I made this, I don't find RPG missions that interesting, so I am concentrating on work that makes my own gameplay more enjoyable :whistle: I might pick this up again, but I'm so busy with soooooooo many other scripts that I'm not so sure when I will get back to this one...
-
createUnit? ... I'm sure you mean camCreate ... no?
Planck
-
No, he is putting man classes into SPON Money, where it was only designed to allow you to buy regular vehicles. My code thus uses createVehicle on the man, creating an AI-less man that stands there like a statue. AI need to be created with createUnit (and a few other things need to be done, like checking that the player is a group leader, joining the new man into your existing group, etc). Although this isn't a massively complex addition, it would rely on me adding a whole new type of object that can be bought with SPON Money, which is non-trivial.
-
OK, ta, I misunderstood. :cool2:
Planck
-
Really, SPON Money needs a lot of work doing to it, including this additional feature, to live up to its potential, although it works well enough as it is (that is, it does what it says it will do; it just doesn't do all the things people might want it to do!). The main problem is that although I made this, I don't find RPG missions that interesting, so I am concentrating on work that makes my own gameplay more enjoyable :whistle: I might pick this up again, but I'm so busy with soooooooo many other scripts that I'm not so sure when I will get back to this one...
No worries I'm new to scripting and I think this is the best way for me to learn it. I'm going to try my hand at merging your code with the create AI script I downloaded. I might post here now and again asking for info or I will post my results so ohers can enjoy.
One other thing I want to add if anyone is interested. You can add a weapon crate to the vehicle section of the price list and to the _stock section of the merchants that you want to be able to sell the item. You will get one small bug. most weapon crate classes do not have an associated .paa file so you will get an error message of no image file when you browse shop.
Jan 24:
I looked over D Murphy's scripts for his Quarantine mission/mod. He did work recruitment into the origional script, however he put his code into the origional SPON core and money scripts.
If you were interested Spooner on updating Spon money you could look at murphys code and compare it, maybe clean it up a bit or whatever. He didn't separate his code from yours in separate files. This might lead to future bugs if others decide to use his scripts and another person is using a different version.
// -----------------------------------------------------------------------------
// Function: SPON_buySelectedItem
//
// Parameters:
// None.
//
// Returns:
// None.
//
SPON_buySelectedItem =
{
_index = lbCurSel SPON_SHOP_SHOP_INVENTORY_IDC;
if (_index < 0) exitWith {}; // Ignore button presses when no item is selected.
_data = call compile (lbData [SPON_SHOP_SHOP_INVENTORY_IDC, _index]);
private ["_itemType", "_itemClass", "_config", "_cost", "_canBuy"];
_itemType = _data select 0;
_itemClass = _data select 1;
_config = _data select 2;
_cost = _data select 3;
_canBuy = _data select 4;
if (_canBuy) then
{
switch (_itemType) do
{
case TYPE_VEHICLE:
{
// Murphy code
// East side
if ((_itemclass iskindof "FDF_Mercenary_Teamleader_East")AND(count units group player <4))then{_itemclass createunit [position player, group player, "",0.5,"PRIVATE"]};
if (_itemclass iskindof "FDF_Mercenary_Medic_East")then{_itemclass createunit [position player, group player, "",0.5,"PRIVATE"]};
if (_itemclass iskindof "FDF_Mercenary_Gunner_East")then{_itemclass createunit [position player, group player, "",0.5,"PRIVATE"]};
if (_itemclass iskindof "FDF_Mercenary_Mines_East")then{_itemclass createunit [position player, group player, "",0.5,"PRIVATE"]};
if (_itemclass iskindof "FDF_Mercenary_RPG_East")then{_itemclass createunit [position player, group player, "",0.5,"PRIVATE"]};
if (_itemclass iskindof "FDF_Mercenary_M_East")then{_itemclass createunit [position player, group player, "",0.5,"PRIVATE"]};
if (_itemclass iskindof "FDF_Mercenary_BaseU_East")then{_itemclass createunit [position player, group player, "",0.5,"PRIVATE"]};
// Guer side
if ((_itemclass iskindof "FDF_Armed_Civilian2")AND(count units group player <4))then{_itemclass createunit [position player, group player, "",0.5,"PRIVATE"]};
if (_itemclass iskindof "FDF_Armed_Civilian5")then{_itemclass createunit [position player, group player, "",0.5,"PRIVATE"]};
if (_itemclass iskindof "FDF_Armed_Civilian6")then{_itemclass createunit [position player, group player, "",0.5,"PRIVATE"]};
if (_itemclass iskindof "FDF_Female_ACivilian")then{_itemclass createunit [position player, group player, "",0.5,"PRIVATE"]};
if (_itemclass iskindof "FDF_Armed_Civilian4")then{_itemclass createunit [position player, group player, "",0.5,"PRIVATE"]};
if (_itemclass iskindof "FDF_Armed_Civilian3")then{_itemclass createunit [position player, group player, "",0.5,"PRIVATE"]};
if (_itemclass iskindof "FDF_Armed_Civilian7")then{_itemclass createunit [position player, group player, "",0.5,"PRIVATE"]};
// WTF?
If (not(_itemclass iskindof "man")) then {_veh = _itemClass createVehicle (getPos player);_veh reveal player;clearWeaponCargo _veh;clearmagazinecargo _veh;player reveal _veh;};
// End Murphy code
};
case TYPE_WEAPON:
{
// Find out what base class the weapon is.
_weaponType = [_itemClass] call SPON_getWeaponType;
player addWeapon _itemClass;
};
case TYPE_MAGAZINE:
{
_isLarge = _config select 2;
_slots = _config select 3;
if (_isLarge) then
{
SPON_largeSlotsUsed = SPON_largeSlotsUsed + _slots;
player addMagazine _itemClass;
ctrlSetText [SPON_SHOP_LARGE_MAGAZINES_IDC, (format ["%1 / %2", SPON_largeSlotsUsed, SPON_maxLargeSlots])];
}
else
{
SPON_smallSlotsUsed = SPON_smallSlotsUsed + _slots;
player addMagazine _itemClass;
ctrlSetText [SPON_SHOP_SMALL_MAGAZINES_IDC, (format ["%1 / %2", SPON_smallSlotsUsed, SPON_maxSmallSlots])];
};
};
};
SPON_playerCashBalance = SPON_playerCashBalance - _cost;
call SPON_updateShop;
};
nil; // Return.
};
I found the particular section of code that makes it all work from Murphy Man's modifications to the file showShopDialog.sqf I added the comments //Murphy code and // End Murphy code to indicate his modification.
Individual class names must be done for every purchaseable AI unit in the mission. I have added in class types that I am using for my mini mod.
I hope this helps anyone who wants to do the same.
-
I would suggest using this though:
case TYPE_VEHICLE:
{
private "_veh";
if (_itemClass isKindOf "Man") then
{
_veh = _itemclass createUnit [position player, group player, "",0.5,"PRIVATE"];
}
else
{
_veh = _itemClass createVehicle (getPos player);
clearWeaponCargo _veh;
clearMagazineCargo _veh;
};
player reveal _veh;
};
1) You don't need to specify man classes. No reason to need to do this.
2) You shouldn't prevent the creation of leader classes at this point (by preventing their creation if the squad is already too large). If you do this, then the player will pay the money, but not receive the new man. The correct place to put this check is when you are populating the menu, not after you have decided to buy one.
-
I'll give that a whirl as well. I'm happy with Murphys code but it would get cumbersome to have to enter all those classes. I'll test it out and report back on what happens thanx Spooner.
case TYPE_VEHICLE:
{
private "_veh";
if ((_itemClass isKindOf "Man")AND(count units group player <4)) then
{
_veh = _itemclass createUnit [position player, group player, "",0.5,"PRIVATE"];
}
else
{
_veh = _itemClass createVehicle (getPos player);
clearWeaponCargo _veh;
clearMagazineCargo _veh;
};
player reveal _veh;
};
Tried your code Spooner and it works brilliant. I added a group size limit code to yours only because I need it in my mission. If you come out with a new version in the future I would recomend adding this little bit of code. The only other thing that needs to be added is the classes for the units on the pricelist.
-
If you have too many people in your squad when you buy someone, you will pay the money and instead get a statue :blink: This is why I said you need to implement that limit somewhere else!
-
In my testing you can continue to buy units and they will not be a part of the group but they aren't statues, they will react when shot at and stuff so it's not the biggest problem.
I would like to add though that if you add a weapon crate in the vehicles listing it will not have any inventory in multiplayer games but works fine in single player.
-
The reason you don't get contents for ammo boxes is because I clear out all the contents of vehicles (an ammo box is just a vehicle you can't get into!), so you don't get massive amounts of free ammo with certain vehicles. You could always not clear the cargos of ammo boxes to overcome this:
// Only clear out vehicles, not ammo boxes.
_veh = _itemClass createVehicle (getPos player);
if (not (_veh isKindOf "ReammoBox")) then
{
clearWeaponCargo _veh;
clearMagazineCargo _veh;
};
I can't understand why ammo boxes would have contents in SP mode normally though :whistle:
-
Prob just one of Arma's amny gremlins :P
-
Ok, so I love the SPON money script, but with the release of the RKSL cargo script I want to encorporate the two.
On vehicles and items etc that RKSL havn't already scripted, such as addons by other players, you need to add a line to the init field of the item.
What I am curious to know, is how you add something to the init field of an item created via SPON money.
So if your shop sells a truck, how do i add something to the trucks init field?
Thanks
-
This sort of thing has been discussed already in this thread. Have a poke around and ask again if you still have problems...
-
Never mind, i worked it out haha.
I was going to ask how to include recruitable AI units into the shop but it seems this has already been covered. What I was hoping to add was buyable objects such as the blue and white container, as, since I have already mentioned elsewhere I am using RKSl cargo. The blue and white containers would be a nice way to be able to store vehicles, tents, etc so as not to clutter a players base or area until the items were used. It would also be a handy way to transport objects etc.
My problem is, i included it in the price list and shop but it didn't appear to work.
[
[//weapons
[weapon names and price ]
],
[//ammo
[ammo names and prices]
],
[//vehicles
[vehicle name and price]
]
]
Obviously it isn't weapons, ammo or vehicles, so which section would I include it under, or where abouts would I include other static objects, so obviously the string goes along the lines of [weapon, ammo, vehicles].. so is there a fourth bit to it? [weapons, ammo, vehicles, objects] maybe?
thanks
-
Statics should count as vehicles in this case, since vehicles or objects would just be created with createVehicle in exactly the same way. Might be some reason that it fails though, since my scripts might not recognise a static as a vehicle since it is one of AllVehicles and might not show it because of that. Really I can't remember though...