Home   Help Search Login Register  

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

0 Members and 2 Guests are viewing this topic.

Offline Callaghan

  • Members
  • *
Re: SPON Money (DO NOT SUBMIT)
« Reply #30 on: 11 Mar 2008, 10:36:36 »
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.
« Last Edit: 11 Mar 2008, 10:45:36 by Callaghan »

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: SPON Money (DO NOT SUBMIT)
« Reply #31 on: 11 Mar 2008, 15:23:34 »
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:
Code: (add a killed handler for each unit you want a bounty paid on) [Select]
_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;
         };
    }
]

Code: (Add a SPON event handler to everyone who can collect bounties) [Select]
["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:
Code: [Select]
// 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.
« Last Edit: 11 Mar 2008, 18:52:57 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Callaghan

  • Members
  • *
Re: SPON Money (DO NOT SUBMIT)
« Reply #32 on: 13 Mar 2008, 11:55:06 »
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.

Code: [Select]
// 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?
« Last Edit: 13 Mar 2008, 12:31:08 by Callaghan »

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: SPON Money (DO NOT SUBMIT)
« Reply #33 on: 13 Mar 2008, 12:32:04 »
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
« Last Edit: 13 Mar 2008, 12:34:22 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Blacknite

  • Members
  • *
  • Chiefs runs the navy!
Re: SPON Money (DO NOT SUBMIT)
« Reply #34 on: 11 Dec 2008, 05:07:48 »
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?

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: SPON Money (DO NOT SUBMIT)
« Reply #35 on: 11 Dec 2008, 07:33:40 »
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.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Phil!

  • Members
  • *
Re: SPON Money v0.1.2 (ACCEPTED)
« Reply #36 on: 21 Jan 2009, 00:07:34 »
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


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?
« Last Edit: 21 Jan 2009, 20:21:47 by Phil! »

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: SPON Money v0.1.2 (ACCEPTED)
« Reply #37 on: 23 Jan 2009, 02:42:38 »
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...
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: SPON Money v0.1.2 (ACCEPTED)
« Reply #38 on: 23 Jan 2009, 03:08:29 »
createUnit? ... I'm sure you mean camCreate ... no?


Planck
I know a little about a lot, and a lot about a little.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: SPON Money v0.1.2 (ACCEPTED)
« Reply #39 on: 23 Jan 2009, 03:26:06 »
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.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: SPON Money v0.1.2 (ACCEPTED)
« Reply #40 on: 23 Jan 2009, 03:29:57 »
OK, ta, I misunderstood.   :cool2:


Planck
I know a little about a lot, and a lot about a little.

Offline Phil!

  • Members
  • *
Re: SPON Money v0.1.2 (ACCEPTED)
« Reply #41 on: 23 Jan 2009, 04:11:12 »
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.

Code: [Select]
// -----------------------------------------------------------------------------
// 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.
« Last Edit: 25 Jan 2009, 07:03:36 by Phil! »

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: SPON Money v0.1.2 (ACCEPTED)
« Reply #42 on: 25 Jan 2009, 17:56:44 »
I would suggest using this though:
Code: (untested, to save me some time) [Select]
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.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Phil!

  • Members
  • *
Re: SPON Money v0.1.2 (ACCEPTED)
« Reply #43 on: 25 Jan 2009, 20:15:48 »
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.

Code: [Select]
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.
« Last Edit: 28 Jan 2009, 15:47:48 by Phil! »

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: SPON Money v0.1.2 (ACCEPTED)
« Reply #44 on: 29 Jan 2009, 22:58:28 »
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!
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)