-- ArmoredPacksPap1Mod 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 ArmoredPacksPap1Mod = {}
function ArmoredPacksPap1Mod.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(147.275,321.009,112.139)
		UI.SET_BLIP_COLOUR(blip, 1)
		UI.SET_BLIP_SPRITE(blip, 402)
		UI.SET_BLIP_NAME_FROM_TEXT_FILE(blip, "Pay and Plate 1")
		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 mainPap1Init()
	APPap1GUI = APPap1GUIinit()

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

	APPap1GUI.mainMenu("menu2", "main", "PLATE STYLE", 0.17, 0.1, 0.234, 0.0522, 0.003, 0.35, 2)
	APPap1GUI.addButton("menu2", "Blue on White 1 $50", platePap1Style1,"", false, 0.35, 0)
	APPap1GUI.addButton("menu2", "Blue on White 2 $50", platePap1Style2,"", false, 0.35, 0)
	APPap1GUI.addButton("menu2", "Blue on White 3 $50", platePap1Style3,"", false, 0.35, 0)
	APPap1GUI.addButton("menu2", "Yellow on Blue $75", platePap1Style4,"", false, 0.35, 0)
	APPap1GUI.addButton("menu2", "Yellow on Black $150", platePap1Style5,"", false, 0.35, 0)
	APPap1GUI.addButton("menu2", "North Yankton $500", platePap1Style6,"", false, 0.35, 0)
	APPap1GUI.addButton("menu2", "PREV <", APPap1GUI.setActiveMenu, "main", false, 0.35, 1)

	APPap1GUI.mainMenu("menu3", "main", "CHANGE PLATE NUMBER", 0.17, 0.1, 0.234, 0.0522, 0.003, 0.35, 2)
	APPap1GUI.addButton("menu3", "GTA5 $4000", Pap1plate1,"", false, 0.35, 0)
	APPap1GUI.addButton("menu3", "4RM0R3D $2500", Pap1plate2,"", false, 0.35, 0)
	APPap1GUI.addButton("menu3", "R3B3L10N $2500", Pap1plate3,"", false, 0.35, 0)	
	APPap1GUI.addButton("menu3", "L0TU5 $1000", Pap1plate4,"", false, 0.35, 0)
	APPap1GUI.addButton("menu3", "3LD14BL0 $2500", Pap1plate5,"", false, 0.35, 0)
	APPap1GUI.addButton("menu3", "PREV <", APPap1GUI.setActiveMenu, "main", false, 0.35, 1)
	APPap1GUI.addButton("menu3", "NEXT >", APPap1GUI.setActiveMenu, "menu4", false, 0.35, 1)
	
	APPap1GUI.mainMenu("menu4", "main", "CHANGE PLATE NUMBER", 0.17, 0.1, 0.234, 0.0522, 0.003, 0.35, 2)
	APPap1GUI.addButton("menu4", "K1FFL0M $2500", Pap1plate6,"", false, 0.35, 0)
	APPap1GUI.addButton("menu4", "R3D $1000", Pap1plate7,"", false, 0.35, 0)
	APPap1GUI.addButton("menu4", "L057 $1000", Pap1plate8,"", false, 0.35, 0)
	APPap1GUI.addButton("menu4", "5YND1C4T $2500", Pap1plate9,"", false, 0.35, 0)
	APPap1GUI.addButton("menu4", "CREATE A PLATE $8000", createPap1Plate, "", false, 0.35, 0)
	APPap1GUI.addButton("menu4", "PREV <", APPap1GUI.setActiveMenu, "menu3", false, 0.35, 1)	
end

local ArmoredPacksPap1Mod = {}

function ArmoredPacksPap1Mod.unload()
end
function ArmoredPacksPap1Mod.init()
mainPap1Init()

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

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

	
		APPap1GUI.tick()
		
end

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

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

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

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

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

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

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

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

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

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

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

	function APPap1GUI.drawAPPap1GUI()
		if(APPap1GUI.activeMenu ~= "" and APPap1GUI.activeMenu ~= nil) then
			local name = APPap1GUI.activeMenu

			if(APPap1GUI.menu[name] ~= nil) then
				local xmin = APPap1GUI.menu[name].xmin
				local ymin = APPap1GUI.menu[name].ymin
				local xmax = APPap1GUI.menu[name].xmax
				local ymax = APPap1GUI.menu[name].ymax
				
				local text = APPap1GUI.menu[name].title
				local textScale = APPap1GUI.menu[name].textScale
				local font = APPap1GUI.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(APPap1GUI.buttons[name] ~= nil) then
					for i, v in pairs(APPap1GUI.buttons[name].settings) do
						local buttonSettings = APPap1GUI.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 == APPap1GUI.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
					APPap1GUI.setActiveMenu("")
				end
			else
				APPap1GUI.setActiveMenu("")
			end
		end
	end

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

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

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

	function APPap1GUI.tick()
		APPap1GUI.drawIndex()
		APPap1GUI.drawAPPap1GUI()

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

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

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

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

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

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

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

	return APPap1GUI
end

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

--PRICES
	--PLATES
local Pap1plate1Cost = 4000
local Pap1plate2Cost = 2500
local Pap1plate3Cost = 2500
local Pap1plate4Cost = 1000
local Pap1plate5Cost = 2500
local Pap1plate6Cost = 2500
local Pap1plate7Cost = 1000
local Pap1plate8Cost = 1000
local Pap1plate9Cost = 8000
local createPap1PlateCost = 10000

local platePap1Style1Cost = 50
local platePap1Style2Cost = 50
local platePap1Style3Cost = 50
local platePap1Style4Cost = 75
local platePap1Style5Cost = 150
local platePap1Style6Cost = 500

--NUMBER
	--PLATES
local numberPap1PlateText1 = "GTA5"
local numberPap1PlateText2 = "4RM0R3D"
local numberPap1PlateText3 = "R3B3L10N"
local numberPap1PlateText4 = "L0TU5"
local numberPap1PlateText5 = "3LD14BL0"
local numberPap1PlateText6 = "K1FFl0M"
local numberPap1PlateText7 = "R3D"
local numberPap1PlateText8 = "L057"
local numberPap1PlateText9 = "5YND1C4T"

local showMenu = false

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

local spawned = false
local m1Ped

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

--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 ArmoredPacksPap1Mod.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, 147.275, 321.009, 112.139, 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(m1Ped, 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
		APPap1GUI.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,147.275, 321.009, 112.139, false ) < 50 ) then
		spawnPaP1Mechanic()
		spawned = true
	elseif(spawned == true and GAMEPLAY.GET_DISTANCE_BETWEEN_COORDS( location.x, location.y, location.z,147.275, 321.009, 112.139, false ) > 50 ) then
		PED.DELETE_PED(m1Ped)
		PED.DELETE_PED(r1Ped[0])
		PED.DELETE_PED(r1Ped[1])
		mechanic1Money = 0
		spawned = false
	end
		
	
end

--CREATE PLATE
function createPap1Plate()
	
	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(createPap1PlateCost)
	buy = true
	end
end

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

	Pay(Pap1plate1Cost)
	buy = true
	end
end

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

	Pay(Pap1plate2Cost)
	buy = true
	end
end

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

	Pay(Pap1plate3Cost)
	buy = true
	end
end

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

	Pay(Pap1plate4Cost)
	buy = true
	end
end

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

	Pay(Pap1plate5Cost)
	buy = true
	end
end

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

	Pay(Pap1plate6Cost)
	buy = true
	end
end

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

	Pay(Pap1plate7Cost)
	buy = true
	end
end

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

	Pay(Pap1plate8Cost)
	buy = true
	end
end

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

	Pay(Pap1plate9Cost)
	buy = true
	end
end

function platePap1Style1()
	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(platePap1Style1Cost)
	buy = true
	end
end

function platePap1Style2()
	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(platePap1Style2Cost)
	buy = true
	end
end

function platePap1Style3()
	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(platePap1Style3Cost)
	buy = true
	end
end

function platePap1Style4()
	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(platePap1Style5Cost)
	buy = true
	end
end

function platePap1Style5()
	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(platePap1Style5Cost)
	buy = true
	end
end

function platePap1Style6()
	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(platePap1Style6Cost)
	buy = true
	end
end

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

--MECHANIC SPAWN
function spawnPaP1Mechanic()

	local weapon = GAMEPLAY.GET_HASH_KEY("WEAPON_PISTOL")

	---MECHANIC---
	local mechanic1 = GAMEPLAY.GET_HASH_KEY("S_M_M_AutoShop_01")
	STREAMING.REQUEST_MODEL(mechanic1)
	while(not STREAMING.HAS_MODEL_LOADED(mechanic1)) do
		wait(50)
	end
	m1Ped = PED.CREATE_PED(1, mechanic1, 150.600, 318.407, 112.139, 64, true, true)
	PED.SET_PED_CAN_SWITCH_WEAPON(m1Ped, true)
	WEAPON.GIVE_DELAYED_WEAPON_TO_PED(m1Ped, weapon, 1000, false)
	PED.SET_PED_RELATIONSHIP_GROUP_HASH(m1Ped, GAMEPLAY.GET_HASH_KEY("PRIVATE_SECURITY"))
	ENTITY.SET_ENTITY_INVINCIBLE(m1Ped, false)
	STREAMING.SET_MODEL_AS_NO_LONGER_NEEDED(mechanic1)
	mechanic1Money = (GAMEPLAY.GET_RANDOM_INT_IN_RANGE(1000,10000))
	PED.SET_PED_MONEY(m1Ped, mechanic1Money)

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

	STREAMING.REQUEST_MODEL(repairman1)
	
	while(not STREAMING.HAS_MODEL_LOADED(repairman1)) do
		wait(50)
	end
	
	r1Ped = {}
	
	r1Ped[0] = PED.CREATE_PED(1, repairman1, 144.721, 323.832, 112.139, 186, true,true)
	PED.SET_PED_CAN_SWITCH_WEAPON(r1Ped[0], true)
	WEAPON.GIVE_DELAYED_WEAPON_TO_PED(r1Ped[0], weapon, 1000, false)
	PED.SET_PED_RELATIONSHIP_GROUP_HASH(r1Ped[0], GAMEPLAY.GET_HASH_KEY("PRIVATE_SECURITY"))
	ENTITY.SET_ENTITY_INVINCIBLE(r1Ped[0], false)
	
	r1Ped[1] = PED.CREATE_PED(1, repairman1, 147.084, 324.867, 112.139, 174, true,true)
	PED.SET_PED_CAN_SWITCH_WEAPON(r1Ped[1], true)
	WEAPON.GIVE_DELAYED_WEAPON_TO_PED(r1Ped[1], weapon, 1000, false)
	PED.SET_PED_RELATIONSHIP_GROUP_HASH(r1Ped[1], GAMEPLAY.GET_HASH_KEY("PRIVATE_SECURITY"))
	ENTITY.SET_ENTITY_INVINCIBLE(r1Ped[1], false)

	STREAMING.SET_MODEL_AS_NO_LONGER_NEEDED(repairman1)
	
end


------------------------------------------------------------------------------
return ArmoredPacksPap1Mod

-- Credits to: Alexander Blade & headscript--