public void ColHit(ColShape shape, NetHandle ent) { var player = API.getPlayerFromHandle(ent); if (player == null) { return; } if (shape.hasData("Bench")) { if (player.vehicle != null) { return; } API.sendNotificationToPlayer(player, "Press E to sit down"); } else if (shape.hasData("vending") && shape.getData("filled") == false) { API.consoleOutput("vendingmachinhit"); Items.InventoryHolder ih = API.shared.getEntityData(ent, "InventoryHolder"); if (shape.getData("vending") == "3B21C5E7") { foreach (Items.InventoryItem ii in ih.Inventory) { if (ii.Details.ID == 57) { ih.RemoveItemFromInventory(Items.ItemByID(57)); API.triggerClientEvent(player, "display_subtitle", "~g~Goods Delivered! ~r~$40", 5000); shape.setData("filled", true); API.delay(1000000, true, () => { shape.setData("filled", false); }); } } } else if (shape.getData("vending") == "426A547C") { foreach (Items.InventoryItem ii in ih.Inventory) { if (ii.Details.ID == 56) { ih.RemoveItemFromInventory(Items.ItemByID(56)); API.triggerClientEvent(player, "display_subtitle", "~g~Goods Delivered! ~r~$45", 5000); shape.setData("filled", true); API.delay(1100000, true, () => { shape.setData("filled", false); }); } } } else if (shape.getData("vending") == "418F055A") { foreach (Items.InventoryItem ii in ih.Inventory) { if (ii.Details.ID == 58) { ih.RemoveItemFromInventory(Items.ItemByID(58)); API.triggerClientEvent(player, "display_subtitle", "~g~Goods Delivered! ~r~$60", 5000); shape.setData("filled", true); API.delay(1300000, true, () => { shape.setData("filled", false); }); } } } } else if (shape.hasData("vending") && shape.getData("filled") == true) { API.sendNotificationToPlayer(player, "This Machine has already been filled"); } }
public void ScriptEvent(Client sender, string eventName, object[] args) { if (eventName == "Enter") { if (sender.vehicle != null) { rentVehicle(sender); } } if (eventName == "VehicleMenuKeyPressed") { if (sender.vehicle != null) { object[] argumentList = new object[15]; argumentList[0] = 7; argumentList[1] = sender.vehicle.displayName; argumentList[2] = "Vehicle options"; argumentList[3] = false; argumentList[4] = 5; argumentList[5] = "Lock doors"; argumentList[6] = "Unlock doors"; argumentList[7] = "Pop/shut trunk"; argumentList[8] = "Pop/shut hood"; argumentList[9] = "Inventory"; for (var i = 0; i < 5; i++) { argumentList[10 + i] = ""; } API.triggerClientEvent(sender, "menu_handler_create_menu", argumentList); } } if (eventName == "menu_handler_select_item") { var callbackId = (int)args[0]; var index = (int)args[1]; if (callbackId == 7) { if (index == 0) { API.setVehicleLocked(sender.vehicle, true); // API.shared.playSoundFrontEnd(sender, "CONFIRM_BEEP", "HUD_MINI_GAME_SOUNDSET"); } if (index == 1) { API.setVehicleLocked(sender.vehicle, false); // API.shared.playSoundFrontEnd(sender, "CONFIRM_BEEP", "HUD_MINI_GAME_SOUNDSET"); } if (index == 2) { if (sender.vehicle.isDoorOpen(5)) { sender.vehicle.closeDoor(5); } else { sender.vehicle.openDoor(5); } } if (index == 3) { if (sender.vehicle.isDoorOpen(4)) { sender.vehicle.closeDoor(4); } else { sender.vehicle.openDoor(4); } } if (index == 4) { if (API.hasEntityData(sender.vehicle, "InventoryHolder")) { Items.InventoryHolder ih = API.getEntityData(sender.vehicle, "InventoryHolder"); if (ih != null) { var itemsLen = ih.Inventory.Count; object[] argumentList = new object[5 + itemsLen * 2]; argumentList[0] = 8; argumentList[1] = sender.vehicle.displayName; argumentList[2] = "Inventory ~b~Select an Item "; argumentList[3] = false; argumentList[4] = itemsLen; var i = 0; foreach (Items.InventoryItem item in ih.Inventory) { argumentList[5 + i] = item.Details.Name; argumentList[5 + itemsLen + i] = "Quantity: " + item.Quantity; i++; } API.triggerClientEvent(sender, "menu_handler_create_menu", argumentList); } } } } if (callbackId == 8) { Items.InventoryHolder ih = API.getEntityData(sender.vehicle, "InventoryHolder"); Items.InventoryHolder pih = API.getEntityData(sender, "InventoryHolder"); Items.InventoryItem item = ih.Inventory[index]; if (item.Details.ID == 56 || item.Details.ID == 57 || item.Details.ID == 58) { if (pih.Inventory.Exists(ii => ii.Details.ID == item.Details.ID)) { API.triggerClientEvent(sender, "show_subtitle", "~r~ You can only carry one of those", 3500); } else { ih.RemoveItemFromInventory(item.Details); pih.AddItemToInventory(item.Details); } } else { ih.RemoveItemFromInventory(item.Details); pih.AddItemToInventory(item.Details); } } } }