Jump to content

Need HELP!


Michcio

Recommended Posts

Hi! I have very good script but i need help.

-- Settings variables 
local textFont       = "default-bold"           -- The font of the tag text 
local textScale      = 1                        -- The scale of the tag text 
local heightPadding  = 1                        -- The amount of pixels the tag should be extended on either side of the vertical axis 
local widthPadding   = 1                        -- The amount of pixels the tag should be extended on either side of the horizontal axis 
local xOffset        = 8                        -- Distance between the player blip and the tag 
local minAlpha       = 10                       -- If blip alpha falls below this, the tag won't the shown 
local textAlpha      = 255 
local rectangleColor = tocolor(0,0,0,230) 
  
-- Other variables 
local floor          = math.floor 
local w,h            = guiGetScreenSize() 
  
local function drawMapStuff() 
    if isPlayerMapVisible() then 
         
        local sx,sy,ex,ey     = getPlayerMapBoundingBox()                           -- Map positions 
        local mw,mh           = ex-sx,sy-ey                                         -- Map width/height 
        local cx,cy           = (sx+ex)/2,(sy+ey)/2                                 -- Center position of the map 
        local ppuX,ppuY       = mw/6000,mh/6000                                     -- Pixels per unit 
        local fontHeight      = dxGetFontHeight(textScale,textFont)                 -- Height of the specified font 
        local yOffset         = fontHeight/2                                        -- How much pixels the tag should be offsetted at 
        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)                     -- Player's position 
                local x          = floor(cx+px*ppuX+xOffset)                        -- X for the nametag 
                local y          = floor(cy+py*ppuY-yOffset)                        -- Y for the nametag 
                local pname      = getPlayerName(attached)                          -- Player name 
                local nameLength = dxGetTextWidth(pname,textScale,textFont)         -- Width of the playername 
                local r,g,b      = getPlayerNametagColor(attached)                  -- Player's nametag color 
                local _,_,_,a    = getBlipColor(v)                                  -- Blip alpha 
                 
                if a>minAlpha then 
                     
                    dxDrawRectangle(x-widthPadding,y+heightPadding,nameLength+widthPadding*2,fontHeight-heightPadding*2,rectangleColor,false) 
                    dxDrawText(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) 

How to make unvisible on the map player in Police team? Help me!

Link to comment

like this?

-- Settings variables 
local textFont       = "default-bold"           -- The font of the tag text 
local textScale      = 1                        -- The scale of the tag text 
local heightPadding  = 1                        -- The amount of pixels the tag should be extended on either side of the vertical axis 
local widthPadding   = 1                        -- The amount of pixels the tag should be extended on either side of the horizontal axis 
local xOffset        = 8                        -- Distance between the player blip and the tag 
local minAlpha       = 10                       -- If blip alpha falls below this, the tag won't the shown 
local textAlpha      = 255 
local rectangleColor = tocolor(0,0,0,230) 
  
-- Other variables 
local floor          = math.floor 
local w,h            = guiGetScreenSize() 
  
local function drawMapStuff() 
    if isPlayerMapVisible() then 
        
        local sx,sy,ex,ey     = getPlayerMapBoundingBox()                           -- Map positions 
        local mw,mh           = ex-sx,sy-ey                                         -- Map width/height 
        local cx,cy           = (sx+ex)/2,(sy+ey)/2                                 -- Center position of the map 
        local ppuX,ppuY       = mw/6000,mh/6000                                     -- Pixels per unit 
        local fontHeight      = dxGetFontHeight(textScale,textFont)                 -- Height of the specified font 
        local yOffset         = fontHeight/2                                        -- How much pixels the tag should be offsetted at 
        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)                     -- Player's position 
                local x          = floor(cx+px*ppuX+xOffset)                        -- X for the nametag 
                local y          = floor(cy+py*ppuY-yOffset)                        -- Y for the nametag 
                local pname      = getPlayerName(attached)                          -- Player name 
                local nameLength = dxGetTextWidth(pname,textScale,textFont)         -- Width of the playername 
                local r,g,b      = getPlayerNametagColor(attached)                  -- Player's nametag color 
                local _,_,_,a    = getBlipColor(v)                                  -- Blip alpha 
                local team       = getPlayerTeam(attached)                          -- Player's team 
                 
                if a>minAlpha and getTeamName(team) ~= "Police" then 
                    
                    dxDrawRectangle(x-widthPadding,y+heightPadding,nameLength+widthPadding*2,fontHeight-heightPadding*2,rectangleColor,false) 
                    dxDrawText(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) 

Link to comment

Thanks, but how to make this unvisible?

-- needs configurable blip colors, and team support 
root = getRootElement () 
color = { 255, 255, 255 } 
players = {} 
resourceRoot = getResourceRootElement ( getThisResource () ) 
  
function onResourceStart ( resource ) 
    for id, player in ipairs( getElementsByType ( "player" ) ) do 
        if ( players[player] ) then 
            createBlipAttachedTo ( player, 0, 2, players[source][1], players[source][2], players[source][3] ) 
        else 
            createBlipAttachedTo ( player, 0, 2, color[1], color[2], color[3] ) 
        end 
    end 
end 
  
function onPlayerSpawn ( spawnpoint ) 
    if ( players[source] ) then 
        createBlipAttachedTo ( source, 0, 2, players[source][1], players[source][2], players[source][3] ) 
    else 
        createBlipAttachedTo ( source, 0, 2, color[1], color[2], color[3] ) 
    end 
end 
  
function onPlayerQuit () 
    destroyBlipsAttachedTo ( source ) 
end 
  
function onPlayerWasted ( totalammo, killer, killerweapon ) 
    destroyBlipsAttachedTo ( source ) 
end 
  
function setBlipsColor ( source, commandName, r, g, b ) 
    if ( tonumber ( b ) ) then 
        color = { tonumber ( r ), tonumber ( g ), tonumber ( b ) } 
        for id, player in ipairs( getElementsByType ( "player" ) ) do 
            destroyBlipsAttachedTo ( player ) 
            if ( players[player] ) then 
                createBlipAttachedTo ( player, 0, 2, players[source][1], players[source][2], players[source][3] ) 
            else 
                createBlipAttachedTo ( player, 0, 2, color[1], color[2], color[3] ) 
            end 
        end 
    end 
end 
  
function setBlipColor ( source, commandName, r, g, b ) 
    if ( tonumber ( b ) ) then 
        destroyBlipsAttachedTo ( source ) 
        players[source] = { tonumber ( r ), tonumber ( g ), tonumber ( b ) } 
        createBlipAttachedTo ( source, 0, 2, players[source][1], players[source][2], players[source][3] ) 
    end 
end 
  
addCommandHandler ( "setblipscolor", setBlipsColor ) 
addCommandHandler ( "setblipcolor", setBlipColor ) 
addEventHandler ( "onResourceStart", resourceRoot, onResourceStart ) 
addEventHandler ( "onPlayerSpawn", root, onPlayerSpawn ) 
addEventHandler ( "onPlayerQuit", root, onPlayerQuit ) 
addEventHandler ( "onPlayerWasted", root, onPlayerWasted )  
  
function destroyBlipsAttachedTo(player) 
    local attached = getAttachedElements ( player ) 
    if ( attached ) then 
        for k,element in ipairs(attached) do 
            if getElementType ( element ) == "blip" then 
                destroyElement ( element ) 
            end 
        end 
    end 
end      

please help me

Link to comment
dzek kolego jesteś z Polski? Proszę pomoż mi z tym. LUA trochę szkole ale nie mogę tego wykombinować do końca. Jak już coś mi wyjdzie to wtedy nie działa ten pierwszy skrypt. Pomóż.

Please send such messages via PM. This is an English forum and nobody will help you if they don't understand you.

Basically, don't attach blips to players who are in the Police team. Use getPlayerTeam and getTeamFromName and compare the teams.

Link to comment
dzek kolego jesteś z Polski? Proszę pomoż mi z tym. LUA trochę szkole ale nie mogę tego wykombinować do końca. Jak już coś mi wyjdzie to wtedy nie działa ten pierwszy skrypt. Pomóż.

Asking or even begging for help won't make anybody to help you faster. Just be patient. (oh, and personally - when somebody is nagging me for help (much ppl are) - im just ignoring, so try to aviod begging)

Link to comment
-- needs configurable blip colors, and team support 
root = getRootElement () 
color = { 255, 255, 255 } 
players = {} 
resourceRoot = getResourceRootElement ( getThisResource () ) 
police = getTeamFromName("Policja") 
swat = getTeamFromName("S.W.A.T.") 
team = getPlayerTeam(player) 
  
function onResourceStart ( resource ) 
    for id, player in ipairs( getElementsByType ( "player" ) ) do 
        if team ~= police and team ~= swat then 
            if ( players[player] ) then 
                createBlipAttachedTo ( player, 0, 2, players[source][1], players[source][2], players[source][3] ) 
            else 
                createBlipAttachedTo ( player, 0, 2, color[1], color[2], color[3] ) 
            end 
        end 
    end 
end 
  
function onPlayerSpawn ( spawnpoint ) 
    if team ~= police and team ~= swat then 
        if ( players[source] ) then 
            createBlipAttachedTo ( source, 0, 2, players[source][1], players[source][2], players[source][3] ) 
        else 
            createBlipAttachedTo ( source, 0, 2, color[1], color[2], color[3] ) 
        end 
    end 
end 
  
function onPlayerQuit () 
    destroyBlipsAttachedTo ( source ) 
end 
  
function onPlayerWasted ( totalammo, killer, killerweapon ) 
    destroyBlipsAttachedTo ( source ) 
end 
  
function setBlipsColor ( source, commandName, r, g, b ) 
    if ( tonumber ( b ) ) then 
        color = { tonumber ( r ), tonumber ( g ), tonumber ( b ) } 
        for id, player in ipairs( getElementsByType ( "player" ) ) do 
            destroyBlipsAttachedTo ( player ) 
            if ( players[player] ) then 
                createBlipAttachedTo ( player, 0, 2, players[source][1], players[source][2], players[source][3] ) 
            else 
                createBlipAttachedTo ( player, 0, 2, color[1], color[2], color[3] ) 
            end 
        end 
    end 
end 
  
function setBlipColor ( source, commandName, r, g, b ) 
    if ( tonumber ( b ) ) then 
        destroyBlipsAttachedTo ( source ) 
        players[source] = { tonumber ( r ), tonumber ( g ), tonumber ( b ) } 
        createBlipAttachedTo ( source, 0, 2, players[source][1], players[source][2], players[source][3] ) 
    end 
end 
  
addCommandHandler ( "setblipscolor", setBlipsColor ) 
addCommandHandler ( "setblipcolor", setBlipColor ) 
addEventHandler ( "onResourceStart", resourceRoot, onResourceStart ) 
addEventHandler ( "onPlayerSpawn", root, onPlayerSpawn ) 
addEventHandler ( "onPlayerQuit", root, onPlayerQuit ) 
addEventHandler ( "onPlayerWasted", root, onPlayerWasted )  
  
function destroyBlipsAttachedTo(player) 
    local attached = getAttachedElements ( player ) 
    if ( attached ) then 
        for k,element in ipairs(attached) do 
            if getElementType ( element ) == "blip" then 
                destroyElement ( element ) 
            end 
        end 
    end 
end      

Thats what i make. It doesn't work.

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