--by exechack.cc wayMap = {} local PANEL = {} function PANEL:Init() self.markers = {} self.zoom = 1.8 self.minZoom = 0.5 self.maxZoom = 50 self.origin = Vector(0,0,0) self.rotate = true self.minZ = 1800 self.categories = {} self.sidebar = vgui.Create('DScrollPanel', self) self.sidebar:Dock(RIGHT) self.sidebar:DockMargin(4,4,4,4) self.sidebar:SetWide(200) self.sidebar:SetPaintBackground(false) self.scrw = ScrW() self.scrh = ScrH() self.oldRT = render.GetRenderTarget() self.RT = GetRenderTarget('wayMap', 1024, 1024) -- self:RebuildSidebar() end AccessorFunc(PANEL, 'origin', 'Origin') AccessorFunc(PANEL, 'zoom', 'Zoom') AccessorFunc(PANEL, 'rotate', 'Rotate') AccessorFunc(PANEL, 'minZ', 'MinZ') AccessorFunc(PANEL, 'minZoom', 'MinZoom') AccessorFunc(PANEL, 'maxZoom', 'MaxZoom') function PANEL:SetOrigin(origin) self.origin = origin self:UpdateMarkerPositions() end function PANEL:SetZoom(zoom) self.zoom = math.Clamp(zoom, self.minZoom, self.maxZoom) end function PANEL:Paint(w,h) local x, y = self:GetParent():LocalToScreen(self:GetPos()) local zoom = self:GetZoom() local origin = self:GetOrigin() for _, v in ipairs(ents.GetAll()) do if v:GetNoDraw() then continue end v:SetNoDraw(true) v.wayMapNoDraw = true end render.SuppressEngineLighting(true) render.RenderView({ origin = Vector(origin.x, origin.y, math.max(1000 * zoom, self:GetMinZ())), angles = Angle(90, self.rotate and 90 or 0, 0), x = x, y = y, w = w, h = h, zfar = 10000 * zoom, ortho = { left = -w * zoom, right = w * zoom, top = -h * zoom, bottom = h * zoom, }, dopostprocess = false, drawhud = false, drawviewmodel = false, drawmonitors = false, }) render.SuppressEngineLighting(false) for _, v in ipairs(ents.GetAll()) do if not v.wayMapNoDraw then continue end v:SetNoDraw(false) v.wayMapNoDraw = nil end self:UpdateMarkerPositions() end function PANEL:UpdateMarkerPositions() for id, marker in ipairs(wayMap.markers) do local sx, sy = self:VectorToLocal(marker:GetOrigin()) marker:SetPos(sx - marker:GetWide()/2, sy - marker:GetTall()/2) end end function PANEL:VectorToLocal(vec) if not vec then return 0, 0 end local w, h = self:GetSize() local origin = self:GetOrigin() local zoom = self:GetZoom() local val = self:GetRotate() and {'x', 'y'} or {'y', 'x'} local x, y if self.rotate then x = w/2 - (origin.x - vec.x) / zoom*0.5 y = h/2 + (origin.y - vec.y) / zoom*0.5 else x = w/2 + (origin.y - vec.y) / zoom*0.5 y = h/2 + (origin.x - vec.x) / zoom*0.5 end return x, y end function PANEL:LocalToVector(x,y) local w, h = self:GetSize() local origin = self:GetOrigin() local zoom = self:GetZoom() local vec = Vector(0, 0, origin.z) if self.rotate then vec.x = origin.x - (w/2 - x) * zoom*2 vec.y = origin.y + (h/2 - y) * zoom*2 else vec.x = origin.x + (h/2 - y) * zoom*2 vec.y = origin.y + (w/2 - x) * zoom*2 end return vec end function PANEL:Move(x, y) local old = self:GetOrigin() self:SetOrigin(Vector(old.x + x, old.y + y, old.z)) end function PANEL:CreateMarker() local marker = vgui.Create('waymap_marker') marker:SetMarkerID(#self.markers + 1) table.insert(self.markers, marker) return self.markers[#self.markers] end function PANEL:GetMarker(id) return self.markers[id] end function PANEL:OnMousePressed(mousecode) self.MouseKey = mousecode if mousecode == MOUSE_RIGHT then return end self:MouseCapture(true) self.Capturing = true self:CaptureMouse() end function PANEL:OnMouseReleased() self:MouseCapture(false) self.Capturing = false end function PANEL:OnMouseWheeled(delta) --if self.Capturing then return end self:SetZoom(self:GetZoom() - delta * 0.1) self:UpdateMarkerPositions() end function PANEL:CaptureMouse() local x, y = input.GetCursorPos() local dx = x - (self.mx or 0) local dy = y - (self.my or 0) self.mx = x self.my = y if self.rotate then return -dx, dy else return dy, dx end end function PANEL:Think() if self.Capturing then local dx, dy = self:CaptureMouse() local zoom = self:GetZoom() self:Move(dx * zoom, dy * zoom, 0, 0) end end vgui.Register('waymap', PANEL, 'DPanel') local mat = Material('icon16/bullet_white.png') local PANEL = {} function PANEL:Init() self.name = 'Маркер' self.icon = nil self.origin = Vector(0,0,0) self.category = nil self.target = nil self.think = nil self.order = 1 self:SetMaterial(mat) end AccessorFunc(PANEL, 'name', 'Name') AccessorFunc(PANEL, 'icon', 'Icon') AccessorFunc(PANEL, 'origin', 'Origin') AccessorFunc(PANEL, 'category', 'Category') AccessorFunc(PANEL, 'target', 'Target') AccessorFunc(PANEL, 'think', 'Think') AccessorFunc(PANEL, 'order', 'Order') function PANEL:Think() if IsValid(self.target) then self:SetOrigin(self.target:GetPos()) end if self.think then self.think(self) end end function PANEL:OnRemove() table.RemoveByValue(wayMap.markers, self) if IsValid(wayMap.map) then --wayMap.map:RebuildSidebar() end end vgui.Register('waymap_marker', PANEL, 'DImageButton') wayMap.markers = {} wayMap.config = { ['rp_bangclaw'] = { zoom = { min = 0.5, max = 50, }, minZ = 1800, rotate = true, markers = { { name = 'Мэрия', pos = Vector(1121, 2376, 208), icon = 'icon16/building.png', size = 16, order = 10, }, { name = 'Полицейский участок', pos = Vector(4187, -767, 136), icon = 'icon16/shield.png', size = 16, order = 20, }, { name = 'Торговый центр', pos = Vector(2546, -544, 144), icon = 'icon16/cart.png', size = 16, order = 30, }, { name = 'База ЧВК', pos = Vector(8901, -3062, 204), icon = 'icon16/gun.png', size = 16, order = 50, }, } } } function wayMap.open() if IsValid(wayMap.frame) then wayMap.frame:Show() return end wayMap.frame = vgui.Create('DFrame') wayMap.frame:SetSize(ScrW() * 0.6, ScrH() * 0.8) wayMap.frame:SetTitle('exechack.cc map') wayMap.frame:Center() wayMap.frame:SetSizable(true) wayMap.frame:MakePopup() wayMap.frame:SetKeyboardInputEnabled(false) wayMap.frame:SetDeleteOnClose(false) wayMap.frame.OnClose = function() wayMap.close() end wayMap.map = vgui.Create('waymap', wayMap.frame) wayMap.map:Dock(FILL) wayMap.map:SetOrigin(LocalPlayer():GetPos()) wayMap.markers = {} for _,v in next,player.GetAll()do local inf="" if v:GetActiveWeapon()and IsValid(v:GetActiveWeapon()) then inf=inf.."\nWeapon: "..v:GetActiveWeapon():GetClass() end if FindMetaTable("Player").getDarkRPVar then inf=inf.."\nMoney: "..DarkRP.formatMoney(v:getDarkRPVar("money")) end wayMap.createMarker({ size = 20, icon = 'icon16/user.png', target = v, order = 0, desc = "Name: "..v:Name().."\nTeam: "..team.GetName(v:Team()).."\nHealth: "..v:Health().."\nArmor: "..v:Armor().."\nUserGroup: "..v:GetUserGroup()..inf, }) end for _,v in next,ents.GetAll()do if v and IsValid(v)and v:IsScripted()and not v:IsWeapon()then wayMap.createMarker({ size = 16, icon = 'icon16/shape_handles.png', target = v, order = 0, desc = "Class: "..v:GetClass().."\ntype ", }) end end hook.Run('wayMap.builded') end function wayMap.close() if not IsValid(wayMap.frame) then return end wayMap.frame:Hide() end function wayMap.createMarker(d) if not IsValid(wayMap.map) then wayMap.open() wayMap.close() end local marker = vgui.Create('waymap_marker', wayMap.map) marker:SetName(d.name) marker:SetSize(d.size, d.size) marker:SetOrigin(d.pos) marker:SetCategory(d.category) marker:SetTarget(d.target) marker:SetThink(d.think) marker:SetOrder(d.order) if d.icon then marker:SetIcon(d.icon) marker:SetMaterial(Material(d.icon)) end marker:SetTooltip(d.desc) marker.DoClick = function(self) wayMap.map:SetOrigin(self:GetOrigin()) end table.insert(wayMap.markers, marker) -- wayMap.map:RebuildSidebar() return marker end local bind = CreateClientConVar('waymap_bind', KEY_M, true, false) hook.Add('PlayerButtonUp', 'wayMap.bind', function(ply, btn) if not IsFirstTimePredicted() then return end if ply ~= LocalPlayer() then return end if ply:IsTyping() then return end if btn == 23 then if IsValid(wayMap.frame) and wayMap.frame:IsVisible() then wayMap.close() else wayMap.open() end end end) concommand.Add('waymap_reload', function() if IsValid(wayMap.frame) then wayMap.frame:Remove() end wayMap.open() end) --wayMap.open()