Jump to content

Minimap


Cadu12

Recommended Posts

I have one problem, when map started and doesnt set to all players colors

There is script:

  
addEvent("onMapStarting", true) 
  
function MapStarted() 
    for id, player in ipairs(getElementsByType("player")) do 
        playerTeam = getPlayerTeam" class="kw2">getPlayerTeam(player) 
        local attachedElements = getAttachedElements(player) 
        if attachedElements and #attachedElements > 0 and playerTeam then 
            for k,v in ipairs(attachedElements) do 
                if getElementType(v) == "blip" then 
                    local r,g,b = getTeamColor(playerTeam)       
                    setBlipColor(v, r, g, b, 255) 
                    setBlipSize ( v, 4 ) -- THIS IS ONLY FOR TEST! 
                end 
            end 
        end 
    end 
end 
addEventHandler("onMapStarting", getRootElement(), MapStarted) 
  

Link to comment

Hi,

I think your problem is here:

  
if attachedElements and #attachedElements > 0 and playerTeam then 
  

Is it possible that players, at the map starting, have no blip or no team ?

try to output a message if the test return false

  
 addEvent("onMapStarting", true) 
   
 function MapStarted() 
     for id, player in ipairs(getElementsByType("player")) do 
         playerTeam = getPlayerTeam" class="kw2">getPlayerTeam(player) 
         local attachedElements = getAttachedElements(player) 
         if attachedElements and #attachedElements > 0 and playerTeam then 
              outputChatBox( "Player "..getPlayerName( player ).." have attached elements and team ! " ) 
             for k,v in ipairs(attachedElements) do 
                 if getElementType(v) == "blip" then 
                     local r,g,b = getTeamColor(playerTeam)       
                     setBlipColor(v, r, g, b, 255) 
                     setBlipSize ( v, 4 ) -- THIS IS ONLY FOR TEST! 
                 end           
             end 
         else 
              outputChatBox( "Player "..getPlayerName( player ).." have no attached elements or no team ! " ) 
         end 
     end 
 end 
 addEventHandler("onMapStarting", getRootElement(), MapStarted) 
  
  
  

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...