Jump to content
Sign in to follow this  
Deg

adding money

Recommended Posts

Hi folks, i was wondering if there is a way to add money as soon as i interacted with an object , say like a crate or a wreck or maybe a body. Would i need to use an event handler ? I have looked through the forums and have been reading through the biki, but so far i have not seen anything that covers this. Thanks

Deg

Share this post


Link to post
Share on other sites

Why would a soldier need money in the field? I mean, I can see a Squad Leader being given some local currency to grease the wheels of necessity if they need something local or need to pay off a village elder for information, but they surely wouldn't store that in a wreck or a dead body!

Whatever game mode you're using should already have methods for adding and subtracting money, are you not able to use those?

Share this post


Link to post
Share on other sites
Why would a soldier need money in the field? I mean, I can see a Squad Leader being given some local currency to grease the wheels of necessity if they need something local or need to pay off a village elder for information, but they surely wouldn't store that in a wreck or a dead body!

Whatever game mode you're using should already have methods for adding and subtracting money, are you not able to use those?

Its my salvage and gather mission, actually im substituting money for salvage points, Im trying to have it so if you come across a wreck or crate or what ever you get x amount of money (salvage points) for it when you interact with it like when you open an ammo crate or a body for example, and also thats what im trying to figure out, those methods , how to add money(salvage points) to my funds in such circumstances, is it something to do with the warfare module? im really not sure all ive figured out so far is to add a set amount of funds and value for things for my COIN on mission start. Is there somewhere that explains methods for adding and subtracting money?.

Share this post


Link to post
Share on other sites

Yeah, the whole money thing is built into Warfare. The best place to start would probably be the Warfare Editing Guide, pretty sure that talks about how to set that stuff up. The link there is to V1 for ArmA, I'll poke around and try to find an updated version.

Might poke around on this guy's blog, seems he's trying to do similar things as you are.

Edited by kylania

Share this post


Link to post
Share on other sites

Thanks for the reply checking it all out now :)

Share this post


Link to post
Share on other sites

Cant seem to find anything that really relates to what i want so im still digging around, to bad there wasnt some kind of add funds command i could use on a trigger or something that would just add x amount of money(salvage points) to your funds right away when you interact with a crate or something lol, well back to digging :)

Share this post


Link to post
Share on other sites

There are two Warfare scripts which I believe do this:

Common_ChangeClientFunds.sqf

Common_ChangeClientPoints.sqf

I think ClientPoints is the one you are looking for.

The parameters are amount, side, and group (?)

Don't have an Arma2 machine right now so I can't verify. Going by faulty memory, sorry.

Try it and let me know if it works for you.

Share this post


Link to post
Share on other sites

Thanks ill look into those as soon as i get home :)

Share this post


Link to post
Share on other sites
There are two Warfare scripts which I believe do this:

Common_ChangeClientFunds.sqf

Common_ChangeClientPoints.sqf

I think ClientPoints is the one you are looking for.

The parameters are amount, side, and group (?)

Don't have an Arma2 machine right now so I can't verify. Going by faulty memory, sorry.

Try it and let me know if it works for you.

Sorry for the dumb question but where exactly do i find those scripts :o

Share this post


Link to post
Share on other sites

Thanks Kylania, i was reading something about pbo files a while back do i need to get those files from the warfare pbo to my mission file so i can see them ?

Share this post


Link to post
Share on other sites

Both scripts seem to be entirely commented out... but here they are:

Common_ChangeClientFunds.sqf:

scriptName format ["%1Scripts\Common\Functions\Common_ChangeClientFunds.sqf",BIS_WFdPath];

//Last modified 11/17/9

//*****************************************************************************************

//Description: Changes the player's funds by passed amount.

//*****************************************************************************************

Private["_amount","_ID","_side","_sideText"];

_amount = _this Select 0;

_side = _this Select 1;

_sideText = WFSideText _side;

_ID = _this Select 2;

//Debug:

if (IsNil "_amount") ExitWith {DebugLog "WF Error: ChangeClientFunds _amount undefined!"};

if (IsNil "_side") ExitWith {DebugLog "WF Error: ChangeClientFunds _side undefined!"};

if (IsNil "_ID") ExitWith {DebugLog "WF Error: ChangeClientFunds _ID undefined!"};

if (_side == Civilian) ExitWith {};

Call Compile Format["%1Player%2Funds = %1Player%2Funds + _amount;",_sideText,_ID];

Call Compile Format["if (%1Player%2Funds < 0) then {%1Player%2Funds = 0};",_sideText,_ID];

Call Compile Format["PublicVariable ""%1Player%2Funds"";",_sideText,_ID];

//*****************************************************************************************

//3/15/7 MM - Created file.

Common_ChangeClientPoints.sqf:

scriptName format ["%1Scripts\Common\Functions\Common_ChangeClientPoints.sqf",BIS_WFdPath];

//Last modified 2/27/10

//*****************************************************************************************

//Description: Changes the player's funds by passed amount.

//*****************************************************************************************

Private["_amount","_ID","_leader","_points","_score","_side","_sideText"];

_amount = _this Select 0;

_side = _this Select 1;

_ID = _this Select 2;

//Debug:

if (IsNil "_amount") ExitWith {DebugLog "WF Error: ChangeClientPoints _amount undefined!"};

if (IsNil "_side") ExitWith {DebugLog "WF Error: ChangeClientPoints _side undefined!"};

if (IsNil "_ID") ExitWith {DebugLog "WF Error: ChangeClientPoints _ID undefined!"};

_sideText = WFSideText _side;

if (_side == Civilian) ExitWith {};

_points = 0;

Call Compile Format["%1Player%2Points = %1Player%2Points + _amount;_points = %1Player%2Points;",_sideText,_ID];

if (abs _points >= 1.0) then

{

_leader = Leader ([_side,_ID] Call GetClientTeam);

_score = _points - (_points % 1);

_points = _points - _score;

Call Compile Format["%1Player%2Points = _points",_sideText,_ID];

if (IsServer) then

{

[0,0,_leader,Score _leader + _score] Call SRVFNCRequestChangeScore;

}

else

{

[CMDREQUESTCHANGESCORE,_leader,Score _leader + _score] Spawn BIS_WF_CommandToServer;

};

};

Call Compile Format["PublicVariable ""%1Player%2Points"";",_sideText,_ID];

//*****************************************************************************************

//3/15/7 MM - Created file.

Share this post


Link to post
Share on other sites

Thank you again, now im off to figure this all out lol :)

Share this post


Link to post
Share on other sites

You would have to be using the warfare module in your mission, and you should be able to call the script something like this:

[parameters] ExecVM "ca\Warfare2\warfare2\Scripts\Common\Functions\Common_ChangeClientPoints.sqf";

Share this post


Link to post
Share on other sites

If i put the warfare module in my mission can i disable it except for the construction and funds part, thats all i really need for my mission, like i said before my mission is about survival and gathering equipment from dead guys and what little funds(in my case salvage points) you can get to build a small base.Im still working on a mission end but id really like to get this all figured out, if it can even be done. Thanks again dbrant and Kylania for your replies. :)

Deg

Share this post


Link to post
Share on other sites

Sorry Deg, I saw "money", "resources" and "salvage" & my brain said Warfare module!

What you're probably looking for is the construction interface (CoIn), about which I know next to nothing.

Share this post


Link to post
Share on other sites

No worries dbrant, i do have my coin already set up thanks, starting with 0 funds and values ive set for basic base stuff like wire fences ect.. but what im trying to figure out is how i can add funds while im playing the mission, for example if i find a wreck on the side of the road if i can figure out a way to collect say 20 dollars/salvage points for it then after i collect from it the wreck will be deleted/removed from the mission. Im just wondering if this could be done or its over my head. :)

Share this post


Link to post
Share on other sites

Deg half the fun of Arma is figuring out how to do things, the rest is figuring out better ways to do the same thing.

Could you not just use setvariable to update to the new value?

from the wiki:

BIS_coin_0 setvariable ["BIS_COIN_funds","money_account"];

You may have to get the current value first before adding your $20 to it and then use setvariable.

Keep beating at it, you'll figure it out.

Share this post


Link to post
Share on other sites
Deg half the fun of Arma is figuring out how to do things, the rest is figuring out better ways to do the same thing.

Could you not just use setvariable to update to the new value?

from the wiki:

You may have to get the current value first before adding your $20 to it and then use setvariable.

Keep beating at it, you'll figure it out.

I do prefer to figuring things out myself, but when it comes to scripting im not the brightest apple on the tree.:o but im slowly learning, ive only had arma 2/OA for a few weeks now but im getting the hang of editing it. :)

Share this post


Link to post
Share on other sites

Here's a quick and dirty demo mission.

Init.sqf which sets up the COIN settings and adds the Salvage addAction to all units and vehicles on the EAST side (for this example):

// START OF COIN SETTINGS
myMoney = 1000;

myCoin setvariable ["BIS_COIN_name","Base"];
myCoin setvariable ["BIS_COIN_rules",[player]];
myCoin setvariable ["BIS_COIN_areasize",[50,50]]; 
myCoin setvariable ["BIS_COIN_categories",["Base", "Defence"]]; 
myCoin setvariable ["BIS_COIN_items",
[
	//--- Class, Category, Cost or [fundsID,Cost], (display name)
	["US_WarfareBBarracks_Base_EP1","Base",200,"Barracks"],
	["US_WarfareBFieldhHospital_EP1","Base",400],
	["US_WarfareBHeavyFactory_EP1","Base",600],
	["WarfareBMGNest_M240_US_EP1","Defence",100]
]
];
myCoin setvariable ["BIS_COIN_funds",["myMoney"]];
myCoin setvariable ["BIS_COIN_fundsDescription",["$"]];
myCoin setvariable ["BIS_COIN_onPurchase",{sleep 2}];
// END OF COIN SETTINGS

_done = []; // array of vehicles we've already added the action to
{
if (side _x == east) then {
	if ((vehicle _x != _x) && !(vehicle _x in _done)) then {
		(vehicle _x) addAction ["Salvage","addSalvage.sqf",[],1,false,true,"","!alive _target"]; // this is needed since a crewed vehicle isn't considered a "unit".
		_done = _done + [vehicle _x];
	};
	_x addEventHandler ["killed",{(vehicle (_this select 0)) addAction ["Salvage","addSalvage.sqf"];}];
};
sleep .01;	
} forEach allUnits;

addSalvage.sqf which includes the values for the types of wrecks/bodies:

private["_amount"];

_salvagedItem = _this select 0;

_tankValue = 200;
_carValue = 100;
_manValue = 15;

switch (true) do {
case (_salvagedItem isKindOf "Tank"): {_amount = _tankValue;};
case (_salvagedItem isKindOf "LandVehicle"): {_amount = _carValue;};
case (_salvagedItem isKindOf "Man"): {_amount = _manValue;};
default {_amount = 0};
};

deleteVehicle _salvagedItem;
myMoney = myMoney + _amount;
Call Compile Format["PublicVariable ""myMoney"";"];

_name = getText (configFile >> "cfgVehicles" >> typeOf _salvagedItem >> "displayName");
hint format["Earned: %1 for salvaging %2 - [%3]",_amount, _name, myMoney];

COIN settings borrowed from Jedo.

Share this post


Link to post
Share on other sites

Awsome, ill try this out as soon as i get back home later and ill let you know how it goes, thank you again Kylania. :)

Share this post


Link to post
Share on other sites

I just got home and tried your demo mission thats fantastic thats more than i hoped for thank you very much , so by the looks of it i should be able to add other stuff to salvage then :) My hat off to you kind sir. Thanks again.

Deg

Share this post


Link to post
Share on other sites

Just a few things about it. First, make sure you put more specific things "higher" on the case list than LandVehicle or Man. Like how Tank is listed above LandVehicle. Actually, you might as well just code the values there, like this:

switch (true) do {
case (_salvagedItem isKindOf "Tank"): {_amount = 200;};
case (_salvagedItem isKindOf "LandVehicle"): {_amount = 100;};
case (_salvagedItem isKindOf "Man"): {_amount = 15;};
default {_amount = 0};
};

instead of having all the extra values listed above.

Also the whole crewed vehicle thing is pissing me off. If you place a vehicle and just add the EH to the units, all the CREW gets it, but not the vehicle. That's why I switched things to being a Killed Eventhandler then vehicles get the !alive addAction added directly. That way if the crew bails the crew and the vehicle get the action.

However... if you kill the crew inside the vehicle the vehicle never gets the action because it's considered a "killed unit", or maybe it's just the SUV. I dunno, but if you shoot the driver out the car gets it's salvage option, but not the driver.

Also this isn't in anyway multiplayer ready. :) Well, it kind of is.. but would need a few extra lines.

Share this post


Link to post
Share on other sites

I shot the driver in the car and i could salvage both, and im not really worried about mp its more for me anyways :)

Edited by Deg

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×