--==============================================
--    Get Info Mod by Ideo

--  Press : numpad / to Enable/Disable the mod
--  AIM a target to get information
--==============================================


local GetInfo = {}


function GetInfo.unload()
end
function GetInfo.init()

GetInfo_Enabled = false
GetInfoCheckpoint = 0
GetInfoCheckpoint2 = 0
GetInfoIsObject = 1
GetInfo_AIM_ENTITY = 0
GetInfo_AIM_ENTITY2 = 0
GetInfo_Notif = {}

GetInfo_Notif_i = 1
end

function GetInfo.tick()

	
	if(get_key_pressed(Keys.Divide))then
AUDIO.PLAY_SOUND_FRONTEND(-1, "Hit_out", "PLAYER_SWITCH_CUSTOM_SOUNDSET", true)
		GetInfo_Enabled = not GetInfo_Enabled
		GRAPHICS.DELETE_CHECKPOINT(GetInfoCheckpoint)
		GRAPHICS.DELETE_CHECKPOINT(GetInfoCheckpoint2)
		if (GetInfo_Enabled) then
			GetInfo.DrawText("~y~Get Info Mod ~n~~s~by ~r~Ideo~s~ ~n~ ~b~Enabled")
		else
			GetInfo.DrawText("Get Info Mod ~n~by ~r~Ideo~s~ ~n~ ~b~Disabled")
		end
		wait (500)	
		
	end
	

	

	if (GetInfo_Enabled) then
	

		
		local IsTargettingEntity, TargetEntity = PLAYER._GET_AIMED_ENTITY( PLAYER.PLAYER_ID(),0)
		local TypeEntity = ENTITY.GET_ENTITY_TYPE(TargetEntity)
		local location = ENTITY.GET_ENTITY_COORDS(TargetEntity, nil)

		GetInfo.Chechpoint()

		
		if (EntityTemp == TargetEntity) then
			SameObject = true
		end
		if (IsTargettingEntity and not SameObject) then
		GRAPHICS.DELETE_CHECKPOINT(GetInfoCheckpoint2)
		
		for k,v in pairs(GetInfo_Notif) do 
			UI._REMOVE_NOTIFICATION(GetInfo_Notif[k])
		end

			GetInfo_Notif_i = 1
		
			local model = ENTITY.GET_ENTITY_MODEL(TargetEntity)
			
			if (ENTITY.IS_ENTITY_A_PED(TargetEntity)) then
			AUDIO.PLAY_SOUND_FRONTEND(-1, "Hit_out", "PLAYER_SWITCH_CUSTOM_SOUNDSET", true)
			
				local vehicle = PED.GET_VEHICLE_PED_IS_IN(TargetEntity, false)
				local Vmodel = ENTITY.GET_ENTITY_MODEL(vehicle)
				if(Vmodel == 0) then
				GetInfoIsObject = 1
				GetInfo_AIM_ENTITY = TargetEntity
					
					GetInfo.DrawText("Type : ~y~PED~s~ ~n~PED ID : ~r~" .. TargetEntity .. "~s~ ~n~Ped Hash : ~g~" .. model)
					print("_________________")
					print("Ped Hash :" .. model)
					print("-----------------")
					--wait(500)
				else
				GetInfoIsObject = 4
				GetInfo_AIM_ENTITY = TargetEntity
				GetInfo_AIM_ENTITY2 = vehicle
					
					GetInfo.DrawText("Type : ~y~PED + VEHICLE~s~ ~n~PED ID : ~r~" .. TargetEntity .. "~s~ ~n~Ped Hash : ~g~" .. model)	
					GetInfo.DrawText("VEHICLE ID : ~r~" .. vehicle .. "~s~ ~n~Vehicle Hash : ~g~" .. Vmodel)
					print("_________________")
					print("Ped Hash :" .. model)
					print("Vehicle Hash :" .. Vmodel)
					print("-----------------")
					--wait(500)
				end

			--wait(500)
			elseif (ENTITY.IS_ENTITY_A_VEHICLE(TargetEntity)) then
			AUDIO.PLAY_SOUND_FRONTEND(-1, "Hit_out", "PLAYER_SWITCH_CUSTOM_SOUNDSET", true)
			
			GetInfoIsObject = 2
			GetInfo_AIM_ENTITY = TargetEntity
			
				GetInfo.DrawText("Type : ~y~VEHICLE~s~ ~n~VEHICLE ID : ~r~" .. TargetEntity .. "~s~ ~n~Vehicle Hash : ~g~" .. model)
				print("_________________")
				print("Vehicle Hash :" .. model)
				print("-----------------")
				
			elseif (ENTITY.IS_ENTITY_AN_OBJECT(TargetEntity)) then
			AUDIO.PLAY_SOUND_FRONTEND(-1, "Hit_out", "PLAYER_SWITCH_CUSTOM_SOUNDSET", true)
			
			GetInfoIsObject = 3
			GetInfo_AIM_ENTITY = TargetEntity
				
				GetInfo.DrawText("Type : ~y~OBJECT~s~ ~n~ID : ~r~" .. TargetEntity .. "~s~ ~n~Hash : ~g~" .. model)		
				GetInfo.DrawText("Location of ~r~" .. TargetEntity .. "~s~~n~X : ~b~" .. GetInfo.round(location.x,6) .. "~s~ ~n~ Y : ~b~" .. GetInfo.round(location.y,6) .. "~s~ ~n~ Z : ~b~" .. GetInfo.round(location.z,6))
				print("_________________")
				print("Object ID :" .. TargetEntity)
				print("Object Hash :" .. model)
				print("----Location-----")
				print("X =" .. location.x)
				print("Y =" .. location.y)
				print("Z =" .. location.z)
				print("-----------------")	
				--wait(500)
			end

		else
			--print("no Entity")
		end
		if (TargetEntity ~= 0) then
			EntityTemp = TargetEntity
		end
		SameObject = false
	end
	
end



function GetInfo.round(num, idp)
  return tonumber(string.format("%." .. (idp or 0) .. "f", num))
end


--==================================================================================================================================================
--															DRAW TEXT FUNCTION
--==================================================================================================================================================	
function GetInfo.DrawText(Text)
	UI._SET_NOTIFICATION_TEXT_ENTRY("STRING")
	UI._ADD_TEXT_COMPONENT_STRING(Text)
	GetInfo_Notif[GetInfo_Notif_i] = UI._DRAW_NOTIFICATION(false, true)
	GetInfo_Notif_i = GetInfo_Notif_i + 1
end
--==================================================================================================================================================


--==================================================================================================================================================
--															DRAW TEXT FUNCTION
--==================================================================================================================================================	
function GetInfo.Chechpoint()


	local location = ENTITY.GET_ENTITY_COORDS(GetInfo_AIM_ENTITY, nil)
	local location2 = ENTITY.GET_ENTITY_COORDS(GetInfo_AIM_ENTITY2, nil)
	GRAPHICS.DELETE_CHECKPOINT(GetInfoCheckpoint)	
	GRAPHICS.DELETE_CHECKPOINT(GetInfoCheckpoint2)
	if (GetInfoIsObject == 1) then
		GetInfoCheckpoint = GRAPHICS.CREATE_CHECKPOINT(45, location.x, location.y, location.z-1, location.x, location.y, location.z - 1, 1, 0, 0, 255, 255, 0)
		GRAPHICS.SET_CHECKPOINT_CYLINDER_HEIGHT(GetInfoCheckpoint, 3, 3, 3)		
	elseif (GetInfoIsObject == 2) then
		GetInfoCheckpoint = GRAPHICS.CREATE_CHECKPOINT(45, location.x, location.y, location.z-1, location.x, location.y, location.z - 1, 5, 0, 255, 0, 255, 0)
		GRAPHICS.SET_CHECKPOINT_CYLINDER_HEIGHT(GetInfoCheckpoint, 2, 2, 2)		
	elseif (GetInfoIsObject == 3) then
		GetInfoCheckpoint = GRAPHICS.CREATE_CHECKPOINT(45, location.x, location.y, location.z, location.x, location.y, location.z, 3, 255, 0, 0, 255, 0)
		GRAPHICS.SET_CHECKPOINT_CYLINDER_HEIGHT(GetInfoCheckpoint, 1, 1, 1)	
	elseif (GetInfoIsObject == 4) then
		GetInfoCheckpoint = GRAPHICS.CREATE_CHECKPOINT(45, location.x, location.y, location.z-1, location.x, location.y, location.z - 1, 1, 0, 0, 255, 255, 0)
		GRAPHICS.SET_CHECKPOINT_CYLINDER_HEIGHT(GetInfoCheckpoint, 3, 3, 3)	
		GetInfoCheckpoint2 = GRAPHICS.CREATE_CHECKPOINT(45, location2.x, location2.y, location2.z-1, location2.x, location2.y, location2.z - 1, 5, 0, 255, 0, 255, 0)
		GRAPHICS.SET_CHECKPOINT_CYLINDER_HEIGHT(GetInfoCheckpoint2, 2, 2, 2)	
	end		
	


end
--==================================================================================================================================================


return GetInfo