Jump to content

Playerblip F11


Bean666

Recommended Posts

hi guys . i have this function that a player can only see a player when a player is near, it works! but only in the GPS Not in the radar[F11]. it doesnt work in F11 . you can still see players far away with F11 , but with GPS you cant see them if they're far so is there any way to make this function happen in the radar[F11]? any help appreciated

local _createBlipAttachedTo = createBlipAttachedTo 
function createBlipAttachedTo(player, icon, size, r, g, b) 
    return _createBlipAttachedTo(player, icon, size, r, g, b, 255, 0, 100.0) 
end 

Edited by Guest
Link to comment

try this

Client Side

local playerBlips = {} 
local distance = 30 
  
addEventHandler("onClientResourceStart", resourceRoot, 
function() 
    for k, thePlayer in ipairs(getElementsByType("player")) do 
        if not (playerBlips[thePlayer]) and not (thePlayer == localPlayer) then 
        playerBlips[thePlayer] = createBlipAttachedTo(thePlayer, 0, 0) 
        end 
    end 
end) 
  
addEventHandler("onClientPlayerJoin", root, 
function() 
    if not (playerBlips[source]) and not (thePlayer == localPlayer) then 
        playerBlips[source] = createBlipAttachedTo(thePlayer, 0, 0) 
    end 
end) 
  
addEventHandler("onClientRender", root, 
function() 
    for thePlayer, theBlip in pairs(playerBlips) do 
        if (isElement(thePlayer)) and (isElement(theBlip)) and not (thePlayer == localPlayer) then 
            local R, G, B = getPlayerNametagColor(thePlayer) 
            local px, py, pz = getElementPosition(thePlayer) 
            local bx, by, bz = getElementPosition(theBlip) 
  
            setBlipColor(theBlip, R, G, B) 
            setBlipVisibleDistance(theBlip, distance) 
            if (getDistanceBetweenPoints3D(px, py, pz, bx, by, bz) >= distance) then 
                setBlipColor(theBlip, R, G, B, 0) 
            end 
        end 
    end 
end) 
  
addEventHandler("onClientPlayerQuit", root, 
function() 
    if (isElement(playerBlips[source])) then 
        destroyElement(playerBlips[source]) 
        playerBlips[source] = nil 
    end 
end) 

Link to comment

Try this

-- Server side 
local blip = {} 
  
function applyBlips() 
    for k, player in pairs( getElementsByType( "player" ) ) do 
        local r, g, b = getPlayerNametagColor( player ) 
        if isPedDead( player ) then return end 
        if not blip[ player ] then 
            blip[ player ] = createBlipAttachedTo( player, 0, 2, r, g, b, 255 ) 
        else 
            setBlipColor( blip[ player ], r, g, b, 255 ) 
        end 
    end 
end 
addEventHandler( "onResourceStart", resourceRoot, applyBlips ) 
setTimer( applyBlips, 500, 0 ) -- This is to account for team changes. 
  
function createBlips() 
    if ( source ) then player = source end 
    local r, g, b = getPlayerNametagColor( player ) 
    if not blip[ player ] then 
        blip[ player ] = createBlipAttachedTo( player, 0, 2, r, g, b, 255 ) 
    else 
        setBlipColor( blip[ player ], r, g, b, 255 ) 
    end 
end 
addEventHandler( "onPlayerSpawn", root, createBlips ) 
  
function destroyBlip() 
    if ( source ) then player = source end 
    if ( blip[ player ] and isElement( blip[ player ] ) ) then 
        destroyElement( blip[ player ] ) 
        blip[ player ] = nil 
    end 
end 
addEventHandler( "onPlayerQuit", root, destroyBlip ) 
  
function timedDestory() 
    setTimer( destroyBlip, 4000, 1, source ) 
end 
addEventHandler( "onPlayerWasted", root, timedDestory ) 
  

Link to comment
Why use getDistanceBetweenPoints2D? Just set the max blip distance to what you want in createBlipAttachedTo. That saves having to check if players are within a certain range of the source every second or so.
hi guys . i have this function that a player can only see a player when a player is near, it works! but only in the GPS Not in the radar[F11]. it doesnt work in F11 . you can still see players far away with F11 , but with GPS you cant see them if they're far so is there any way to make this function happen in the radar[F11]? any help appreciated

He said , the blips are still visible in F11.

Link to comment

Try this (client side)

local playerBlips = {} 
local distance = 30 
  
addEventHandler("onClientResourceStart", resourceRoot, 
function() 
    for k, thePlayer in ipairs(getElementsByType("player")) do 
        if not (playerBlips[thePlayer]) and not (thePlayer == localPlayer) then 
            playerBlips[thePlayer] = createBlipAttachedTo(thePlayer, 0, 0) 
        end 
    end 
end) 
  
addEventHandler("onClientPlayerJoin", root, 
function() 
    if not (playerBlips[source]) and not (source == localPlayer) then 
        playerBlips[source] = createBlipAttachedTo(source, 0, 0) 
    end 
end) 
  
addEventHandler("onClientRender", root, 
function() 
    for thePlayer, theBlip in pairs(playerBlips) do 
        if (isElement(thePlayer)) and (isElement(theBlip)) and not (thePlayer == localPlayer) then 
            local R, G, B = getPlayerNametagColor(thePlayer) 
            local px, py, pz = getElementPosition(thePlayer) 
            local bx, by, bz = getElementPosition(theBlip) 
  
            setBlipColor(theBlip, R, G, B, 255) 
            setBlipVisibleDistance(theBlip, distance) 
            if (getDistanceBetweenPoints3D(px, py, pz, bx, by, bz) >= distance) then 
                setBlipColor(theBlip, R, G, B, 0) 
            end 
        end 
    end 
end) 
  
addEventHandler("onClientPlayerQuit", root, 
function() 
    if (isElement(playerBlips[source])) then 
        destroyElement(playerBlips[source]) 
        playerBlips[source] = nil 
    end 
end) 

Edited by Guest
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...