-
Notifications
You must be signed in to change notification settings - Fork 0
/
GetMoneyList.sqf
113 lines (96 loc) · 3.18 KB
/
GetMoneyList.sqf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//GetMoneyList.sqf
//Runs on server
//Called from initServer.sqf
//Sets up money list
//pvs
private ["_moneyIndex", "_moneyIndexString", "_moneyName", "_moneyUID", "_moneyMoney", "_moneySteamName", "_count", "_max", "_index", "_next", "_i", "_number", "_money", "_steamName", "_ret","_name","_uid"];
while {true} do
{
newMoneyMoney = [];
newMoneyUIDS = [];
newMoneyNames = [];
newMoneySteamNames = [];
_moneyIndex = 0;
_moneyIndexString = str _moneyIndex;
_moneyName = ["MoneyList", "Names", _moneyIndexString, "STRING"] call iniDB_read;
while {_moneyName != ""} do
{
moneyNames set [_moneyIndex, _moneyName];
_moneyUID = ["MoneyList", "UIDs", _moneyIndexString, "STRING"] call iniDB_read;
moneyUIDS set [_moneyIndex,_moneyUID];
_moneyMoney = ["MoneyList", "Money", _moneyIndexString, "SCALAR"] call iniDB_read;
moneyMoney set [_moneyIndex,_moneyMoney];
_moneySteamName = ["MoneyList", "SteamNames", _moneyIndexString, "STRING"] call iniDB_read;
moneySteamNames set [_moneyIndex,_moneySteamName];
_moneyIndex = _moneyIndex + 1;
_moneyIndexString = str _moneyIndex;
_moneyName = ["MoneyList", "Names", _moneyIndexString, "STRING"] call iniDB_read;
};
//sort money list
//get position of maximum in array
_count = count moneyMoney;
_max = 0;
_index = 0;
nextMoney = +_count;
while {_count > 0} do
{
{
if (_forEachIndex == 0) then
{
_max = moneyMoney select _forEachIndex;
_index = 0;
}
else
{
_next = moneyMoney select _forEachIndex;
if (_next > _max) then
{
_max = _next;
_index = _forEachIndex;
};
};
}forEach moneyMoney;
newMoneyMoney append [_max];
newMoneyUIDS append [moneyUIDS select _index];
newMoneyNames append [moneyNames select _index];
newMoneySteamNames append [moneySteamNames select _index];
moneyMoney deleteAt _index;
moneyUIDS deleteAt _index;
moneyNames deleteAt _index;
moneySteamNames deleteAt _index;
_count = count moneyMoney;
};
for [{_i=0},{_i<(count newMoneyMoney)},{_i=_i+1}] do
{
_number = str _i;
_money = newMoneyMoney select _i;
_uid = newMoneyUIDS select _i;
_name = newMoneyNames select _i;
_steamName = newMoneySteamNames select _i;
_ret = ["MoneyList", "Money", _number, _money] call iniDB_write;
_ret = ["MoneyList", "UIDs", _number, _uid] call iniDB_write;
_ret = ["MoneyList", "Names", _number, _name] call iniDB_write;
_ret = ["MoneyList", "SteamNames", _number, _steamName] call iniDB_write;
};
moneyMoney = +newMoneyMoney;
moneyNames = +newMoneyNames;
moneyUIDS = +newMoneyUIDS;
moneySteamNames = +newMoneySteamNames;
moneyTime = time;
{
_firstOccurs = moneyUIDS find _x;
if ((_firstOccurs<_forEachIndex) or (_x=="")) then
{
moneyNames deleteAt _forEachIndex;
moneyUIDS deleteAt _forEachIndex;
moneyMoney deleteAt _forEachIndex;
moneySteamNames deleteAt _forEachIndex;
};
}forEach moneyUIDS;
publicVariable "moneyMoney";
publicVariable "moneyNames";
publicVariable "moneyUIDS";
publicVariable "moneySteamNames";
publicVariable "moneyTime";
sleep MoneyListDelay*60;
};