Dentos Posted September 29, 2014 Share Posted September 29, 2014 So I got resource that allows you to see only your clan members in map and viceversa but theres a little problem with it -I start resource and it works fine -I reconnect -The people in my gang can still see me but i cant see them -someone reconnects in my gang I start seeing only one reconnected and not rest and the one reconnected cant see anyone until someone reconnects heres the script been stuck on this for almost a month 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 blipJoin() addTeamBlip(source) end addEventHandler("onPlayerJoin",getRootElement(),blipJoin) 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
Anubhav Posted September 29, 2014 Share Posted September 29, 2014 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 blipJoin() addTeamBlip(source) end addEventHandler("onPlayerLogin",getRootElement(),blipJoin) 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
Dentos Posted September 29, 2014 Author Share Posted September 29, 2014 tried it and still the same dont mean offend or anything but either im blind or you didnt change anything (sorry if im mistaken) Link to comment
Saml1er Posted September 29, 2014 Share Posted September 29, 2014 local function blipJoin() addTeamBlip(source) for i,v in pairs (pBlips) do if i ~= source then setElementVisibleTo (v,source,true) end end end addEventHandler("onPlayerLogin",getRootElement(),blipJoin) 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