Dentos Posted September 27, 2014 Share Posted September 27, 2014 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
Anubhav Posted September 27, 2014 Share Posted September 27, 2014 (edited) setTimer( addTeamBlip, 10000, 0 ) Edited September 27, 2014 by Guest Link to comment
lcd1232 Posted September 27, 2014 Share Posted September 27, 2014 setTimer( addTeamBlip, 1000*10, 0 ) -- 1000 msec = 1 sec Link to comment
Saml1er Posted September 27, 2014 Share Posted September 27, 2014 That will not work. setTimer ( function() for index, player in ipairs(getElementsByType("player")) do addTeamBlip(player) end end,10000,0 ) Link to comment
mustang Posted September 27, 2014 Share Posted September 27, 2014 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
Dentos Posted September 28, 2014 Author Share Posted September 28, 2014 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now