Hi I can't get my publicvariable to work right.
here is my in init.sqf
"trade" addPublicVariableEventHandler
{
civ = _this select 0;
amount = _this select 1;
item = _this select 2;
num = _this select 3;
if (player == civ) then
{
my_count = ((dcv_inv_array select num) select 1);
my_count = my_count + amount;
new_count = [item, my_count, num];
dcv_inv_array set [num, new_count];
player groupchat format [localize "STR_item_received", amount, item];
};
};
here is my script to open inventory menu(part)
player_array =
[
[Civ1, 0],
[Civ2, 1],
[Civ3, 2],
[Civ4, 3],
[Civ5, 4],
[Civ6, 5],
[Civ7, 6],
[Civ8, 7],
[Civ9, 8],
[Cop1, 9],
[Cop2, 10],
[Cop3, 11],
[Cop4, 12],
[Cop5, 13],
[Cop6, 14],
[Cop7, 15],
[Cop8, 16],
[Cop9, 17],
[Sher1, 18],
[Sher2, 19],
[Sher3, 20],
[Sher4, 21],
[Sher5, 22],
[Sher6, 23]
];
//--
test_array = [];
alive_p =
{
_p = _this select 0;
if ((alive _p) AND (!(isnull _p))) then
{
test_Array = test_array + [_p];
publicVariable "test_array";
};
};
{[_x select 0] call alive_p} foreach player_array;
{
//if ([_x select 0] call alive_p) then
//{
_index2 = lbAdd [_playerlist, format["%1 - %2", _x, name _x]];
lbSetData [_playerlist, _index2, format["%1", _x]];
lbSetValue [_playerlist, _index2, 0];
//};
} foreach test_array;
//--
and here is my trade script:
_playerlist = 31;
_index = lbCurSel 31;
_val = lbValue [31, _index];
_ind = lbCurSel 30;
item = lbData [30, _ind];
num = lbValue [30, _ind];
amount_to_send = parseNumber (ctrlText 33);
my_amount = ((dcv_inv_array select num) select 1);
p_name = lbData [_playerlist, _index];
if (my_amount < amount_to_send) exitwith {player groupchat format [localize "STR_not_enough", item]};
if ((amount_to_send + 1 == 1) OR (amount_to_send == 0) OR amount_to_send < 0) exitWith {player groupchat localize "STR_not_valid"};
if (item == "Rifle-Bag")exitWith {player groupchat localize "STR_cant_send"};
itemlist = 30;
player groupchat format [localize "STRitem_sent", p_name, amount_to_send, item];
my_amount = my_amount - amount_to_send;
_newitem_c = [item, my_amount, num];
dcv_inv_array set [num, _newitem_c];
lbClear itemlist;
{
if (_x select 1 > 0) then
{
_index = lbAdd [itemlist, format["%1: %2", _x select 0, _x select 1]];
lbSetData [itemlist, _index, _x select 0];
lbSetValue [itemlist, _index, _x select 2];
};
} foreach dcv_inv_array;
trade = [p_name, amount_to_send, item, num];
publicvariable "trade";
most important line being:
trade = [p_name, amount_to_send, item, num];
publicvariable "trade";
but for some reason there is not getting the item when I transfer it.
_playerlist = 31 //=IDC of combobox to select player to send to