Jump to content

a question


darhal

Recommended Posts

There no function to create attached blip, but you can change the position of the blip:

You can get the position of the player:

getElementPosition 

Then set the position of the blip to the position of the player:

setCustomBlipPosition 

And in order for the blip to stay attached to the player continuously, you need to call this function with this event:

onClientRender

Link to comment

You can create a blip attached to a player, if you want to do that...

addCommandHandler ( "placehit", 
    function ( thePlayer, theCommand, hitPerson, hitPrice ) 
        if ( ( hitPerson ) and ( hitPrice ) ) then  
            if ( getPlayerFromName ( tostring ( hitPerson ) ) ) then 
                local blip = createBlipAttachedTo ( getPlayerFromName ( tostring ( hitPerson ) ), 41 ); 
                setElementData ( getPlayerFromName ( tostring ( hitPerson ) ), "hitprice", hitPrice ); 
                outputChatBox ( tostring ( hitPerson ) .."'s is now worth $".. hitPrice ); 
            else 
                outputChatBox ( "This player is not online.", thePlayer ); 
            end 
        else 
            outputChatBox ( "Wrong usage. example: /placehit billy 500", thePlayer ); 
        end 
    end 
); 

Edited by Guest
Link to comment

this exmple make all players have custom blip

local playerBlips = {} 
local image = "icon.png" 
  
addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource() ), 
    function () 
        for k, thePlayer in ipairs ( getElementsByType( "player" ) ) do 
            if not ( playerBlips[thePlayer] ) then 
                playerBlips[thePlayer] = exports.customblips:createCustomBlip ( 0, 0, 16, 16, image ) 
            end 
        end 
    end 
) 
  
addEventHandler( "onClientPlayerJoin", root, 
    function() 
        if not ( playerBlips[source] ) then 
            playerBlips[source] = exports.customblips:createCustomBlip ( 0,0, 16, 16, image ) 
        end 
    end 
) 
  
addEventHandler( "onClientRender", root, 
    function () 
        for thePlayer, theBlip in pairs( playerBlips ) do 
            if ( isElement( thePlayer ) ) and not ( thePlayer == localPlayer ) then 
                if ( theBlip ) then 
                    local x,y,z = getElementPosition( thePlayer ) 
                    exports.customblips:setCustomBlipPosition ( theBlip, x, y ) 
                end 
            end 
        end 
    end 
) 
  
addEventHandler("onClientPlayerQuit",root, 
    function () 
        if ( isElement( playerBlips[source] ) ) then 
            destroyElement( playerBlips[source] ) 
            playerBlips[source] = nil 
        end 
    end 
) 

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