Jump to content

Colorblips


Resmurf

Recommended Posts

i tested this,

this has no error:

function onResourceStart ( resource, source ) 
    for id, source in ipairs( getElementsByType ( "source" ) ) do 
        if getPlayerTeam" class="kw2">getPlayerTeam(source) ~= nil then 
             local r, g, b = getTeamColor(getPlayerTeam" class="kw2">getPlayerTeam(source)) 
              createBlipAttachedTo ( source, 0, 2, r,g,b ) 
       else 
             if ( players[source] ) then 
                 createBlipAttachedTo ( source, 0, 2, players[source][1], players[source][2], players[source][3] ) 
             else 
                 createBlipAttachedTo ( source, 0, 2, color[1], color[2], color[3] ) 
            end 
         end 
    end 
end 
  
function onPlayerSpawn ( spawnpoint ) 
     if getPlayerTeam" class="kw2">getPlayerTeam(source) ~= nil then 
             local r, g, b = getTeamColor(getPlayerTeam" class="kw2">getPlayerTeam(source)) 
              createBlipAttachedTo ( source, 0, 2, r,g,b ) 
     else 
         if ( players[source] ) then 
             createBlipAttachedTo ( source, 0, 2, players[source][1], players[source][2], players[source][3] ) 
        else 
             createBlipAttachedTo ( source, 0, 2, color[1], color[2], color[3] ) 
        end 
    end 
end 
  

Edited by Guest
Link to comment

ok here:

  
function onResourceStart ( resource, source ) 
    for id, source in ipairs( getElementsByType ( "source" ) ) do 
        if getPlayerTeam(source) ~= nil then 
             local r, g, b = getTeamColor(getPlayerTeam(source)) 
              createBlipAttachedTo ( source, 0, 2, r,g,b ) 
       else 
             if ( players[source] ) then 
                 createBlipAttachedTo ( source, 0, 2, players[source][1], players[source][2], players[source][3] ) 
             else 
                 createBlipAttachedTo ( source, 0, 2, color[1], color[2], color[3] ) 
            end 
         end 
    end 
end 
  
function onPlayerSpawn ( spawnpoint ) 
     if getPlayerTeam(source) ~= nil then 
             local r, g, b = getTeamColor(getPlayerTeam(source)) 
              createBlipAttachedTo ( source, 0, 2, r,g,b ) 
     else 
         if ( players[source] ) then 
             createBlipAttachedTo ( source, 0, 2, players[source][1], players[source][2], players[source][3] ) 
        else 
             createBlipAttachedTo ( source, 0, 2, color[1], color[2], color[3] ) 
        end 
    end 
end 
  

Link to comment

try this then:

  
addEventHandler ( "onClientResourceStart", getRootElement(getThisResource()), 
function( resource, source ) 
    for id, source in ipairs( getElementsByType ( "source" ) ) do 
        if getPlayerTeam(source) ~= nil then 
             local r, g, b = getTeamColor(getPlayerTeam(source)) 
              createBlipAttachedTo ( source, 0, 2, r,g,b ) 
       else 
             if ( players[source] ) then 
                 createBlipAttachedTo ( source, 0, 2, players[source][1], players[source][2], players[source][3] ) 
             else 
                 createBlipAttachedTo ( source, 0, 2, color[1], color[2], color[3] ) 
            end 
         end 
    end 
end) 
  
addEventHandler ( "onPlayerSpawn",getRootElement(), 
function( spawnpoint ) 
     if getPlayerTeam(source) ~= nil then 
             local r, g, b = getTeamColor(getPlayerTeam(source)) 
              createBlipAttachedTo ( source, 0, 2, r,g,b ) 
     else 
         if ( players[source] ) then 
             createBlipAttachedTo ( source, 0, 2, players[source][1], players[source][2], players[source][3] ) 
        else 
             createBlipAttachedTo ( source, 0, 2, color[1], color[2], color[3] ) 
        end 
    end 
end) 
  

I added the Event Handlers so when the resource start the blip is on the person, and when the player spawns it moves with them.

Link to comment

Your blips is created succesfully? , if so then , set a timer that will get the player name tag color and set the player blip to it like this: this script doesnt include creating the blip only change it's color so you must add it to your script.

playerTimer = {} 
addEventHandler('onResourceStart', resourceRoot, 
    function() 
        for i, v in ipairs(getElementsByType('player')) do 
                playerTimer[v] = setTimer(updatePlayerBlip, 1000, 0, v) 
        end 
    end 
) 
  
addEventHandler('onPlayerSpawn', root, 
    function() 
        function(source) 
            playerTimer[source] = setTimer(updatePlayerBlip, 1000, 0, source) 
        end 
    end 
) 
  
function getPlayerBlip(src) 
    if src then 
        local attached = getAttachedElements ( src ) 
        if ( attached ) then 
            for k,element in ipairs(attached) do 
                if getElementType ( element ) == "blip" then 
                    return element 
                end 
            end 
        end 
    end 
end 
  
function updatePlayerBlip(src) 
    if src then 
        if not isPedDead(src) then 
            if getPlayerBlip(src) then 
                local r, g, b = getPlayerNametagColor(src) 
                setBlipColor(getPlayerBlip(src), r, g, b, 255) 
            end 
        end 
    end 
end 
  
addEventHandler('onPlayerQuit', root, 
    function() 
                if isTimer(playerTimer[source]) then 
                   killTimer(playerTimer[source]) 
               end 
    end 
) 
  
addEventHandler('onPlayerWasted', root, 
    function() 
                if isTimer(playerTimer[source]) then 
                killTimer(playerTimer[source]) 
               end 
    end 
) 

And dont double post.

Link to comment
ok

Edit:

here:

  
addEventHandler ( "onPlayerJoin",getResource(getThisResource()), 
function() 
    spawnPlayer (client, x, y, z, 0, math.random (1,288), 0, 0, teamF) 
end) 
  

What is that? getResource(getThisResource()) ? I personally don't get what did you do here... :roll:

Maybe you meant, getResourceRootElement(getThisResource()) ?

Link to comment

I just notice I messed up

  
local x = POSITION OF PLAYER 
local y = POSITION OF PLAYER 
local z = POSITION OF PLAYER 
addEventHandler ( "onPlayerJoin",getRootElement(), 
function() 
    spawnPlayer (client, x, y, z, 0, math.random (0,288), 0, 0) 
end) 
  

Edited by Guest
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...