TorNix~|nR Posted July 5, 2016 Posted July 5, 2016 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
TorNix~|nR Posted July 5, 2016 Author Posted July 5, 2016 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
Captain Cody Posted July 5, 2016 Posted July 5, 2016 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.
TorNix~|nR Posted July 5, 2016 Author Posted July 5, 2016 9: Bad argument @ 'createBlipAttachedTo' [Expected element at argument 1, got nil] --- Can I get your skype please ?
TorNix~|nR Posted July 5, 2016 Author Posted July 5, 2016 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
TorNix~|nR Posted July 5, 2016 Author Posted July 5, 2016 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)
DarkByte Posted July 5, 2016 Posted July 5, 2016 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
Ahmed Ly Posted July 5, 2016 Posted July 5, 2016 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 = ?
Ahmed Ly Posted July 5, 2016 Posted July 5, 2016 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)
DarkByte Posted July 5, 2016 Posted July 5, 2016 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
Dimos7 Posted July 5, 2016 Posted July 5, 2016 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
Captain Cody Posted July 5, 2016 Posted July 5, 2016 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.
Walid Posted July 5, 2016 Posted July 5, 2016 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) 1
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