-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.cs
76 lines (63 loc) · 2.58 KB
/
server.cs
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
$SHOP::FilePath = filePath($Con::File) @ "/";
$SHOP::ServerPath = $SHOP::FilePath @ "server/";
$SHOP::CommonPath = $SHOP::FilePath @ "common/";
// Directories where price and inventory data is stored.
$SHOP::DataPath = "config/server/ItemShop/";
if ($Server::LAN)
$SHOP::DataPath = $SHOP::DataPath @ "lan/";
else
$SHOP::DataPath = $SHOP::DataPath @ "net/";
$SHOP::DataPath = $SHOP::DataPath @ strlwr($GamemodeDisplayName) @ "/";
$SHOP::GamemodePath = "Add-Ons/Gamemode_" @ $GamemodeDisplayName @ "/";
$SHOP::ClientDataPath = $SHOP::DataPath @ "clients/";
if (isObject(SHOP_ServerGroup)) {
SHOP_ServerGroup.chainDeleteAll();
SHOP_ServerGroup.delete();
}
new ScriptGroup(SHOP_ServerGroup);
exec($SHOP::ServerPath @ "ammoSupport.cs");
exec($SHOP::ServerPath @ "buyItems.cs");
exec($SHOP::ServerPath @ "commands.cs");
exec($SHOP::ServerPath @ "events.cs");
exec($SHOP::ServerPath @ "giveItem.cs");
exec($SHOP::ServerPath @ "players.cs");
exec($SHOP::ServerPath @ "prefs.cs");
exec($SHOP::ServerPath @ "priceTags.cs");
exec($SHOP::ServerPath @ "utils.cs");
exec($SHOP::ServerPath @ "InvData.cs");
exec($SHOP::ServerPath @ "PriceData.cs");
exec($SHOP::ServerPath @ "ShopData.cs");
exec($SHOP::CommonPath @ "CSVReader.cs");
$SHOP::DefaultShopData = SHOP_ShopData();
SHOP_ServerGroup.add($SHOP::DefaultShopData);
deactivatePackage(ItemShopPackage); // DEBUG
activatePackage(ItemShopPackage);
$SHOP::PriceSaveFileName = $SHOP::DataPath @ "itemshop.csv";
$SHOP::DefaultPriceSaveFileName = $SHOP::GamemodePath @ "itemshop.csv";
// We do not want to load shop data until all item add-ons have been loaded.
package ItemShopLoadAfterPackage
{
function GameConnection::onClientEnterGame(%this)
{
// A client cannot enter the game until all add-ons have been loaded
// so this is a good place to load item data.
// Load item data.
if (isFile($SHOP::PriceSaveFileName))
%loadFrom = $SHOP::PriceSaveFileName;
else if (isFile($SHOP::DefaultPriceSaveFileName))
%loadFrom = $SHOP::DefaultPriceSaveFileName;
if (%loadFrom !$= "") {
echo("Loading price data from \"" @ %loadFrom @ "\"");
$SHOP::DefaultShopData.loadData(%loadFrom);
}
// Make ammo pickups.
$SHOP::DefaultShopData.makeAmmoPickups();
Parent::onClientEnterGame(%this);
// Only need to run this script once so deactivate the package to prevent
// running it again. Please note that this must be called after
// Parent::onClientEnterGame or other packages that wrap this function will
// not execute.
deactivatePackage(ItemShopLoadAfterPackage);
}
};
activatePackage(ItemShopLoadAfterPackage);