-- ArmoredPacksEcpMod by 2S v2.2.0

-- NOTE:
-- Please do not distribute this code without permission.
-- You can edit this file only for personal use. 
-- If this code is re-released in your mod, please add credits.
-- Thanks..

-------------------------------------------------------------------------------------------------------------------
local ArmoredPacksEcpMod = {}
function ArmoredPacksEcpMod.unload()	
	UI.REMOVE_BLIP(blip)
end

local Notification = {}

function Notification.unload() end
function Notification.init() end
function Notification.tick() end

function notify(msg) 
	UI._SET_NOTIFICATION_TEXT_ENTRY("STRING")
	UI._ADD_TEXT_COMPONENT_STRING(msg)
	UI._DRAW_NOTIFICATION(FALSE, FALSE)
end

--DISPLAY BLIP
local blip = UI.ADD_BLIP_FOR_COORD(-671.388,90.853,55.855)
		UI.SET_BLIP_COLOUR(blip, 1)
		UI.SET_BLIP_SPRITE(blip, 426)
		UI.SET_BLIP_NAME_FROM_TEXT_FILE(blip, "Epsilon Charity Program")
		UI.SET_BLIP_SCALE(blip, 1)
		UI.SET_BLIP_AS_SHORT_RANGE(blip, true)

-------------MENU KEYS----------------
--NUMPAD
local openMenukey = Keys.E
local upKey = Keys.NumPad8
local downKey = Keys.NumPad2
local selectKey = Keys.NumPad5
local cancelKey = Keys.NumPad0

--ARROW KEYS
local arrowupKey = Keys.Up
local arrowdownKey = Keys.Down
local arrowselectKey = Keys.Return
local arrowcancelKey = Keys.Back

-------------------------------------------------------------------------------------------------------------------
--DO NOT EDIT BEYOND THIS POINT------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------

function mainEcpInit()
	APEcpGUI = APEcpGUIinit()

	--MENU
	APEcpGUI.mainMenu("main", "", "EPSILON PROGRAM - SUPER CAR", 0.17, 0.1, 0.234, 0.0522, 0.003, 0.35, 2)
	APEcpGUI.addButton("main", "Bullet $155000", spawnEpsilonVehicle,"bullet", false, 0.35, 0)
	APEcpGUI.addButton("main", "Adder $1000000", spawnEpsilonVehicle,"adder", false, 0.35, 0)
	APEcpGUI.addButton("main", "Vacca $240000", spawnEpsilonVehicle,"vacca", 0,0.45, 0.05,0.0)
	APEcpGUI.addButton("main", "Infernus $440000", spawnEpsilonVehicle,"infernus", false, 0.35, 0)
	APEcpGUI.addButton("main", "Zentorno $725000", spawnEpsilonVehicle,"zentorno", false, 0.35, 0)
	APEcpGUI.addButton("main", "Entity XF $795000", spawnEpsilonVehicle,"entityxf", false, 0.35, 0)
	APEcpGUI.addButton("main", "Cheetah $650000", spawnEpsilonVehicle,"cheetah", false, 0.35, 0)
	APEcpGUI.addButton("main", "Turismo R $500000", spawnEpsilonVehicle,"turismor", false, 0.35, 0)
	APEcpGUI.addButton("main", "Voltic $150000", spawnEpsilonVehicle,"voltic", false, 0.35, 0)
end

local ArmoredPacksEcpMod = {}

function ArmoredPacksEcpMod.unload()
end
function ArmoredPacksEcpMod.init()
mainEcpInit()

	--NUMPAD
	local E = openMenukey
	local numpad8 = upKey
	local numpad2 = downKey
	local numpad5 = selectKey
	local numpad0 = cancelKey
	
	--ARROW KEYS
	local keyup = arrowupKey
	local keydown = arrowdownKey
	local keyenter = arrowselectKey
	local keybackspace = arrowcancelKey

	APEcpGUI.updateSelection = {["menuOpen"] = {["keys"] = {E},["menu"] = "main"},["menuUp"] = {["keys"] = {numpad8,keyup}}, 
		["menuDown"] = {["keys"] = {numpad2,keydown}},["menuCancel"] = {["keys"] = {numpad0,keybackspace}},["select"] = {["keys"] = {numpad5,keyenter}}}
end
function ArmoredPacksEcpMod.tick()
	

	
		APEcpGUI.tick()
		
end

-------------------------------------------------------------------------------------------------------------------

function APEcpGUIinit()
	APEcpGUI = {}
	APEcpGUI.menu = {}
	APEcpGUI.buttons = {}
	APEcpGUI.updateSelection = {["menuOpen"] = {["keys"] = {},["menu"] = ""},["menuUp"] = {["keys"] = {}},
		["menuDown"] = {["keys"] = {}},["menuCancel"] = {["keys"] = {}},["select"] = {["keys"] = {}}}
	APEcpGUI.activeButton = 1
	APEcpGUI.activeMenu = ""
	APEcpGUI.IndexStatus = {["text"] = "", ["time"] = 0}

	function APEcpGUI.mainMenu(menuName, prevMenu, title, xmin, ymin, xmax, ymax, Space, textScale, font)
		if(APEcpGUI.menu[menuName] == nil) then
			APEcpGUI.menu[menuName] = {}
			lastOffset = ymin + ymax + Space
		end

		APEcpGUI.menu[menuName] = {["prevMenu"] = prevMenu,["title"] = title,["xmin"] = xmin,["ymin"] = ymin,
			["xmax"] = xmax,["ymax"] = ymax,["spacing"] = Space,["textScale"] = textScale,
			["font"] = font,["lastOffset"] = lastOffset,["numButtons"] = 0}
	end
	
	function APEcpGUI.addButton(mainMenu, text, funct, args, selectable, textScale, font)
		if(APEcpGUI.buttons[mainMenu] == nil or APEcpGUI.buttons[mainMenu]["settings"] == nil) then
			APEcpGUI.buttons[mainMenu] = {["settings"] = {}}
		end

		local currButtonNum = #APEcpGUI.buttons[mainMenu].settings + 1
		APEcpGUI.menu[mainMenu].numButtons = currButtonNum

		if(selectable) then
			selectableOn = false
		else
		    selectableOn = nil
		end

		APEcpGUI.buttons[mainMenu].settings[currButtonNum] = {["mainMenu"] = mainMenu,["text"] = text,["funct"] = funct,
			["args"] = args,["font"] = font,["xmin"] = APEcpGUI.menu[mainMenu].xmin,
			["ymin"] = APEcpGUI.menu[mainMenu].lastOffset,["xmax"] = APEcpGUI.menu[mainMenu].xmax,
			["ymax"] = APEcpGUI.menu[mainMenu].ymax,["textScale"] = textScale,
			["selectable"] = selectable,["selectableOn"] = selectableOn}

		APEcpGUI.menu[mainMenu]["lastOffset"] = (APEcpGUI.menu[mainMenu].lastOffset + APEcpGUI.menu[mainMenu].ymax + APEcpGUI.menu[mainMenu].spacing)
	end

	function APEcpGUI.setActiveMenu(menuName)
		APEcpGUI.activeButton = 1
		APEcpGUI.activeMenu = menuName
	end

	function APEcpGUI.drawIndex()
		if(nextDrawTime == nil or prevText ~= APEcpGUI.IndexStatus.text) then
			nextDrawTime = GAMEPLAY.GET_GAME_TIMER() + APEcpGUI.IndexStatus.time
		end

		if(nextDrawTime > GAMEPLAY.GET_GAME_TIMER()) then
			prevText = APEcpGUI.IndexStatus.text
			UI.SET_TEXT_FONT(0)
			UI.SET_TEXT_SCALE(0.0, 0.35)
			UI.SET_TEXT_COLOUR(255, 255, 255, 255)
			UI.SET_TEXT_WRAP(0, 1)
			UI.SET_TEXT_CENTRE(true)
			UI.SET_TEXT_DROPSHADOW(10, 10, 0, 0, 0)
			UI.SET_TEXT_EDGE(1, 0, 0, 0, 205)
			UI._SET_TEXT_ENTRY("STRING")
			UI._ADD_TEXT_COMPONENT_STRING(APEcpGUI.IndexStatus.text)
			UI._DRAW_TEXT(xmin , 0.5)
		else
			APEcpGUI.IndexStatus = {["text"] = "", ["time"] = 0}
			nextDrawTime = nil
		end
	end

	function addButtonText(text, xmin, ymin, textScale, font)
		if(text ~= nil and xmin ~= nil and ymin ~= nil and textScale ~= nil and font ~= nil) then
			UI.SET_TEXT_FONT(font)
			UI.SET_TEXT_SCALE(0.0, 0.30)
			UI.SET_TEXT_COLOUR(255, 255, 255, 255)
			UI.SET_TEXT_CENTRE(true)
			UI.SET_TEXT_DROPSHADOW(0, 0, 0, 0, 0)
			UI.SET_TEXT_EDGE(1, 0, 0, 0, 205)
			UI._SET_TEXT_ENTRY("STRING")
			UI._ADD_TEXT_COMPONENT_STRING(text)
			UI._DRAW_TEXT(xmin , ymin - 0.0125)
		else
			print("text: ", text, ", xmin: ", xmin, ", ymin: ", ymin, ", textScale: ", textScale, ", font: ", font)
		    APEcpGUI.setActiveMenu("")
		end
	end

	function APEcpGUI.drawAPEcpGUI()
		if(APEcpGUI.activeMenu ~= "" and APEcpGUI.activeMenu ~= nil) then
			local name = APEcpGUI.activeMenu

			if(APEcpGUI.menu[name] ~= nil) then
				local xmin = APEcpGUI.menu[name].xmin
				local ymin = APEcpGUI.menu[name].ymin
				local xmax = APEcpGUI.menu[name].xmax
				local ymax = APEcpGUI.menu[name].ymax
				
				local text = APEcpGUI.menu[name].title
				local textScale = APEcpGUI.menu[name].textScale
				local font = APEcpGUI.menu[name].font
				local colors = {["r"] = 0, ["g"] = 0, ["b"] = 0, ["o"] = 255}

				addButtonText(text, xmin, ymin, textScale, font)
				GRAPHICS.DRAW_RECT(xmin, ymin, xmax, ymax, colors.r, colors.g, colors.b, colors.o);

				if(APEcpGUI.buttons[name] ~= nil) then
					for i, v in pairs(APEcpGUI.buttons[name].settings) do
						local buttonSettings = APEcpGUI.buttons[name].settings[i]
						local xmin = buttonSettings.xmin
						local ymin = buttonSettings.ymin
						local xmax = buttonSettings.xmax
						local ymax = buttonSettings.ymax
						
						local font = buttonSettings.font
						local text = buttonSettings.text
						local textScale = buttonSettings.textScale
						local colors = {["r"] = 80, ["g"] = 180, ["b"] = 200, ["o"] = 180}

						if(buttonSettings.selectableOn == true) then
							text = buttonSettings.text .. " [ON]"
						elseif(buttonSettings.selectableOn == false) then
							text = buttonSettings.text .. " [OFF]"
						end
						
						if(i == APEcpGUI.activeButton) then
							colors = {["r"] = 100, ["g"] = 200, ["b"] = 220, ["o"] = 200}
						end

						addButtonText(text, xmin, ymin, textScale, font)
						GRAPHICS.DRAW_RECT(xmin, ymin, xmax, ymax, colors.r, colors.g, colors.b, colors.o);
					end
				else
					APEcpGUI.setActiveMenu("")
				end
			else
				APEcpGUI.setActiveMenu("")
			end
		end
	end

	function APEcpGUI.updateIndexStatus(text, time)
		APEcpGUI.IndexStatus = {["text"] = text, ["time"] = time}
	end

	function APEcpGUI.isButtonselectableOn()
		local activeButton = APEcpGUI.buttons[APEcpGUI.activeMenu].settings[APEcpGUI.activeButton]
		if(activeButton.selectable) then
			return activeButton.selectableOn
		elseif(activeButton.selectable == flse) then
			print("Button \"", APEcpGUI.buttons[APEcpGUI.activeMenu].settings[APEcpGUI.activeButton].text, "\"")
		    return nil
		end
	end

	function APEcpGUI.toggleButtonState()
		local activeButton = APEcpGUI.buttons[APEcpGUI.activeMenu].settings[APEcpGUI.activeButton]
		
		if(APEcpGUI.isButtonselectableOn() and activeButton.selectable) then
			activeButton.selectableOn = false
		elseif(APEcpGUI.isButtonselectableOn() == false and activeButton.selectable) then
			activeButton.selectableOn = true
			print("toggled on")
		end
	end

	function APEcpGUI.tick()
		APEcpGUI.drawIndex()
		APEcpGUI.drawAPEcpGUI()

		for i, key in pairs(APEcpGUI.updateSelection.menuOpen.keys) do
			if(get_key_pressed(key)) then
				if lastTime==nil or GAMEPLAY.GET_GAME_TIMER()-lastTime>120 then lastTime=GAMEPLAY.GET_GAME_TIMER()
					if(APEcpGUI.activeMenu == APEcpGUI.updateSelection.menuOpen.menu) then
						APEcpGUI.setActiveMenu(APEcpGUI.menu[APEcpGUI.activeMenu].prevMenu)
					else
					    APEcpGUI.setActiveMenu(APEcpGUI.updateSelection.menuOpen.menu)
					    APEcpGUI.currentSelection = 1
					end
				end
			
			end
		end

		for k, key in pairs(APEcpGUI.updateSelection.menuUp.keys) do
			if(get_key_pressed(key) and APEcpGUI.activeMenu ~= "") then
				if lastTime==nil or GAMEPLAY.GET_GAME_TIMER()-lastTime>120 then lastTime=GAMEPLAY.GET_GAME_TIMER()
					APEcpGUI.activeButton = APEcpGUI.activeButton - 1

					if(APEcpGUI.activeButton <= 0) then
						APEcpGUI.activeButton = APEcpGUI.menu[APEcpGUI.activeMenu].numButtons
					end
				end
			
			end
		end

		for k, key in pairs(APEcpGUI.updateSelection.menuDown.keys) do
			if(get_key_pressed(key) and APEcpGUI.activeMenu ~= "") then
				if lastTime==nil or GAMEPLAY.GET_GAME_TIMER()-lastTime>120 then lastTime=GAMEPLAY.GET_GAME_TIMER()
					APEcpGUI.activeButton = APEcpGUI.activeButton + 1
					if(APEcpGUI.activeButton > APEcpGUI.menu[APEcpGUI.activeMenu].numButtons) then
						APEcpGUI.activeButton = 1
					end
				end
			
			end
		end

		for k, key in pairs(APEcpGUI.updateSelection.select.keys) do
			if(get_key_pressed(key) and APEcpGUI.activeMenu ~= "") then
			   if lastTime==nil or GAMEPLAY.GET_GAME_TIMER()-lastTime>120 then lastTime=GAMEPLAY.GET_GAME_TIMER()
				local currButton = APEcpGUI.buttons[APEcpGUI.activeMenu].settings[APEcpGUI.activeButton]
				
				if(type(currButton.funct) == "function" and type(currButton.args) == "table") then
					APEcpGUI.toggleButtonState()
					currButton.funct(currButton.args[1], currButton.args[2], currButton.args[3], currButton.args[4], currButton.args[5], currButton.args[6], currButton.args[7], currButton.args[8], currButton.args[9], currButton.args[10], currButton.args[11], currButton.args[12], currButton.args[13], currButton.args[14], currButton.args[15], currButton.args[16], currButton.args[17], currButton.args[18], currButton.args[19], currButton.args[20])

				elseif(type(currButton.funct) == "function" and type(currButton.args) == "string" or type(currButton.args) == "number"or type(currButton.args) == "boolean") then
					APEcpGUI.toggleButtonState()
					currButton.funct(currButton.args)
					
				elseif(currButton.args == nil) then
					APEcpGUI.toggleButtonState()
					currButton.funct()

				else
					print("function: ", currButton.funct, ", args: ", currButton.args)
				end
			   end
			
			end
		end

		for k, key in pairs(APEcpGUI.updateSelection.menuCancel.keys) do
			if(get_key_pressed(key) and APEcpGUI.activeMenu ~= "") then
				if lastTime==nil or GAMEPLAY.GET_GAME_TIMER()-lastTime>120 then lastTime=GAMEPLAY.GET_GAME_TIMER()
					APEcpGUI.setActiveMenu(APEcpGUI.menu[APEcpGUI.activeMenu].prevMenu)
				end
			
			end
		end
	end

	return APEcpGUI
end

-------------------------------------------------------------------------------------------------------------------
 
--PRICES
	--SUPER
local sprosirisCost = 1950000
local sprbulletCost = 155000
local spradderCost = 1000000
local sprvaccaCost = 240000
local sprinfernusCost = 440000
local sprzentornoCost = 725000
local sprentityxfCost = 795000
local sprcheetahCost = 650000
local sprturismorCost = 500000
local sprvolticCost = 150000

--CARNAME
	--SUPER
local sprosirisCarName = "Osiris"
local sprbulletCarName = "Bullet"
local spradderCarName = "Adder"
local sprvaccaCarName = "Vacca"
local sprinfernusCarName = "Infernus"
local sprzentornoCarName = "Zentorno"
local sprentityxfCarName = "Entity XF"
local sprcheetahCarName = "Cheetah"
local sprturismorCarName = "Turismo R"
local sprvolticCarName = "Voltic"

local showMenu = false

local buy = false
local timebuy = 99999
local CarName = "not set"

local spawned = false
local sPed

-------------------------------------------------------------------------------------------------------------------

--Pay System
function Pay(pay)

local playerPed = PLAYER.PLAYER_PED_ID()

		if (PED.IS_PED_MODEL(playerPed, GAMEPLAY.GET_HASH_KEY("player_zero"))) then
			model = 0
		elseif (PED.IS_PED_MODEL(playerPed, GAMEPLAY.GET_HASH_KEY("player_one"))) then                                
			model = 1                                         
		elseif (PED.IS_PED_MODEL(playerPed, GAMEPLAY.GET_HASH_KEY("player_two"))) then
			model = 2
		end
	
		local statname = "SP"..model.."_TOTAL_CASH"
		local hash = GAMEPLAY.GET_HASH_KEY(statname)
		local bool, val = STATS.STAT_GET_INT(hash, 0, -1)

		STATS.STAT_SET_INT(hash, val - pay, true)

end

------------------------------------------------------------------------------

function ArmoredPacksEcpMod.tick()

	local playerPed = PLAYER.PLAYER_PED_ID()
	local playerPedinV = PED.IS_PED_IN_ANY_VEHICLE(playerPed, false)
	local playerCoords = ENTITY.GET_ENTITY_COORDS(playerPed, true)
	local buyPoint = GAMEPLAY.GET_DISTANCE_BETWEEN_COORDS(playerCoords.x, playerCoords.y, playerCoords.z, -671.388, 90.853, 55.855, true	)
	local player = PLAYER.GET_PLAYER_PED(playerPed)
	local location = ENTITY.GET_ENTITY_COORDS( playerPed, nil )
	
	--SHOW MENU FLAG
	if (not playerPedinV and buyPoint < 2 and not showMenu) then
		if PED._IS_PED_DEAD(sPed, true) then
			notify("Our Sister is not here, come back later Brother-Brother. Kifflom!")
		else
			notify("Kifflom! Brother-Brother, please donate for Epsilon Charity Program. PRESS E")
		
			if get_key_pressed(Keys.E) then
				showMenu = true
			end
		end
	end

	--SHOW MENU
	if(showMenu == true) then
		APEcpGUI.tick()
	end

	--CLOSE MENU
	if(buyPoint > 2 and get_key_pressed(Keys.E)) then
		showMenu = false
	elseif(buyPoint > 10 and showMenu == true) then
		showMenu = false
	end

	--PLAYER & DEALER DISTANCE
	if(buyPoint > 5 and showMenu == true) then
		notify("PRESS E to close the Menu")
	end

	--SPAWN/DESPAWN DEALER
	if(spawned == false and GAMEPLAY.GET_DISTANCE_BETWEEN_COORDS( location.x, location.y, location.z,-671.388, 90.853, 55.855, false ) < 150 ) then
		spawnEpsilonDealer()
		spawned = true
	elseif(spawned == true and GAMEPLAY.GET_DISTANCE_BETWEEN_COORDS( location.x, location.y, location.z,-671.388, 90.853, 55.855, false ) > 150 ) then
		PED.DELETE_PED(sPed)
		PED.DELETE_PED(bePed[0])
		PED.DELETE_PED(bePed[1])
		PED.DELETE_PED(bePed[2])
		PED.DELETE_PED(bePed[3])
		PED.DELETE_PED(bePed[4])
		PED.DELETE_PED(bePed[5])
		PED.DELETE_PED(bePed[6])
		PED.DELETE_PED(bePed[7])
		PED.DELETE_PED(bePed[8])
		PED.DELETE_PED(bePed[9])
		PED.DELETE_PED(bePed[10])
		sisterMoney = 0
		spawned = false
	end
		
	
end

--DEALER SPAWN
function spawnEpsilonDealer()

	local weapon = GAMEPLAY.GET_HASH_KEY("WEAPON_COMBATPISTOL")
	local weapon2 = GAMEPLAY.GET_HASH_KEY("WEAPON_STUNGUN")
	local weapon3 = GAMEPLAY.GET_HASH_KEY("WEAPON_SNIPERRIFLE")
	local weapon4 = GAMEPLAY.GET_HASH_KEY("WEAPON_SMG")

	---SISTER---
	local sister = GAMEPLAY.GET_HASH_KEY("A_F_Y_Epsilon_01")
	STREAMING.REQUEST_MODEL(sister)
	while(not STREAMING.HAS_MODEL_LOADED(sister)) do
		wait(50)
	end
	sPed = PED.CREATE_PED(1, sister, -671.388, 90.853, 55.855, 350, true, true)
	PED.SET_PED_CAN_SWITCH_WEAPON(sPed, true)
	WEAPON.GIVE_DELAYED_WEAPON_TO_PED(sPed, weapon2, 1000, false)
	PED.SET_PED_RELATIONSHIP_GROUP_HASH(sPed, GAMEPLAY.GET_HASH_KEY("PRIVATE_SECURITY"))
	ENTITY.SET_ENTITY_INVINCIBLE(sPed, false)
	STREAMING.SET_MODEL_AS_NO_LONGER_NEEDED(sister)
	sisterMoney = (GAMEPLAY.GET_RANDOM_INT_IN_RANGE(8000,100000))
	PED.SET_PED_MONEY(sPed, sisterMoney)

	---BROTHER---
	brother = GAMEPLAY.GET_HASH_KEY("A_M_Y_Epsilon_01")
	brother2 = GAMEPLAY.GET_HASH_KEY("A_M_Y_Epsilon_02")

	STREAMING.REQUEST_MODEL(brother)
	STREAMING.REQUEST_MODEL(brother2)
	
	while(not STREAMING.HAS_MODEL_LOADED(brother)) do
		wait(50)
	end

	while(not STREAMING.HAS_MODEL_LOADED(brother2)) do
		wait(50)
	end
	
	bePed = {}
	
	bePed[0] = PED.CREATE_PED(1, brother, -669.747, 93.659, 55.855, 356, true,true)
	PED.SET_PED_CAN_SWITCH_WEAPON(bePed[0], true)
	WEAPON.GIVE_DELAYED_WEAPON_TO_PED(bePed[0], weapon, 1000, false)
	PED.SET_PED_RELATIONSHIP_GROUP_HASH(bePed[0], GAMEPLAY.GET_HASH_KEY("PRIVATE_SECURITY"))
	ENTITY.SET_ENTITY_INVINCIBLE(bePed[0], false)
	
	bePed[1] = PED.CREATE_PED(1, brother, -672.747, 100.555, 55.855, 265, true,true)
	PED.SET_PED_CAN_SWITCH_WEAPON(bePed[1], true)
	WEAPON.GIVE_DELAYED_WEAPON_TO_PED(bePed[1], weapon, 1000, false)
	PED.SET_PED_RELATIONSHIP_GROUP_HASH(bePed[1], GAMEPLAY.GET_HASH_KEY("PRIVATE_SECURITY"))
	ENTITY.SET_ENTITY_INVINCIBLE(bePed[1], false)
	
	bePed[2] = PED.CREATE_PED(1, brother, -667.904, 103.678, 55.855, 189, true,true)
	PED.SET_PED_CAN_SWITCH_WEAPON(bePed[2], true)
	WEAPON.GIVE_DELAYED_WEAPON_TO_PED(bePed[2], weapon, 1000, false)
	PED.SET_PED_RELATIONSHIP_GROUP_HASH(bePed[2], GAMEPLAY.GET_HASH_KEY("PRIVATE_SECURITY"))
	ENTITY.SET_ENTITY_INVINCIBLE(bePed[2], false)
	
	bePed[3] = PED.CREATE_PED(1, brother, -665.750, 84.967, 51.931, 185, true,true)
	PED.SET_PED_CAN_SWITCH_WEAPON(bePed[3], true)
	WEAPON.GIVE_DELAYED_WEAPON_TO_PED(bePed[3], weapon, 1000, false)
	PED.SET_PED_RELATIONSHIP_GROUP_HASH(bePed[3], GAMEPLAY.GET_HASH_KEY("PRIVATE_SECURITY"))
	ENTITY.SET_ENTITY_INVINCIBLE(bePed[3], false)

	bePed[4] = PED.CREATE_PED(1, brother2, -676.537, 92.213, 55.855, 293, true,true)
	PED.SET_PED_CAN_SWITCH_WEAPON(bePed[4], true)
	WEAPON.GIVE_DELAYED_WEAPON_TO_PED(bePed[4], weapon2, 1000, false)
	PED.SET_PED_RELATIONSHIP_GROUP_HASH(bePed[4], GAMEPLAY.GET_HASH_KEY("PRIVATE_SECURITY"))
	ENTITY.SET_ENTITY_INVINCIBLE(bePed[4], false)

	bePed[5] = PED.CREATE_PED(1, brother2, -672.665, 69.987, 62.442, 307, true,true)
	PED.SET_PED_CAN_SWITCH_WEAPON(bePed[5], true)
	WEAPON.GIVE_DELAYED_WEAPON_TO_PED(bePed[5], weapon3, 1000, false)
	PED.SET_PED_RELATIONSHIP_GROUP_HASH(bePed[5], GAMEPLAY.GET_HASH_KEY("PRIVATE_SECURITY"))
	ENTITY.SET_ENTITY_INVINCIBLE(bePed[5], false)

	bePed[6] = PED.CREATE_PED(1, brother2, -674.549, 77.841, 69.686, 290, true,true)
	PED.SET_PED_CAN_SWITCH_WEAPON(bePed[6], true)
	WEAPON.GIVE_DELAYED_WEAPON_TO_PED(bePed[6], weapon3, 1000, false)
	PED.SET_PED_RELATIONSHIP_GROUP_HASH(bePed[6], GAMEPLAY.GET_HASH_KEY("PRIVATE_SECURITY"))
	ENTITY.SET_ENTITY_INVINCIBLE(bePed[6], false)

	bePed[7] = PED.CREATE_PED(1, brother2, -724.041, 71.107, 59.936, 23, true,true)
	PED.SET_PED_CAN_SWITCH_WEAPON(bePed[7], true)
	WEAPON.GIVE_DELAYED_WEAPON_TO_PED(bePed[7], weapon4, 1000, false)
	PED.SET_PED_RELATIONSHIP_GROUP_HASH(bePed[7], GAMEPLAY.GET_HASH_KEY("PRIVATE_SECURITY"))
	ENTITY.SET_ENTITY_INVINCIBLE(bePed[7], false)

	bePed[8] = PED.CREATE_PED(1, brother2, -715.816, 74.847, 59.936, 27, true,true)
	PED.SET_PED_CAN_SWITCH_WEAPON(bePed[8], true)
	WEAPON.GIVE_DELAYED_WEAPON_TO_PED(bePed[8], weapon4, 1000, false)
	PED.SET_PED_RELATIONSHIP_GROUP_HASH(bePed[8], GAMEPLAY.GET_HASH_KEY("PRIVATE_SECURITY"))
	ENTITY.SET_ENTITY_INVINCIBLE(bePed[8], false)

	bePed[9] = PED.CREATE_PED(1, brother2, -697.815, 47.196, 44.034, 187, true,true)
	PED.SET_PED_CAN_SWITCH_WEAPON(bePed[9], true)
	WEAPON.GIVE_DELAYED_WEAPON_TO_PED(bePed[9], weapon4, 1000, false)
	PED.SET_PED_RELATIONSHIP_GROUP_HASH(bePed[9], GAMEPLAY.GET_HASH_KEY("PRIVATE_SECURITY"))
	ENTITY.SET_ENTITY_INVINCIBLE(bePed[9], false)

	bePed[10] = PED.CREATE_PED(1, brother2, -689.183, 76.593, 55.855, 22, true,true)
	PED.SET_PED_CAN_SWITCH_WEAPON(bePed[10], true)
	WEAPON.GIVE_DELAYED_WEAPON_TO_PED(bePed[10], weapon4, 1000, false)
	PED.SET_PED_RELATIONSHIP_GROUP_HASH(bePed[10], GAMEPLAY.GET_HASH_KEY("PRIVATE_SECURITY"))
	ENTITY.SET_ENTITY_INVINCIBLE(bePed[10], false)
	
	STREAMING.SET_MODEL_AS_NO_LONGER_NEEDED(brother)
	STREAMING.SET_MODEL_AS_NO_LONGER_NEEDED(brother2)
	
end

--VEHICLE SPAWN
function spawnEpsilonVehicle(modelString) 

	print (timebuy)
	print(TIME.GET_CLOCK_DAY_OF_MONTH())
	print(TIME.GET_CLOCK_DAY_OF_MONTH() ~= timebuy)

if(TIME.GET_CLOCK_DAY_OF_MONTH() ~= timebuy) then
	
	local cost
		

	timebuy = TIME.GET_CLOCK_DAY_OF_MONTH()
		
	STREAMING.REQUEST_MODEL(GAMEPLAY.GET_HASH_KEY(modelString))
		
	while(not STREAMING.HAS_MODEL_LOADED(GAMEPLAY.GET_HASH_KEY(modelString))) do
		wait(50)
	end
		
	local vehE = VEHICLE.CREATE_VEHICLE(GAMEPLAY.GET_HASH_KEY(modelString), -668.579, 81.307, 51.503, 258, true, true)
	VEHICLE.SET_VEHICLE_ON_GROUND_PROPERLY(vehE)
		
			VEHICLE.SET_VEHICLE_NEEDS_TO_BE_HOTWIRED(vehE, false) 		
			VEHICLE.SET_VEHICLE_HAS_BEEN_OWNED_BY_PLAYER(vehE, true)
			VEHICLE.SET_VEHICLE_IS_STOLEN(vehE, false)
			VEHICLE.SET_VEHICLE_IS_WANTED(vehE, false)
			VEHICLE.SET_VEHICLE_MOD_KIT(vehE, 0)
			VEHICLE.SET_VEHICLE_MOD(vehE, 16, 1, true)
			VEHICLE.SET_VEHICLE_WHEEL_TYPE(vehE, 120)
			VEHICLE.SET_VEHICLE_WINDOW_TINT(vehE, 4) 
			VEHICLE.SET_CAN_RESPRAY_VEHICLE(vehE, true) 
			VEHICLE.SET_VEHICLE_TYRES_CAN_BURST(vehE, true) 
			VEHICLE.SET_VEHICLE_WHEELS_CAN_BREAK(vehE, true) 			
			VEHICLE.SET_VEHICLE_CUSTOM_PRIMARY_COLOUR(vehE, 135, 206, 250)
			VEHICLE.SET_VEHICLE_CUSTOM_SECONDARY_COLOUR(vehE, 135, 206, 250)
			VEHICLE.SET_VEHICLE_NUMBER_PLATE_TEXT(vehE, "K1FFL0M")
		
	STREAMING.SET_MODEL_AS_NO_LONGER_NEEDED(GAMEPLAY.GET_HASH_KEY(modelString))

	if(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("osiris")) then cost = sprosirisCost
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("bullet")) then cost = sprbulletCost
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("adder")) then cost = spradderCost
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("vacca")) then cost = sprvaccaCost
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("infernus")) then cost = sprinfernusCost
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("zentorno")) then cost = sprzentornoCost
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("entityxf")) then cost = sprentityxfCost
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("cheetah")) then cost = sprcheetahCost
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("turismor")) then cost = sprturismorCost
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("voltic")) then cost = sprvolticCost	
	end
	
	if(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("osiris")) then CarName = sprosirisCarName
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("bullet")) then CarName = sprbulletCarName
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("adder")) then CarName = spradderCarName
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("vacca")) then CarName = sprvaccaCarName
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("infernus")) then CarName = sprinfernusCarName
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("zentorno")) then CarName = sprzentornoCarName
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("entityxf")) then CarName = sprentityxfCarName
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("cheetah")) then CarName = sprcheetahCarName
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("turismor")) then CarName = sprturismorCarName
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("voltic")) then CarName = sprvolticCarName	
	end
	
	ENTITY.SET_VEHICLE_AS_NO_LONGER_NEEDED(vehE)
		
	Pay(cost)
	buy = true
	notify("Thank you for your donation, Your " .. CarName .. " is already delivered. Kifflom!")
		
elseif(TIME.GET_CLOCK_DAY_OF_MONTH() == timebuy) then
	notify("Kifflom Brother-Brother, please wait for another day")
end
		wait(5)
		
		
end


------------------------------------------------------------------------------
return ArmoredPacksEcpMod

-- Credits to: Alexander Blade & headscript--