Jump to content

[HELP] Show players on map


relaxx

Recommended Posts

local myBlip = {}
function showPlayers(source)
    myBlip = {}
    for k, v in ipairs(getElementsByType("player")) do
    if not(v == source and not getElementData(v, "Char->adminduty"))then
        local r,g,b = getTeamColor(getPlayerTeam(v))
        myBlip[v] = createBlipAttachedTo (v, 4,2,r,g,b,160)
    end
end
end
addEvent( "showAllPlayers", true )
addEventHandler( "showAllPlayers", resourceRoot, showPlayers )
  

 

When a player left the sever then his blip is stay on the map can someone help me?

Link to comment

You should use the code tag '<>' when displaying code in your post... Anywho, you want to destroy that blip when the player leaves the server:

-- serverside:
function PlayerQuit(quit,reason,element)
  destroyElement(myblip[source]) -- source is the player who is leaving the server for this event
  myblip[source]=nil -- Free up the memory the player was using for this variable
end

Also note, myBlip is already defined at the top of your script, therefore no need to define it again, you should remove line 3

local myBlip = {} -- Defines myBlip as a simple table
function showPlayers(source)
    myBlip = {} -- Not needed because it is already defined on line 1, you should remove this line altogether

 

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