Jump to content

Colorblips


Resmurf

Recommended Posts

i wanna make blips for the team color

  
root = getRootElement () 
color = { 0, 255, 0 } 
players = {} 
resourceRoot = getResourceRootElement ( getThisResource () ) 
  
function onResourceStart ( resource ) 
    for id, player in ipairs( getElementsByType ( "player" ) ) do 
        if ( players[player] ) then 
            createBlipAttachedTo ( player, 0, 2, players[source][1], players[source][2], players[source][3] ) 
        else 
            createBlipAttachedTo ( player, 0, 2, color[1], color[2], color[3] ) 
        end 
    end 
end 
  
function onPlayerSpawn ( spawnpoint ) 
    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 
  
function onPlayerQuit () 
    destroyBlipsAttachedTo ( source ) 
end 
  
function onPlayerWasted ( totalammo, killer, killerweapon ) 
    destroyBlipsAttachedTo ( source ) 
end 
  
function setBlipsColor ( source, commandName, r, g, b ) 
    if ( tonumber ( b ) ) then 
        color = { tonumber ( r ), tonumber ( g ), tonumber ( b ) } 
        for id, player in ipairs( getElementsByType ( "player" ) ) do 
            destroyBlipsAttachedTo ( player ) 
            if ( players[player] ) then 
                createBlipAttachedTo ( player, 0, 2, players[source][1], players[source][2], players[source][3] ) 
            else 
                createBlipAttachedTo ( player, 0, 2, color[1], color[2], color[3] ) 
            end 
        end 
    end 
end 
  
function setBlipColor ( source, commandName, r, g, b ) 
    if ( tonumber ( b ) ) then 
        destroyBlipsAttachedTo ( source ) 
        players[source] = { tonumber ( r ), tonumber ( g ), tonumber ( b ) } 
        createBlipAttachedTo ( source, 0, 2, players[source][1], players[source][2], players[source][3] ) 
    end 
end 
  
addCommandHandler ( "setblipscolor", setBlipsColor ) 
addCommandHandler ( "setblipcolor", setBlipColor ) 
addEventHandler ( "onResourceStart", resourceRoot, onResourceStart ) 
addEventHandler ( "onPlayerSpawn", root, onPlayerSpawn ) 
addEventHandler ( "onPlayerQuit", root, onPlayerQuit ) 
addEventHandler ( "onPlayerWasted", root, onPlayerWasted ) 
  
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 

where should i put this code

local r,g,b = getTeamColor(getPlayerTeam" class="kw2">getPlayerTeam" class="kw2">getPlayerTeam" class="kw2">getPlayerTeam(player)) 
  

Link to comment

you want to make the players blip color as his team color if one exists right?

You can put this

function onResourceStart ( resource ) 
    for id, player in ipairs( getElementsByType ( "player" ) ) do 
        if getPlayerTeam1(player) ~= nil then 
             local r, g, b = getTeamColor(getPlayerTeam1(player)) 
              createBlipAttachedTo ( player, 0, 2, r,g,b ) 
         elseif ( players[player] ) then 
            createBlipAttachedTo ( player, 0, 2, players[source][1], players[source][2], players[source][3] ) 
        else 
            createBlipAttachedTo ( player, 0, 2, color[1], color[2], color[3] ) 
        end 
    end 
end 
  
function onPlayerSpawn ( spawnpoint ) 
     if getPlayerTeam1(player) ~= nil then 
             local r, g, b = getTeamColor(getPlayerTeam1(player)) 
              createBlipAttachedTo ( player, 0, 2, r,g,b ) 
     elseif ( 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 

you will find "1" near each getPlayerTeam remove it.

Link to comment

try this

function onResourceStart ( resource ) 
    for id, player in ipairs( getElementsByType ( "player" ) ) do 
        if getPlayerTeam1(player) ~= nil then 
             local r, g, b = getTeamColor(getPlayerTeam1(player)) 
              createBlipAttachedTo ( player, 0, 2, r,g,b ) 
       else 
             elseif ( players[player] ) then 
                 createBlipAttachedTo ( player, 0, 2, players[source][1], players[source][2], players[source][3] ) 
             else 
                 createBlipAttachedTo ( player, 0, 2, color[1], color[2], color[3] ) 
            end 
       end 
end 
  
function onPlayerSpawn ( spawnpoint ) 
     if getPlayerTeam1(player) ~= nil then 
             local r, g, b = getTeamColor(getPlayerTeam1(player)) 
              createBlipAttachedTo ( player, 0, 2, r,g,b ) 
     else 
         elseif ( 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 

Link to comment

Not working

Resource 'playerblips' changed, reloading and starting

[2011-06-12 12:24:23] Starting playerblips

[2011-06-12 12:24:23] SCRIPT ERROR: playerblips\playerblips.lua:7: 'end' expected (to close 'if' at line 3) near 'elseif'

[2011-06-12 12:24:23] WARNING: Loading script failed: playerblips\playerblips.lua:7: 'end' expected (to close 'if' at line 3) near 'elseif'

[2011-06-12 12:24:23] playerblips restarted successfully

Link to comment

Try this

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

Link to comment

[2011-06-12 12:36:45] SCRIPT ERROR: playerblips\playerblips.lua:3: 'then' expected near 'kw2'

[2011-06-12 12:36:45] WARNING: Loading script failed: playerblips\playerblips.lua:3: 'then' expected near 'kw2'

[2011-06-12 12:36:45] playerblips restarted successfully

Link to comment

ok I found the reason

try this:

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

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