Jump to content

[HelP]PlayerBlip allowed for all teams..


Recommended Posts

Hello , i just need to make Player blip for only 2 teams , Admins and Events Organization Zone , i tried local allowedTeam{} but not working , still working for all Players at F11 ,

 

local restrictedTeams = {
    ["Admins"] = true,
    ["Events Organization Zone"] = true
}

local textFont       = "default-bold"            
local textScale      = 1                
local heightPadding  = 1    
local widthPadding   = 1
local xOffset        = 8
local minAlpha       = 10
local textAlpha      = 255

local floor          = math.floor
local w,h            = guiGetScreenSize()

local function drawMapStuff()
    if (restrictedTeams[getTeamName(getPlayerTeam(getLocalPlayer()))] ~= nil) then
        if isPlayerMapVisible() then
            local sx,sy,ex,ey     = getPlayerMapBoundingBox()                    
            local mw,mh           = ex-sx,sy-ey                                        
            local cx,cy           = (sx+ex)/2,(sy+ey)/2                                
            local ppuX,ppuY       = mw/6000,mh/6000                                    
            local fontHeight      = dxGetFontHeight(textScale,textFont)                    
            local yOffset         = fontHeight/2                                        
            local blips           = getElementsByType("blip")
            
            for k,v in ipairs(blips) do
            
                local attached=getElementAttachedTo(v)
            
                if isElement(attached) and getElementType(attached)=="player" then
                
                    local px,py      = getElementPosition(attached)                    
                    local x          = floor(cx+px*ppuX+xOffset)                    
                    local y          = floor(cy+py*ppuY-yOffset)                    
                    local pname      = getPlayerName(attached)                        
                    local nameLength = dxGetTextWidth(pname,textScale,textFont)            
                    local r,g,b      = getPlayerNametagColor(attached)                    
                    local _,_,_,a    = getBlipColor(v)                            
                    
                    if a>minAlpha then
                        dxDrawBorderedText(pname,x,y,x+nameLength,y+fontHeight,tocolor(r,g,b,textAlpha),textScale,textFont,"left","top",false,false,false)
                    end
                end
            end
        end
    end
end
addEventHandler("onClientRender",getRootElement(),drawMapStuff)

function dxDrawBorderedText(text, left, top, right, bottom, color, scale, font, alignX, alignY, clip, wordBreak,postGUI) 
    for oX = -1, 1 do
        for oY = -1, 1 do
                dxDrawText(text, left + oX, top + oY, right + oX, bottom + oY, tocolor(0, 0, 0, 255), scale, font, alignX, alignY, clip, wordBreak,postGUI) 
        end 
    end 
    dxDrawText(text, left, top, right, bottom, color, scale, font, alignX, alignY, clip, wordBreak, postGUI) 
end 

Edited by omar0101565111
Link to comment
  • 2 months later...

It's from mapnames resource Afaik.

This resource has nothing to do with blips, with that you will only be able to modify the dx with player's name on the F11 map.

Edit: If you mean the dx player's name, try this:


local restrictedTeams = {
    ["Admins"] = true,
    ["Events Organization Zone"] = true
}

local textFont       = "default-bold"            
local textScale      = 1                
local heightPadding  = 1    
local widthPadding   = 1
local xOffset        = 8
local minAlpha       = 10
local textAlpha      = 255

local floor          = math.floor
local w,h            = guiGetScreenSize()

local function drawMapStuff()
        if isPlayerMapVisible() then
            local sx,sy,ex,ey     = getPlayerMapBoundingBox()                    
            local mw,mh           = ex-sx,sy-ey                                        
            local cx,cy           = (sx+ex)/2,(sy+ey)/2                                
            local ppuX,ppuY       = mw/6000,mh/6000                                    
            local fontHeight      = dxGetFontHeight(textScale,textFont)                    
            local yOffset         = fontHeight/2                                        
            local blips           = getElementsByType("blip")
            
            for k,v in ipairs(blips) do
            
                local attached=getElementAttachedTo(v)
            
			if isElement(attached) and getElementType(attached)=="player" and canDrawForPlayer( attached ) then

				local px,py      = getElementPosition(attached)                    
				local x          = floor(cx+px*ppuX+xOffset)                    
				local y          = floor(cy+py*ppuY-yOffset)                    
				local pname      = getPlayerName(attached)                        
				local nameLength = dxGetTextWidth(pname,textScale,textFont)            
				local r,g,b      = getPlayerNametagColor(attached)                    
				local _,_,_,a    = getBlipColor(v)                            

				if a>minAlpha then
					dxDrawBorderedText(pname,x,y,x+nameLength,y+fontHeight,tocolor(r,g,b,textAlpha),textScale,textFont,"left","top",false,false,false)
				end
			end
		end
	end
end
addEventHandler("onClientRender",getRootElement(),drawMapStuff)

function canDrawForPlayer( player )
	if isElement(player) and getElementType(player) == "player" and getPlayerTeam(player) then
		return restrictedTeams[ getTeamName(getPlayerTeam(player)) ]
	end
	return false
end

function dxDrawBorderedText(text, left, top, right, bottom, color, scale, font, alignX, alignY, clip, wordBreak,postGUI) 
    for oX = -1, 1 do
        for oY = -1, 1 do
                dxDrawText(text, left + oX, top + oY, right + oX, bottom + oY, tocolor(0, 0, 0, 255), scale, font, alignX, alignY, clip, wordBreak,postGUI) 
        end 
    end 
    dxDrawText(text, left, top, right, bottom, color, scale, font, alignX, alignY, clip, wordBreak, postGUI) 
end 

 

Edited by DNL291
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...