Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class S7_ShopMenu_EventHandler : EventHandler {
- override void NetworkProcess (ConsoleEvent e) {
- if (e.IsManual || e.Player < 0) // Don't execute this if it was called manually or the player isn't given/valid
- return;
- if (!playeringame [e.Player] || !players [e.Player].mo) // Don't execute if the player isn't ingame, the player is null or the player's PlayerPawn is null
- return;
- let player = S7_BasePlayer (players [e.Player].mo);
- if (!player)
- return;
- Array<String> strings;
- e.Name.Split (strings, ":");
- if (strings.Size () < 2 || strings [0] != "S7_ShopMenu") // Return if the array has less than two strings or the first string isn't "S7_ShopMenu"
- return;
- if ((strings [1] == "Buy" || strings [1] == "Sell")) {
- let serverData = S7_ServerData.Get ();
- if (!serverData || !serverData.shopData || !serverData.shopData.mainShop)
- return;
- int amount = e.Args [1];
- double mod = 0.0;
- S7_SSItem item = NULL;
- for (int i = 0; i < serverData.shopData.allItems.Size (); i++) {
- if (serverData.shopData.allItems [i].id == e.Args [0]) {
- let item = serverData.shopData.allItems [i];
- break;
- }
- }
- if (!item)
- return;
- if (strings [1] == "Buy" && (item.itemType & IT_BuyItem))
- item.BuyItem (player, amount, mod);
- else if (strings [1] == "Sell" && (item.itemType & IT_SellItem))
- item.SellItem (player, amount, mod);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement