-- ArmoredPacksPap2Mod 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 ArmoredPacksPap2Mod = {}
function ArmoredPacksPap2Mod.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(135.366,-1050.230,29.152)
		UI.SET_BLIP_COLOUR(blip, 1)
		UI.SET_BLIP_SPRITE(blip, 402)
		UI.SET_BLIP_NAME_FROM_TEXT_FILE(blip, "Pay and Plate 2")
		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 mainPap2Init()
	APPap2GUI = APPap2GUIinit()

	--MENU
	APPap2GUI.mainMenu("main", "", "PAY AND PLATE", 0.17, 0.1, 0.234, 0.0522, 0.003, 0.35, 2)
	APPap2GUI.addButton("main", "PLATE STYLE", APPap2GUI.setActiveMenu, "menu2", false, 0.35, 1)
	APPap2GUI.addButton("main", "CHANGE PLATE NUMBER", APPap2GUI.setActiveMenu, "menu3", false, 0.35, 1)

	APPap2GUI.mainMenu("menu2", "main", "PLATE STYLE", 0.17, 0.1, 0.234, 0.0522, 0.003, 0.35, 2)
	APPap2GUI.addButton("menu2", "Blue on White 1 $50", platePap2Style1,"", false, 0.35, 0)
	APPap2GUI.addButton("menu2", "Blue on White 2 $50", platePap2Style2,"", false, 0.35, 0)
	APPap2GUI.addButton("menu2", "Blue on White 3 $50", platePap2Style3,"", false, 0.35, 0)
	APPap2GUI.addButton("menu2", "Yellow on Blue $75", platePap2Style4,"", false, 0.35, 0)
	APPap2GUI.addButton("menu2", "Yellow on Black $150", platePap2Style5,"", false, 0.35, 0)
	APPap2GUI.addButton("menu2", "North Yankton $500", platePap2Style6,"", false, 0.35, 0)
	APPap2GUI.addButton("menu2", "PREV <", APPap2GUI.setActiveMenu, "main", false, 0.35, 1)

	APPap2GUI.mainMenu("menu3", "main", "CHANGE PLATE NUMBER", 0.17, 0.1, 0.234, 0.0522, 0.003, 0.35, 2)
	APPap2GUI.addButton("menu3", "GTA5 $4000", Pap2plate1,"", false, 0.35, 0)
	APPap2GUI.addButton("menu3", "4RM0R3D $2500", Pap2plate2,"", false, 0.35, 0)
	APPap2GUI.addButton("menu3", "R3B3L10N $2500", Pap2plate3,"", false, 0.35, 0)	
	APPap2GUI.addButton("menu3", "L0TU5 $1000", Pap2plate4,"", false, 0.35, 0)
	APPap2GUI.addButton("menu3", "3LD14BL0 $2500", Pap2plate5,"", false, 0.35, 0)
	APPap2GUI.addButton("menu3", "PREV <", APPap2GUI.setActiveMenu, "main", false, 0.35, 1)
	APPap2GUI.addButton("menu3", "NEXT >", APPap2GUI.setActiveMenu, "menu4", false, 0.35, 1)
	
	APPap2GUI.mainMenu("menu4", "main", "CHANGE PLATE NUMBER", 0.17, 0.1, 0.234, 0.0522, 0.003, 0.35, 2)
	APPap2GUI.addButton("menu4", "K1FFL0M $2500", Pap2plate6,"", false, 0.35, 0)
	APPap2GUI.addButton("menu4", "R3D $1000", Pap2plate7,"", false, 0.35, 0)
	APPap2GUI.addButton("menu4", "L057 $1000", Pap2plate8,"", false, 0.35, 0)
	APPap2GUI.addButton("menu4", "5YND1C4T $2500", Pap2plate9,"", false, 0.35, 0)
	APPap2GUI.addButton("menu4", "CREATE A PLATE $8000", createPap2Plate, "", false, 0.35, 0)
	APPap2GUI.addButton("menu4", "PREV <", APPap2GUI.setActiveMenu, "menu3", false, 0.35, 1)	
end

local ArmoredPacksPap2Mod = {}

function ArmoredPacksPap2Mod.unload()
end
function ArmoredPacksPap2Mod.init()
mainPap2Init()

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

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

	
		APPap2GUI.tick()
		
end

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

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

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

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

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

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

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

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

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

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

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

	function APPap2GUI.drawAPPap2GUI()
		if(APPap2GUI.activeMenu ~= "" and APPap2GUI.activeMenu ~= nil) then
			local name = APPap2GUI.activeMenu

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

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

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

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

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

	function APPap2GUI.tick()
		APPap2GUI.drawIndex()
		APPap2GUI.drawAPPap2GUI()

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

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

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

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

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

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

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

	return APPap2GUI
end

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

--PRICES
	--PLATES
local Pap2plate1Cost = 4000
local Pap2plate2Cost = 2500
local Pap2plate3Cost = 2500
local Pap2plate4Cost = 1000
local Pap2plate5Cost = 2500
local Pap2plate6Cost = 2500
local Pap2plate7Cost = 1000
local Pap2plate8Cost = 1000
local Pap2plate9Cost = 8000
local createPap2PlateCost = 10000

local platePap2Style1Cost = 50
local platePap2Style2Cost = 50
local platePap2Style3Cost = 50
local platePap2Style4Cost = 75
local platePap2Style5Cost = 150
local platePap2Style6Cost = 500

--NUMBER
	--PLATES
local numberPap2PlateText1 = "GTA5"
local numberPap2PlateText2 = "4RM0R3D"
local numberPap2PlateText3 = "R3B3L10N"
local numberPap2PlateText4 = "L0TU5"
local numberPap2PlateText5 = "3LD14BL0"
local numberPap2PlateText6 = "K1FFl0M"
local numberPap2PlateText7 = "R3D"
local numberPap2PlateText8 = "L057"
local numberPap2PlateText9 = "5YND1C4T"

local showMenu = false

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

local spawned = false
local m2Ped

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

--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 ArmoredPacksPap2Mod.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, 135.366, -1050.230, 29.152, true	)
	local player = PLAYER.GET_PLAYER_PED(playerPed)
	local location = ENTITY.GET_ENTITY_COORDS( playerPed, nil )
	
	--SHOW MENU FLAG
	if (playerPedinV and buyPoint < 2 and not showMenu) then
		if PED._IS_PED_DEAD(m2Ped, true) then
			notify("Pay and Plate is closed, come back later.")
		else
			notify("Welcome to Pay and Plate, what can i get for you?         PRESS E")
		
			if get_key_pressed(Keys.E) then
				showMenu = true
			end
		end
	end

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

	--CLOSE MENU
	if(playerPedinV and buyPoint > 4 and get_key_pressed(Keys.E)) then
		showMenu = false
	elseif(buyPoint > 8 and showMenu == true) then
		showMenu = false
	elseif(not playerPedinV and showMenu == true) then
		showMenu = false
	end

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

	if(buyPoint > 2 and buy == true and showMenu == true) then
		notify("Thank you.., Come again!")
		wait(5)
	end
	
	--SPAWN/DESPAWN MECHANIC
	if(spawned == false and GAMEPLAY.GET_DISTANCE_BETWEEN_COORDS( location.x, location.y, location.z,135.366, -1050.230, 29.152, false ) < 50 ) then
		spawnPaP2Mechanic()
		spawned = true
	elseif(spawned == true and GAMEPLAY.GET_DISTANCE_BETWEEN_COORDS( location.x, location.y, location.z,135.366, -1050.230, 29.152, false ) > 50 ) then
		PED.DELETE_PED(m2Ped)
		PED.DELETE_PED(r2Ped[0])
		mechanic2Money = 0
		spawned = false
	end
		
	
end

--CREATE PLATE
function createPap2Plate()
	
	GAMEPLAY.DISPLAY_ONSCREEN_KEYBOARD(true, "FMMC_KEY_TIP", "", "", "", "", "", 9)
	while (GAMEPLAY.UPDATE_ONSCREEN_KEYBOARD() == 0) do
		wait(0)
	end
	if (GAMEPLAY.GET_ONSCREEN_KEYBOARD_RESULT()) then
		local vehPlayer = PED.GET_VEHICLE_PED_IS_IN(PLAYER.GET_PLAYER_PED(-1), true)
		VEHICLE.SET_VEHICLE_NUMBER_PLATE_TEXT(vehPlayer, GAMEPLAY.GET_ONSCREEN_KEYBOARD_RESULT())

	Pay(createPap2PlateCost)
	buy = true
	end
end

--CHOSE PLATE
function Pap2plate1()
	if(PED.IS_PED_IN_ANY_VEHICLE(PLAYER.GET_PLAYER_PED(-1), false) and numberPap2PlateText1~=nil) then
		local vehPlayer = PED.GET_VEHICLE_PED_IS_IN(PLAYER.GET_PLAYER_PED(-1), true)
		VEHICLE.SET_VEHICLE_NUMBER_PLATE_TEXT(vehPlayer, numberPap2PlateText1)

	Pay(Pap2plate1Cost)
	buy = true
	end
end

function Pap2plate2()
	if(PED.IS_PED_IN_ANY_VEHICLE(PLAYER.GET_PLAYER_PED(-1), false) and numberPap2PlateText2~=nil) then
		local vehPlayer = PED.GET_VEHICLE_PED_IS_IN(PLAYER.GET_PLAYER_PED(-1), true)
		VEHICLE.SET_VEHICLE_NUMBER_PLATE_TEXT(vehPlayer, numberPap2PlateText2)

	Pay(Pap2plate2Cost)
	buy = true
	end
end

function Pap2plate3()
	if(PED.IS_PED_IN_ANY_VEHICLE(PLAYER.GET_PLAYER_PED(-1), false) and numberPap2PlateText3~=nil) then
		local vehPlayer = PED.GET_VEHICLE_PED_IS_IN(PLAYER.GET_PLAYER_PED(-1), true)
		VEHICLE.SET_VEHICLE_NUMBER_PLATE_TEXT(vehPlayer, numberPap2PlateText3)

	Pay(Pap2plate3Cost)
	buy = true
	end
end

function Pap2plate4()
	if(PED.IS_PED_IN_ANY_VEHICLE(PLAYER.GET_PLAYER_PED(-1), false) and numberPap2PlateText4~=nil) then
		local vehPlayer = PED.GET_VEHICLE_PED_IS_IN(PLAYER.GET_PLAYER_PED(-1), true)
		VEHICLE.SET_VEHICLE_NUMBER_PLATE_TEXT(vehPlayer, numberPap2PlateText4)

	Pay(Pap2plate4Cost)
	buy = true
	end
end

function Pap2plate5()
	if(PED.IS_PED_IN_ANY_VEHICLE(PLAYER.GET_PLAYER_PED(-1), false) and numberPap2PlateText5~=nil) then
		local vehPlayer = PED.GET_VEHICLE_PED_IS_IN(PLAYER.GET_PLAYER_PED(-1), true)
		VEHICLE.SET_VEHICLE_NUMBER_PLATE_TEXT(vehPlayer, numberPap2PlateText5)

	Pay(Pap2plate5Cost)
	buy = true
	end
end

function Pap2plate6()
	if(PED.IS_PED_IN_ANY_VEHICLE(PLAYER.GET_PLAYER_PED(-1), false) and numberPap2PlateText6~=nil) then
		local vehPlayer = PED.GET_VEHICLE_PED_IS_IN(PLAYER.GET_PLAYER_PED(-1), true)
		VEHICLE.SET_VEHICLE_NUMBER_PLATE_TEXT(vehPlayer, numberPap2PlateText6)

	Pay(Pap2plate6Cost)
	buy = true
	end
end

function Pap2plate7()
	if(PED.IS_PED_IN_ANY_VEHICLE(PLAYER.GET_PLAYER_PED(-1), false) and numberPap2PlateText7~=nil) then
		local vehPlayer = PED.GET_VEHICLE_PED_IS_IN(PLAYER.GET_PLAYER_PED(-1), true)
		VEHICLE.SET_VEHICLE_NUMBER_PLATE_TEXT(vehPlayer, numberPap2PlateText7)

	Pay(Pap2plate7Cost)
	buy = true
	end
end

function Pap2plate8()
	if(PED.IS_PED_IN_ANY_VEHICLE(PLAYER.GET_PLAYER_PED(-1), false) and numberPap2PlateText8~=nil) then
		local vehPlayer = PED.GET_VEHICLE_PED_IS_IN(PLAYER.GET_PLAYER_PED(-1), true)
		VEHICLE.SET_VEHICLE_NUMBER_PLATE_TEXT(vehPlayer, numberPap2PlateText8)

	Pay(Pap2plate8Cost)
	buy = true
	end
end

function Pap2plate9()
	if(PED.IS_PED_IN_ANY_VEHICLE(PLAYER.GET_PLAYER_PED(-1), false) and numberPap2PlateText9~=nil) then
		local vehPlayer = PED.GET_VEHICLE_PED_IS_IN(PLAYER.GET_PLAYER_PED(-1), true)
		VEHICLE.SET_VEHICLE_NUMBER_PLATE_TEXT(vehPlayer, numberPap2PlateText9)

	Pay(Pap2plate9Cost)
	buy = true
	end
end

function platePap2Style1()
	if(PED.IS_PED_IN_ANY_VEHICLE(PLAYER.GET_PLAYER_PED(-1), false))then
		local vehPlayer = PED.GET_VEHICLE_PED_IS_IN(PLAYER.GET_PLAYER_PED(-1), true)
		VEHICLE.SET_VEHICLE_NUMBER_PLATE_TEXT_INDEX(vehPlayer, 3)

	Pay(platePap2Style1Cost)
	buy = true
	end
end

function platePap2Style2()
	if(PED.IS_PED_IN_ANY_VEHICLE(PLAYER.GET_PLAYER_PED(-1), false))then
		local vehPlayer = PED.GET_VEHICLE_PED_IS_IN(PLAYER.GET_PLAYER_PED(-1), true)
		VEHICLE.SET_VEHICLE_NUMBER_PLATE_TEXT_INDEX(vehPlayer, 0)

	Pay(platePap2Style2Cost)
	buy = true
	end
end

function platePap2Style3()
	if(PED.IS_PED_IN_ANY_VEHICLE(PLAYER.GET_PLAYER_PED(-1), false))then
		local vehPlayer = PED.GET_VEHICLE_PED_IS_IN(PLAYER.GET_PLAYER_PED(-1), true)
		VEHICLE.SET_VEHICLE_NUMBER_PLATE_TEXT_INDEX(vehPlayer, 4)

	Pay(platePap2Style3Cost)
	buy = true
	end
end

function platePap2Style4()
	if(PED.IS_PED_IN_ANY_VEHICLE(PLAYER.GET_PLAYER_PED(-1), false))then
		local vehPlayer = PED.GET_VEHICLE_PED_IS_IN(PLAYER.GET_PLAYER_PED(-1), true)
		VEHICLE.SET_VEHICLE_NUMBER_PLATE_TEXT_INDEX(vehPlayer, 2)

	Pay(platePap2Style5Cost)
	buy = true
	end
end

function platePap2Style5()
	if(PED.IS_PED_IN_ANY_VEHICLE(PLAYER.GET_PLAYER_PED(-1), false))then
		local vehPlayer = PED.GET_VEHICLE_PED_IS_IN(PLAYER.GET_PLAYER_PED(-1), true)
		VEHICLE.SET_VEHICLE_NUMBER_PLATE_TEXT_INDEX(vehPlayer, 1)

	Pay(platePap2Style5Cost)
	buy = true
	end
end

function platePap2Style6()
	if(PED.IS_PED_IN_ANY_VEHICLE(PLAYER.GET_PLAYER_PED(-1), false))then
		local vehPlayer = PED.GET_VEHICLE_PED_IS_IN(PLAYER.GET_PLAYER_PED(-1), true)
		VEHICLE.SET_VEHICLE_NUMBER_PLATE_TEXT_INDEX(vehPlayer, 5)

	Pay(platePap2Style6Cost)
	buy = true
	end
end

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

--MECHANIC SPAWN
function spawnPaP2Mechanic()

	local weapon = GAMEPLAY.GET_HASH_KEY("WEAPON_PISTOL")

	---MECHANIC---
	local mechanic2 = GAMEPLAY.GET_HASH_KEY("S_M_M_AutoShop_01")
	STREAMING.REQUEST_MODEL(mechanic2)
	while(not STREAMING.HAS_MODEL_LOADED(mechanic2)) do
		wait(50)
	end
	m2Ped = PED.CREATE_PED(1, mechanic2, 138.508, -1048.219, 29.152, 154, true, true)
	PED.SET_PED_CAN_SWITCH_WEAPON(m2Ped, true)
	WEAPON.GIVE_DELAYED_WEAPON_TO_PED(m2Ped, weapon, 1000, false)
	PED.SET_PED_RELATIONSHIP_GROUP_HASH(m2Ped, GAMEPLAY.GET_HASH_KEY("PRIVATE_SECURITY"))
	ENTITY.SET_ENTITY_INVINCIBLE(m2Ped, false)
	STREAMING.SET_MODEL_AS_NO_LONGER_NEEDED(mechanic2)
	mechanic2Money = (GAMEPLAY.GET_RANDOM_INT_IN_RANGE(1000,10000))
	PED.SET_PED_MONEY(m2Ped, mechanic2Money)

	---REPAIRMAN---
	repairman2 = GAMEPLAY.GET_HASH_KEY("S_M_M_AutoShop_02")

	STREAMING.REQUEST_MODEL(repairman2)
	
	while(not STREAMING.HAS_MODEL_LOADED(repairman2)) do
		wait(50)
	end
	
	r2Ped = {}
	
	r2Ped[0] = PED.CREATE_PED(1, repairman2, 132.547, -1049.952, 29.344, 255, true,true)
	PED.SET_PED_CAN_SWITCH_WEAPON(r2Ped[0], true)
	WEAPON.GIVE_DELAYED_WEAPON_TO_PED(r2Ped[0], weapon, 1000, false)
	PED.SET_PED_RELATIONSHIP_GROUP_HASH(r2Ped[0], GAMEPLAY.GET_HASH_KEY("PRIVATE_SECURITY"))
	ENTITY.SET_ENTITY_INVINCIBLE(r2Ped[0], false)

	STREAMING.SET_MODEL_AS_NO_LONGER_NEEDED(repairman2)
	
end


------------------------------------------------------------------------------
return ArmoredPacksPap2Mod

-- Credits to: Alexander Blade & headscript--