Jump to content

Player blips


Recommended Posts

Posted

Hello everyone :)

I have a problem please anyone help me?

I create a player blips of team color, but there is an error has occurred

when I open F11, it starts much lag (FPS 5-10)

help?

Thanks :idea:

76561198387870432.png

ZI ZOMBIE INFECTION: mtasa://5.196.7.163:22003

560x95_FFFFFF_FF9900_000000_000000.png

Posted

function Blip ()

for id, PLAYERS in ipairs(getElementsByType("player")) do

local r, g, b = getTeamColor(getPlayerTeam(PLAYERS))

createBlipAttachedTo(PLAYERS, 0, 2, r, g, b)

end

end

setTimer(Blip, 5000, 0)

function quit ()

destroyBlipsAttachedTo(source)

end

addEventHandler("onPlayerQuit", getRootElement(), quit)

function dead (totalammo, killer, killerweapon)

destroyBlipsAttachedTo ( source )

end

addEventHandler("onPlayerWasted", getRootElement(), dead)

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

----

Thank you CodyL

76561198387870432.png

ZI ZOMBIE INFECTION: mtasa://5.196.7.163:22003

560x95_FFFFFF_FF9900_000000_000000.png

Posted
blips = {} 
  
function Blip () 
for id, player in ipairs(getElementsByType("player")) do 
local r, g, b = getTeamColor(getPlayerTeam(player)) 
if blips[player] then 
setBlipColor (blips[player],r, g, b,255) 
else 
blips[player] = createBlipAttachedTo(PLAYERS, 0, 2, r, g, b) 
end 
end 
end 
setTimer(Blip, 5000, 0) 
  
function quit () 
destroyElement(blips[source]) 
end 
addEventHandler("onPlayerQuit", getRootElement(), quit) 
  
function dead (totalammo, killer, killerweapon) 
destroyElement(blips[source]) 
end 
addEventHandler("onPlayerWasted", getRootElement(), dead) 
  

You were creating a new blip every 5 secounds. Causing alot of lag.

Wolf Inc Discord

Youtube channel
Github

Posted

9: Bad argument @ 'createBlipAttachedTo' [Expected element at argument 1, got nil]

---

Can I get your skype please :) ?

76561198387870432.png

ZI ZOMBIE INFECTION: mtasa://5.196.7.163:22003

560x95_FFFFFF_FF9900_000000_000000.png

Posted

sorry, that is my old script this is the new works but the problem in F11 (lag)

function Blip ()

for id, PLAYERS in ipairs(getElementsByType("player")) do

local r, g, b = getTeamColor(getPlayerTeam(PLAYERS))

createBlipAttachedTo(PLAYERS, 0, 2, r, g, b)

setTimer(Blip, 5000, 0)

end

end

Blip()

function quit ()

destroyBlipsAttachedTo(source)

end

addEventHandler("onPlayerQuit", getRootElement(), quit)

function dead (totalammo, killer, killerweapon)

destroyBlipsAttachedTo(source)

end

addEventHandler("onPlayerWasted", getRootElement(), dead)

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

76561198387870432.png

ZI ZOMBIE INFECTION: mtasa://5.196.7.163:22003

560x95_FFFFFF_FF9900_000000_000000.png

Posted
function Blip () 
for id, PLAYERS in ipairs(getElementsByType("player")) do 
local r, g, b = getTeamColor(getPlayerTeam(PLAYERS)) 
createBlipAttachedTo(PLAYERS, 0, 2, r, g, b) 
setTimer(Blip, 5000, 0) 
end 
end 
  
Blip() 
  
function quit () 
destroyBlipsAttachedTo(source) 
end 
addEventHandler("onPlayerQuit", getRootElement(), quit) 
  
function dead (totalammo, killer, killerweapon) 
destroyBlipsAttachedTo(source) 
end 
addEventHandler("onPlayerWasted", getRootElement(), dead) 
  
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  

Done, anyone help?

the problem: when I open F11 it starts lag (FPS 5-10)

76561198387870432.png

ZI ZOMBIE INFECTION: mtasa://5.196.7.163:22003

560x95_FFFFFF_FF9900_000000_000000.png

Posted
function blip () 
for id, thePlayer in ipairs(getElementsByType("player")) do 
local r, g, b = getTeamColor(getPlayerTeam(PLAYERS)) 
createBlipAttachedTo(thePlayer, 0, 2, r, g, b) 
end 
end 
  
addEventHandler("onPlayerJoin",root,blip) 
  
function quit () 
destroyBlipsAttachedTo(source) 
end 
addEventHandler("onPlayerQuit", getRootElement(), quit) 
  
  
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 

When I hear someone saying Mac is better than PC.

o0pjNKG.gif w0t?VeJXjxD.gifw0t? evspcFJ.gifw0t?

Great minds discuss ideas, average minds discuss events and small minds discuss people.

Posted
function blip () 
for id, thePlayer in ipairs(getElementsByType("player")) do 
local r, g, b = getTeamColor(getPlayerTeam(PLAYERS)) 
createBlipAttachedTo(thePlayer, 0, 2, r, g, b) 
end 
end 
  
addEventHandler("onPlayerJoin",root,blip) 
  
function quit () 
destroyBlipsAttachedTo(source) 
end 
addEventHandler("onPlayerQuit", getRootElement(), quit) 
  
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 

 PLAYERS = ?

76561198264399996.png

 

 

 

 

Posted
  
function blip1 () 
for id, thePlayer in ipairs(getElementsByType("player")) do 
local r, g, b = getTeamColor(getPlayerTeam(thePlayer)) 
createBlipAttachedTo(thePlayer,20,1,r,g,b) 
end 
end 
  
  
  
 blip1() 
  
  
 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 
  
function quit () 
destroyBlipsAttachedTo(source) 
end 
addEventHandler("onPlayerQuit", getRootElement(), quit) 
  

76561198264399996.png

 

 

 

 

Posted
function blip () 
for id, thePlayer in ipairs(getElementsByType("player")) do 
local r, g, b = getTeamColor(getPlayerTeam(PLAYERS)) 
createBlipAttachedTo(thePlayer, 0, 2, r, g, b) 
end 
end 
  
addEventHandler("onPlayerJoin",root,blip) 
  
function quit () 
destroyBlipsAttachedTo(source) 
end 
addEventHandler("onPlayerQuit", getRootElement(), quit) 
  
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 

 PLAYERS = ?

Are you blind? there is thePlayer

When I hear someone saying Mac is better than PC.

o0pjNKG.gif w0t?VeJXjxD.gifw0t? evspcFJ.gifw0t?

Great minds discuss ideas, average minds discuss events and small minds discuss people.

Posted
function Blip() 
   for _, v in ipairs(getElementsByType("player")) do 
       local r, g, b = getTeamColor(getPlayerTeam(v)) 
       createBlipAttachedTo(v, 0, 2, r, g, b) 
    end 
end 
setTimer(Blip, 5000, 0) 
  
function quit() 
    destoryBlipsAttachedTo(souce) 
end 
addEventHandler("onPlayerQuit", root, quit) 
  
function destoryBlipsAttachedTo(thePlayer) 
    local attached = getAttachedElements(thePlayer) 
    if (attached) then 
        for k, element in ipairs(attached) do 
            if getElementType(element)== "blip" then 
               destroyElement(element) 
            end 
        end 
    end 
end 

 

 

Posted

or or or or --

    blips = {} 
      
    function Blip () 
    for id, player in ipairs(getElementsByType("player")) do 
    local r, g, b = getTeamColor(getPlayerTeam(player)) 
    if blips[player] then 
    setBlipColor (blips[player],r, g, b,255) 
    else 
    blips[player] = createBlipAttachedTo(player, 0, 2, r, g, b) 
    end 
    end 
    end 
    setTimer(Blip, 5000, 0) 
      
    function quit () 
    destroyElement(blips[source]) 
    end 
    addEventHandler("onPlayerQuit", getRootElement(), quit) 
      
    function dead (totalammo, killer, killerweapon) 
    destroyElement(blips[source]) 
    end 
    addEventHandler("onPlayerWasted", getRootElement(), dead) 
      

Updates the color every 5.

I forgot to change PLAYERS to player. Small mistake, rest of the code should work perfectly from what I know.

Wolf Inc Discord

Youtube channel
Github

Posted

Try this

local blips = {} -- blips table 
      
function Blip () 
    local players = getElementsByType("player") 
    for id, player in ipairs(players) do 
        local team = getPlayerTeam(player) 
        if team then  
            local r, g, b = getTeamColor(team) 
            if blips[player] then 
                setBlipColor (blips[player],r, g, b,255) 
            else 
                blips[player] = createBlipAttachedTo(player, 0, 2, r, g, b) 
            end  
        end 
    end 
end 
setTimer(Blip, 5000, 0) 
      
-- destroy the blip (onPlayerQuit,onPlayerLogout,onPlayerWasted) 
function quit () 
    if blips[source] then -- if the blip exist then 
        destroyElement(blips[source]) -- destroy it 
        blips[source] = nil 
    end  
end 
addEventHandler("onPlayerLogout", getRootElement(), quit) 
addEventHandler("onPlayerQuit", getRootElement(), quit) 
addEventHandler("onPlayerWasted", getRootElement(), quit)  

  • Like 1

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

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