proracer Posted January 30, 2011 Posted January 30, 2011 function teamBlipColor(source) local r,g,b local playerTeam = getPlayerTeam" class="kw2">getPlayerTeam(source) local attachedElements = getAttachedElements(source) if (attachedElements) then if (playerTeam) then for k,v in ipairs(attachedElements) do if getElementType(v) == "blip" then r,g,b = getTeamColor(playerTeam) setBlipColor(v, tonumber(r), tonumber(g), tonumber(b), 255) end end end end end addCommandHandler("teamcolor", teamBlipColor) It's meant for Race gamemode.No errors, does nothing.
MaddDogg Posted January 30, 2011 Posted January 30, 2011 What's that? local playerTeam = getPlayerTeam" class="kw2">getPlayerTeam" class="kw2">getPlayerTeam(source)
12p Posted January 30, 2011 Posted January 30, 2011 function teamBlipColor(source) local r,g,b playerTeam = getPlayerTeam" class="kw2">getPlayerTeam(source) local attachedElements = getAttachedElements(source) if attachedElements and playerTeam then for k,v in ipairs(attachedElements) do if getElementType(v) == "blip" then local r,g,b = getTeamColor(playerTeam) local setBlipColor(v, r, g, b, 255) end end end end addCommandHandler("teamcolor", teamBlipColor) What's that? local playerTeam = getPlayerTeam" class="kw2">getPlayerTeam" class="kw2">getPlayerTeam" class="kw2">getPlayerTeam" class="kw2">getPlayerTeam(source) Forum bug.
MaddDogg Posted January 30, 2011 Posted January 30, 2011 I guess this function is supposed to color all blips of players in the team color of the player? Did you check if the player is really in a team? Add some debug messages to check, where it stops. Also, I think getAttachedElements always returns a table. You should rather check, if the table has values in it, e.g.: if #attachedElements > 0 then
proracer Posted January 30, 2011 Author Posted January 30, 2011 Ok this is the last code. function teamBlipColor(source) local r,g,b playerTeam = getPlayerTeam" class="kw2">getPlayerTeam(source) local attachedElements = getAttachedElements(source) if attachedElements and playerTeam then for k,v in ipairs(attachedElements) do if getElementType(v) == "blip" then if #attachedElements > 0 then local r,g,b = getTeamColor(playerTeam) setBlipColor(v, r, g, b, 255) end end end end end addCommandHandler("teamcolor", teamBlipColor) It still does nothing and no errors.I will add some debug messages tommorow as I am tired now.If anyone see's where is the problem than please tell me
12p Posted January 30, 2011 Posted January 30, 2011 function teamBlipColor(source) playerTeam = getPlayerTeam" class="kw2">getPlayerTeam(source) local attachedElements = getAttachedElements(source) if attachedElements and #attachedElements > 0 and playerTeam then for k,v in ipairs(attachedElements) do outputChatBox("The No. "..tostring(k).." element is a "..getElementType(v)..".") if getElementType(v) == "blip" then local r,g,b = getTeamColor(playerTeam) setBlipColor(v, r, g, b, 255) outputChatBox ("Your blip set its color rightly!") end end end end addCommandHandler("teamcolor", teamBlipColor) You could use too: setElementID getElementByID
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