-- ArmoredPacksRldMod 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 ArmoredPacksRldMod = {}
function ArmoredPacksRldMod.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(959.742,3619.132,32.665)
		UI.SET_BLIP_COLOUR(blip, 1)
		UI.SET_BLIP_SPRITE(blip, 426)
		UI.SET_BLIP_NAME_FROM_TEXT_FILE(blip, "Redneks Local Dealers")
		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 mainRldInit()
	APRldGUI = APRldGUIinit()

	--MENU
	APRldGUI.mainMenu("main", "", "REDNECKS LD - SUV", 0.17, 0.1, 0.234, 0.0522, 0.003, 0.35, 2)
	APRldGUI.addButton("main", "Rocoto $90000", spawnRednecksVehicle,"rocoto", false, 0.35, 0)
	APRldGUI.addButton("main", "Patriot $102000", spawnRednecksVehicle,"patriot", false, 0.35, 0)
	APRldGUI.addButton("main", "Baller $90000", spawnRednecksVehicle,"baller", false, 0.35, 0)
	APRldGUI.addButton("main", "Huntley $195000", spawnRednecksVehicle,"huntley", false, 0.35, 0)
	APRldGUI.addButton("main", "Granger $35000", spawnRednecksVehicle,"granger", false, 0.35, 0)
	APRldGUI.addButton("main", "Seminole $30000", spawnRednecksVehicle,"seminole", false, 0.35, 0)
	APRldGUI.addButton("main", "Gresley $29000", spawnRednecksVehicle,"gresley", false, 0.35, 0)
	APRldGUI.addButton("main", "Cavalcade $70000", spawnRednecksVehicle,"cavalcade", false, 0.35, 0)
end

local ArmoredPacksRldMod = {}

function ArmoredPacksRldMod.unload()
end
function ArmoredPacksRldMod.init()
mainRldInit()

	--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

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

	
		APRldGUI.tick()
		
end

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

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

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

		APRldGUI.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 APRldGUI.addButton(mainMenu, text, funct, args, selectable, textScale, font)
		if(APRldGUI.buttons[mainMenu] == nil or APRldGUI.buttons[mainMenu]["settings"] == nil) then
			APRldGUI.buttons[mainMenu] = {["settings"] = {}}
		end

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

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

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

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

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

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

		if(nextDrawTime > GAMEPLAY.GET_GAME_TIMER()) then
			prevText = APRldGUI.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(APRldGUI.IndexStatus.text)
			UI._DRAW_TEXT(xmin , 0.5)
		else
			APRldGUI.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)
		    APRldGUI.setActiveMenu("")
		end
	end

	function APRldGUI.drawAPRldGUI()
		if(APRldGUI.activeMenu ~= "" and APRldGUI.activeMenu ~= nil) then
			local name = APRldGUI.activeMenu

			if(APRldGUI.menu[name] ~= nil) then
				local xmin = APRldGUI.menu[name].xmin
				local ymin = APRldGUI.menu[name].ymin
				local xmax = APRldGUI.menu[name].xmax
				local ymax = APRldGUI.menu[name].ymax
				
				local text = APRldGUI.menu[name].title
				local textScale = APRldGUI.menu[name].textScale
				local font = APRldGUI.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(APRldGUI.buttons[name] ~= nil) then
					for i, v in pairs(APRldGUI.buttons[name].settings) do
						local buttonSettings = APRldGUI.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"] = 150, ["g"] = 100, ["b"] = 80, ["o"] = 180}

						if(buttonSettings.selectableOn == true) then
							text = buttonSettings.text .. " [ON]"
						elseif(buttonSettings.selectableOn == false) then
							text = buttonSettings.text .. " [OFF]"
						end
						
						if(i == APRldGUI.activeButton) then
							colors = {["r"] = 200, ["g"] = 150, ["b"] = 130, ["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
					APRldGUI.setActiveMenu("")
				end
			else
				APRldGUI.setActiveMenu("")
			end
		end
	end

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

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

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

	function APRldGUI.tick()
		APRldGUI.drawIndex()
		APRldGUI.drawAPRldGUI()

		for i, key in pairs(APRldGUI.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(APRldGUI.activeMenu == APRldGUI.updateSelection.menuOpen.menu) then
						APRldGUI.setActiveMenu(APRldGUI.menu[APRldGUI.activeMenu].prevMenu)
					else
					    APRldGUI.setActiveMenu(APRldGUI.updateSelection.menuOpen.menu)
					    APRldGUI.currentSelection = 1
					end
				end
			
			end
		end

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

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

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

		for k, key in pairs(APRldGUI.updateSelection.select.keys) do
			if(get_key_pressed(key) and APRldGUI.activeMenu ~= "") then
			   if lastTime==nil or GAMEPLAY.GET_GAME_TIMER()-lastTime>120 then lastTime=GAMEPLAY.GET_GAME_TIMER()
				local currButton = APRldGUI.buttons[APRldGUI.activeMenu].settings[APRldGUI.activeButton]
				
				if(type(currButton.funct) == "function" and type(currButton.args) == "table") then
					APRldGUI.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
					APRldGUI.toggleButtonState()
					currButton.funct(currButton.args)
					
				elseif(currButton.args == nil) then
					APRldGUI.toggleButtonState()
					currButton.funct()

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

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

	return APRldGUI
end

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

--PRICES
	--SUV
local suvradiusCost = 32000
local suvrocotoCost = 90000
local suvpatriotCost = 102000
local suvbeejayxlCost = 86000
local suvballerCost = 90000
local suvhuntleysCost = 195000
local suvgrangerCost = 35000
local suvseminoleCost = 30000
local suvgresleyCost = 29000
local suvcavalcadeCost = 70000

--CARNAME
	--SUV
local suvradiusCarName = "Radius"
local suvrocotoCarName = "Rocoto"
local suvpatriotCarName = "Patriot"
local suvbeejayxlCarName = "Beejay XL"
local suvballerCarName = "Baller"
local suvhuntleysCarName = "Huntley"
local suvgrangerCarName = "Granger"
local suvseminoleCarName = "Seminole"
local suvgresleyCarName = "Gresley"
local suvcavalcadeCarName = "Cavalcade"

local showMenu = false

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

local spawned = false
local rnPed
local picadorRed

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

--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 ArmoredPacksRldMod.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, 959.742, 3619.132, 32.665, 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(rnPed, true) then
			notify("The Dealer is not here, come back later.")
		else
			notify("Howdy partner! What you want? PRESS E")
		
			if get_key_pressed(Keys.E) then
				showMenu = true
			end
		end
	end

	--SHOW MENU
	if(showMenu == true) then
		APRldGUI.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,959.742, 3619.132, 32.665, false ) < 150 ) then
		spawnRednecksDealer()
		spawned = true
	elseif(spawned == true and GAMEPLAY.GET_DISTANCE_BETWEEN_COORDS( location.x, location.y, location.z,959.742, 3619.132, 32.665, false ) > 150 ) then
		PED.DELETE_PED(rnPed)
		PED.DELETE_PED(g2Ped[0])
		PED.DELETE_PED(g2Ped[1])
		PED.DELETE_PED(g2Ped[2])
		PED.DELETE_PED(g2Ped[3])
		PED.DELETE_PED(g2Ped[4])
		PED.DELETE_PED(g2Ped[5])
		PED.DELETE_PED(g2Ped[6])
		PED.DELETE_PED(g2Ped[7])
		PED.DELETE_PED(g2Ped[8])
		PED.DELETE_PED(g2Ped[9])
		PED.DELETE_PED(g2Ped[10])
		PED.DELETE_PED(g2Ped[11])
		PED.DELETE_PED(g2Ped[12])
		rnbossMoney = 0
		spawned = false
	end
		
	
end

--DEALER SPAWN
function spawnRednecksDealer()

	local weapon = GAMEPLAY.GET_HASH_KEY("WEAPON_PUMPSHOTGUN")
	local weapon2 = GAMEPLAY.GET_HASH_KEY("WEAPON_MICROSMG")
	local weapon3 = GAMEPLAY.GET_HASH_KEY("WEAPON_MARKSMANRIFLE")
	local weapon4 = GAMEPLAY.GET_HASH_KEY("WEAPON_ASSAULTRIFLE")
	local weapon5 = GAMEPLAY.GET_HASH_KEY("WEAPON_PISTOL")

	---RNBOSS---
	local rnboss = GAMEPLAY.GET_HASH_KEY("A_M_M_Hillbilly_01")
	STREAMING.REQUEST_MODEL(rnboss)
	while(not STREAMING.HAS_MODEL_LOADED(rnboss)) do
		wait(50)
	end
	rnPed = PED.CREATE_PED(1, rnboss, 959.742, 3619.132, 32.665, 89, true, true)
	PED.SET_PED_CAN_SWITCH_WEAPON(rnPed, true)
	WEAPON.GIVE_DELAYED_WEAPON_TO_PED(rnPed, weapon4, 1000, false)
	PED.SET_PED_RELATIONSHIP_GROUP_HASH(rnPed, GAMEPLAY.GET_HASH_KEY("PRIVATE_SECURITY"))
	ENTITY.SET_ENTITY_INVINCIBLE(rnPed, false)
	STREAMING.SET_MODEL_AS_NO_LONGER_NEEDED(rnboss)
	rnbossMoney = (GAMEPLAY.GET_RANDOM_INT_IN_RANGE(2000,20000))
	PED.SET_PED_MONEY(rnPed, rnbossMoney)

	---RNGANG---
	rngang = GAMEPLAY.GET_HASH_KEY("A_M_M_Hillbilly_02")

	STREAMING.REQUEST_MODEL(rngang)
	
	while(not STREAMING.HAS_MODEL_LOADED(rngang)) do
		wait(50)
	end
	
	g2Ped = {}
	
	g2Ped[0] = PED.CREATE_PED(1, rngang, 958.596, 3615.210, 32.795, 17, true,true)
	PED.SET_PED_CAN_SWITCH_WEAPON(g2Ped[0], true)
	WEAPON.GIVE_DELAYED_WEAPON_TO_PED(g2Ped[0], weapon, 1000, false)
	PED.SET_PED_RELATIONSHIP_GROUP_HASH(g2Ped[0], GAMEPLAY.GET_HASH_KEY("PRIVATE_SECURITY"))
	ENTITY.SET_ENTITY_INVINCIBLE(g2Ped[0], false)
	
	g2Ped[1] = PED.CREATE_PED(1, rngang, 955.964, 3615.108, 32.793, 171, true,true)
	PED.SET_PED_CAN_SWITCH_WEAPON(g2Ped[1], true)
	WEAPON.GIVE_DELAYED_WEAPON_TO_PED(g2Ped[1], weapon, 1000, false)
	PED.SET_PED_RELATIONSHIP_GROUP_HASH(g2Ped[1], GAMEPLAY.GET_HASH_KEY("PRIVATE_SECURITY"))
	ENTITY.SET_ENTITY_INVINCIBLE(g2Ped[1], false)
	
	g2Ped[2] = PED.CREATE_PED(1, rngang, 954.032, 3622.183, 32.473, 83, true,true)
	PED.SET_PED_CAN_SWITCH_WEAPON(g2Ped[2], true)
	WEAPON.GIVE_DELAYED_WEAPON_TO_PED(g2Ped[2], weapon2, 1000, false)
	PED.SET_PED_RELATIONSHIP_GROUP_HASH(g2Ped[2], GAMEPLAY.GET_HASH_KEY("PRIVATE_SECURITY"))
	ENTITY.SET_ENTITY_INVINCIBLE(g2Ped[2], false)
	
	g2Ped[3] = PED.CREATE_PED(1, rngang, 973.367, 3615.023, 32.689, 259, true,true)
	PED.SET_PED_CAN_SWITCH_WEAPON(g2Ped[3], true)
	WEAPON.GIVE_DELAYED_WEAPON_TO_PED(g2Ped[3], weapon2, 1000, false)
	PED.SET_PED_RELATIONSHIP_GROUP_HASH(g2Ped[3], GAMEPLAY.GET_HASH_KEY("PRIVATE_SECURITY"))
	ENTITY.SET_ENTITY_INVINCIBLE(g2Ped[3], false)

	g2Ped[4] = PED.CREATE_PED(1, rngang, 973.241, 3617.499, 32.579, 327, true,true)
	PED.SET_PED_CAN_SWITCH_WEAPON(g2Ped[4], true)
	WEAPON.GIVE_DELAYED_WEAPON_TO_PED(g2Ped[4], weapon2, 1000, false)
	PED.SET_PED_RELATIONSHIP_GROUP_HASH(g2Ped[4], GAMEPLAY.GET_HASH_KEY("PRIVATE_SECURITY"))
	ENTITY.SET_ENTITY_INVINCIBLE(g2Ped[4], false)

	g2Ped[5] = PED.CREATE_PED(1, rngang, 954.986, 3624.836, 32.546, 54, true,true)
	PED.SET_PED_CAN_SWITCH_WEAPON(g2Ped[5], true)
	WEAPON.GIVE_DELAYED_WEAPON_TO_PED(g2Ped[5], weapon2, 1000, false)
	PED.SET_PED_RELATIONSHIP_GROUP_HASH(g2Ped[5], GAMEPLAY.GET_HASH_KEY("PRIVATE_SECURITY"))
	ENTITY.SET_ENTITY_INVINCIBLE(g2Ped[5], false)

	g2Ped[6] = PED.CREATE_PED(1, rngang, 955.644, 3622.728, 36.096, 90, true,true)
	PED.SET_PED_CAN_SWITCH_WEAPON(g2Ped[6], true)
	WEAPON.GIVE_DELAYED_WEAPON_TO_PED(g2Ped[6], weapon3, 1000, false)
	PED.SET_PED_RELATIONSHIP_GROUP_HASH(g2Ped[6], GAMEPLAY.GET_HASH_KEY("PRIVATE_SECURITY"))
	ENTITY.SET_ENTITY_INVINCIBLE(g2Ped[6], false)

	g2Ped[7] = PED.CREATE_PED(1, rngang, 967.856, 3623.336, 36.068, 270, true,true)
	PED.SET_PED_CAN_SWITCH_WEAPON(g2Ped[7], true)
	WEAPON.GIVE_DELAYED_WEAPON_TO_PED(g2Ped[7], weapon3, 1000, false)
	PED.SET_PED_RELATIONSHIP_GROUP_HASH(g2Ped[7], GAMEPLAY.GET_HASH_KEY("PRIVATE_SECURITY"))
	ENTITY.SET_ENTITY_INVINCIBLE(g2Ped[7], false)

	g2Ped[8] = PED.CREATE_PED(1, rngang, 960.925, 3624.576, 36.023, 23, true,true)
	PED.SET_PED_CAN_SWITCH_WEAPON(g2Ped[8], true)
	WEAPON.GIVE_DELAYED_WEAPON_TO_PED(g2Ped[8], weapon4, 1000, false)
	PED.SET_PED_RELATIONSHIP_GROUP_HASH(g2Ped[8], GAMEPLAY.GET_HASH_KEY("PRIVATE_SECURITY"))
	ENTITY.SET_ENTITY_INVINCIBLE(g2Ped[8], false)

	g2Ped[9] = PED.CREATE_PED(1, rngang, 964.645, 3624.533, 36.023, 356, true,true)
	PED.SET_PED_CAN_SWITCH_WEAPON(g2Ped[9], true)
	WEAPON.GIVE_DELAYED_WEAPON_TO_PED(g2Ped[9], weapon5, 1000, false)
	PED.SET_PED_RELATIONSHIP_GROUP_HASH(g2Ped[9], GAMEPLAY.GET_HASH_KEY("PRIVATE_SECURITY"))
	ENTITY.SET_ENTITY_INVINCIBLE(g2Ped[9], false)

	g2Ped[10] = PED.CREATE_PED(1, rngang, 918.491, 3646.092, 36.093, 208, true,true)
	PED.SET_PED_CAN_SWITCH_WEAPON(g2Ped[10], true)
	WEAPON.GIVE_DELAYED_WEAPON_TO_PED(g2Ped[10], weapon3, 1000, false)
	PED.SET_PED_RELATIONSHIP_GROUP_HASH(g2Ped[10], GAMEPLAY.GET_HASH_KEY("PRIVATE_SECURITY"))
	ENTITY.SET_ENTITY_INVINCIBLE(g2Ped[10], false)

	g2Ped[11] = PED.CREATE_PED(1, rngang, 907.911, 3646.505, 36.151, 171, true,true)
	PED.SET_PED_CAN_SWITCH_WEAPON(g2Ped[11], true)
	WEAPON.GIVE_DELAYED_WEAPON_TO_PED(g2Ped[11], weapon4, 1000, false)
	PED.SET_PED_RELATIONSHIP_GROUP_HASH(g2Ped[11], GAMEPLAY.GET_HASH_KEY("PRIVATE_SECURITY"))
	ENTITY.SET_ENTITY_INVINCIBLE(g2Ped[11], false)

	g2Ped[12] = PED.CREATE_PED(1, rngang, 911.696, 3646.010, 36.130, 178, true,true)
	PED.SET_PED_CAN_SWITCH_WEAPON(g2Ped[12], true)
	WEAPON.GIVE_DELAYED_WEAPON_TO_PED(g2Ped[12], weapon5, 1000, false)
	PED.SET_PED_RELATIONSHIP_GROUP_HASH(g2Ped[12], GAMEPLAY.GET_HASH_KEY("PRIVATE_SECURITY"))
	ENTITY.SET_ENTITY_INVINCIBLE(g2Ped[12], false)
	
	STREAMING.SET_MODEL_AS_NO_LONGER_NEEDED(rngang)
	
	STREAMING.REQUEST_MODEL(GAMEPLAY.GET_HASH_KEY("picador"))
	
	while(not STREAMING.HAS_MODEL_LOADED(GAMEPLAY.GET_HASH_KEY("picador"))) do
		wait(50)
	end
	
	picadorRed = VEHICLE.CREATE_VEHICLE(GAMEPLAY.GET_HASH_KEY("picador"), 950.097, 3622.740, 32.417, 85, true, true)
	VEHICLE.SET_VEHICLE_ON_GROUND_PROPERLY(picadorRed)
	ENTITY.SET_VEHICLE_AS_NO_LONGER_NEEDED(picadorRed)
	
end

--VEHICLE SPAWN
function spawnRednecksVehicle(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 vehRN = VEHICLE.CREATE_VEHICLE(GAMEPLAY.GET_HASH_KEY(modelString), 964.719, 3611.201, 32.794, 88, true, true)
	VEHICLE.SET_VEHICLE_ON_GROUND_PROPERLY(vehRN)
		
			VEHICLE.SET_VEHICLE_NEEDS_TO_BE_HOTWIRED(vehRN, false) 		
			VEHICLE.SET_VEHICLE_HAS_BEEN_OWNED_BY_PLAYER(vehRN, true)
			VEHICLE.SET_VEHICLE_IS_STOLEN(vehRN, true)
			VEHICLE.SET_VEHICLE_IS_WANTED(vehRN, true)
			VEHICLE.SET_VEHICLE_MOD_KIT(vehRN, 0)
			VEHICLE.SET_VEHICLE_MOD(vehRN, 16, 1, true)
			VEHICLE.SET_VEHICLE_WHEEL_TYPE(vehRN, 120)
			VEHICLE.SET_VEHICLE_WINDOW_TINT(vehRN, 0) 
			VEHICLE.SET_CAN_RESPRAY_VEHICLE(vehRN, true) 
			VEHICLE.SET_VEHICLE_TYRES_CAN_BURST(vehRN, true) 
			VEHICLE.SET_VEHICLE_WHEELS_CAN_BREAK(vehRN, true)
			VEHICLE.SET_VEHICLE_NUMBER_PLATE_TEXT(vehRN, "R3D")
		
	STREAMING.SET_MODEL_AS_NO_LONGER_NEEDED(GAMEPLAY.GET_HASH_KEY(modelString))

	if(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("radius")) then cost = suvradiusCost
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("rocoto")) then cost = suvrocotoCost
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("patriot")) then cost = suvpatriotCost
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("beejayxl")) then cost = suvbeejayxlCost
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("baller")) then cost = suvballerCost
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("huntley")) then cost = suvhuntleysCost
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("granger")) then cost = suvgrangerCost
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("seminole")) then cost = suvseminoleCost
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("gresley")) then cost = suvgresleyCost 
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("cavalcade")) then cost = suvcavalcadeCost
	end
	
	if(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("radius")) then CarName = suvradiusCarName
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("rocoto")) then CarName = suvrocotoCarName
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("patriot")) then CarName = suvpatriotCarName
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("beejayxl")) then CarName = suvbeejayxlCarName
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("baller")) then CarName = suvballerCarName
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("huntley")) then CarName = suvhuntleysCarName
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("granger")) then CarName = suvgrangerCarName
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("seminole")) then CarName = suvseminoleCarName
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("gresley")) then CarName = suvgresleyCarName 
	elseif(GAMEPLAY.GET_HASH_KEY(modelString) == GAMEPLAY.GET_HASH_KEY("cavalcade")) then CarName = suvcavalcadeCarName
	end
	
	ENTITY.SET_VEHICLE_AS_NO_LONGER_NEEDED(vehRN)
		
	Pay(cost)
	buy = true
	notify("Thank you, Your " .. CarName .. " is already delivered.")
		
elseif(TIME.GET_CLOCK_DAY_OF_MONTH() == timebuy) then
	notify("Wait for another shipment")
end
		wait(5)
		
		
end


------------------------------------------------------------------------------
return ArmoredPacksRldMod

-- Credits to: Alexander Blade & headscript--