Jump to content

Help me out with this small thing


Dentos

Recommended Posts

So i got this reosource for player blips that works but i want to make it so it restarts automaticly every 10 seconds i tried adding this but it dosent work

setTimer( addTeamBlip, 100,true )    

heres the script

local pBlips = { } 
  
addEventHandler("onResourceStart", resourceRoot, 
    function() 
        for index, player in ipairs(getElementsByType("player")) do 
            addTeamBlip(player) 
        end 
    end 
) 
  
function addTeamBlip(player) 
    if ( pBlips[player] ) then return false end -- Adding a prevention of duplicate blips 
    local theGang = getElementData ( player, "gang" ) 
    if ( theGang and theGang ~= "None" ) then 
       local r, g, b = getPlayerNametagColor( player ) 
       local theBlip = createBlipAttachedTo( player, 0, 2, 0, 255, 0 ) 
        -- Change visibility to only the team members 
        setElementVisibleTo( theBlip, root, false ) 
        for index, value in ipairs ( getPlayersByGang ( theGang ) ) do -- THIS 
            setElementVisibleTo( theBlip, value, true ) 
        end 
        pBlips[player] = theBlip 
    end 
end 
  
function destroyBlip(element) 
    local theElement = source or element 
    if ( theElement ) then 
        destroyElement(pBlips[theElement]) 
        pBlips[theElement] = nil -- Just in-case... 
    end 
end 
  
-- Events 
   
addEventHandler ( "onPlayerSpawn", root, addTeamBlip ) 
addEventHandler ( "onPlayerQuit", root, destroyBlip ) 
addEventHandler ( "onPlayerWasted", root, destroyBlip ) 
  
  
function getPlayersByGang ( gang ) 
    local players = { } 
    for _, player in ipairs ( getElementsByType ( "player" ) ) do 
        if ( getElementData ( player, "gang" ) == gang ) then 
            table.insert ( players, player ) 
        end 
    end 
  
    return players 
end 
  
setTimer( addTeamBlip, 100,true )   this------- 
  

Link to comment

try this

local pBlips = { } 
      
    addEventHandler("onResourceStart", resourceRoot, 
        function() 
            for index, player in ipairs(getElementsByType("player")) do 
                addTeamBlip(player) 
            end 
        end 
    ) 
      
    function addTeamBlip(player) 
        if ( pBlips[player] ) then return false end -- Adding a prevention of duplicate blips 
        local theGang = getElementData ( player, "gang" ) 
        if ( theGang and theGang ~= "None" ) then 
           local r, g, b = getPlayerNametagColor( player ) 
           local theBlip = createBlipAttachedTo( player, 0, 2, 0, 255, 0 ) 
            -- Change visibility to only the team members 
            setElementVisibleTo( theBlip, root, false ) 
            for index, value in ipairs ( getPlayersByGang ( theGang ) ) do -- THIS 
                setElementVisibleTo( theBlip, value, true ) 
            end 
            pBlips[player] = theBlip 
        end 
        
    setTimer ( function() 
        addTeamBlip() 
    end, 10000, 1 ) -- Change the time here  , every 1000 = 1 second 
  
    end 
      
    function destroyBlip(element) 
        local theElement = source or element 
        if ( theElement ) then 
            destroyElement(pBlips[theElement]) 
            pBlips[theElement] = nil -- Just in-case... 
        end 
    end 
      
    -- Events 
      
    addEventHandler ( "onPlayerSpawn", root, addTeamBlip ) 
    addEventHandler ( "onPlayerQuit", root, destroyBlip ) 
    addEventHandler ( "onPlayerWasted", root, destroyBlip ) 
      
      
    function getPlayersByGang ( gang ) 
        local players = { } 
        for _, player in ipairs ( getElementsByType ( "player" ) ) do 
            if ( getElementData ( player, "gang" ) == gang ) then 
                table.insert ( players, player ) 
            end 
        end 
      
        return players 
    end 

Link to comment

dosent work i got my hands on this script it works better but stop working when you reconnect they can see you but you cant see them in the map

  
local pBlips = { } 
  
    function blipsRestart() 
        for index, player in ipairs(getElementsByType("player")) do 
            addTeamBlip(player) 
        end 
    end 
setTimer(blipsRestart,10000,0) 
 addEventHandler("onResourceStart", resourceRoot, blipsRestart) 
  
function addTeamBlip(player) 
    if ( pBlips[player] ) then return false end -- Adding a prevention of duplicate blips 
    local theGang = getElementData ( player, "gang" ) 
    if ( theGang and theGang ~= "None" ) then 
       local r, g, b = getPlayerNametagColor( player ) 
       local theBlip = createBlipAttachedTo( player, 0, 2, 0, 255, 0 ) 
        -- Change visibility to only the team members 
        setElementVisibleTo( theBlip, root, false ) 
        for index, value in ipairs ( getPlayersByGang ( theGang ) ) do -- THIS 
            setElementVisibleTo( theBlip, value, true ) 
        end 
        pBlips[player] = theBlip 
    end 
end 
  
function destroyBlip(element) 
    local theElement = source or element 
    if ( theElement ) then 
        destroyElement(pBlips[theElement]) 
        pBlips[theElement] = nil -- Just in-case... 
    end 
end 
  
-- Events 
  
addEventHandler ( "onPlayerSpawn", root, addTeamBlip ) 
addEventHandler ( "onPlayerQuit", root, destroyBlip ) 
  
  
function getPlayersByGang ( gang ) 
    local players = { } 
    for _, player in ipairs ( getElementsByType ( "player" ) ) do 
        if ( getElementData ( player, "gang" ) == gang ) then 
            table.insert ( players, player ) 
        end 
    end 
  
    return players 
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...