Jump to content
Sign in to follow this  
mr_shadow

Set variable in item

Recommended Posts

Hello guys, is there any way to make my "set variable" an item? For example I have variable money, and want to make it as an item, like in wasteland where u can drop it an so on, appreciate your help.

Cus I don't have any ideas. How to make money droppable or give other players.

Edited by mr_shadow

Share this post


Link to post
Share on other sites

Not as directly as you'd like. You could add actions to allow a player to spawn a Pile of Money object and assign X value to that object once it's spawned and "deduct" that amount from the players variable amount. There's no Pile of Money inventory item though (not by default at least) and you couldn't set a variable to that anyway since it's not an object. You'd have to fake/workaround it instead.

Share this post


Link to post
Share on other sites

Things can be a little complicated as far as dropping of items go.

I have a somewhat of a system working on a mission I have been creating.

You need to have it not only create (and potentially set the objects name), but also tie a variable to that object. If your mission is MP then you need to remember to sync this in MP.

If you like, you can PM me and I can give you access to my mission/code so you can look at how to do it. However, I wouldn't say that my way is very efficient, though would definitely work for singular objects dropped.

Share this post


Link to post
Share on other sites

I understand your answers, and I know that there are no default money, can u show me an example how to "tie" it to object?

Edited by mr_shadow

Share this post


Link to post
Share on other sites

Ok, here you go.

I have written you all the code you will need to do this.

As one last note though, this by no means is the best or most efficient way of doing this, but it works.

The money can be dropped via whatever means you like (addAction, GUI ect), but it must contain a line like this:

["drop", 1000, "X", "X"] execVM "drop.sqf";

Don't edit "Drop" or remove the "X" 's.

1000 however is the amount of money that you will drop, this could be changed to a variable if you are dropping differing amounts, or left as a number.

drop.sqf

_target = _this select 0;
_value = _this select 1;
_name = _this select 2;
_item = _this select 3;

hint format["%1 %2 %3 %4", _target, _value, _name, _item];

if (_target == "drop") exitWith {
if (myMoney < _value) exitWith {
	player groupchat format["You tried to drop $%1. You only have $%2", _value, mymoney]
};
_pos = getposASL player;
_createMoney = "Land_Money_F" createVehicle _pos;
_name = format["item_%1", round(time)];
curItem = _createMoney;
   curName = _name;
   curValue  = _value;
[[["Create", curValue, curName, curItem], "drop.sqf"],"BIS_fnc_execVM",true,true] spawn BIS_fnc_MP;
myMoney = myMoney - _value;
player groupchat format["You dropped $%1. You now have $%2", _value, myMoney];
};

if (_target == "create") exitWith{
hint format["%1, %2, %3, %4", _target, _value, _name, _item];	
_item setVehicleVarName _name;
   curItem = _item;
   curName = _name;
   curValue  = _value;
   _item addaction [format["Pickup $%1", _value],"pickup.sqf",["pickup", curVal, "X", curItem]];
};

pickup.sqf

_item = (_this select 3) select 3;
_value = (_this select 3) select 1;

deleteVehicle _item;
myMoney = myMoney + _value;
player groupchat format["You picked up $%1. You now have $%2", _value, myMoney];

As a final note, the variable "myMoney" can be changed to whatever variable you are using for your money.

Enjoy.

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  

×