Didn't want to start a new topic so i decided to post here.
I got another problem, I want to set the players blip to the color of the players team so i tried editing the playerblips resource to do that but the problem is it just sets the players blip to red and i dno why here's the code:
-- needs configurable blip colors, and team support
root = getRootElement ()
r, g, b = getTeamColor( getTeamFromName(getPlayerTeam( root )) ) -- i added this
color = { r, g, b } -- changed this
players = {}
resourceRoot = getResourceRootElement ( getThisResource () )
function onResourceStart ( resource )
for id, player in ipairs( getElementsByType ( "player" ) ) do
if ( players[player] ) then
createBlipAttachedTo ( player, 0, 2, color[r], color[g], color[b] )
else
createBlipAttachedTo ( player, 0, 2, color[r], color[g], color[b] )
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[r], color[g], color[b] ) --and this
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[r], color[g], color[b] ) -- and this
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