xeon17 Posted February 4, 2014 Share Posted February 4, 2014 Hello , i have problem with the PlayerBlips script , it always show player blip color as green i no have idea how to fix it The player color is his team color or white if he not have team ( on killermessages , scoreboard , chat ) but on the radar always green. Any help or how i can fix it ? -- needs configurable blip colors, and team support 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 Link to comment
Anubhav Posted February 4, 2014 Share Posted February 4, 2014 root = getRootElement () color = { 255, 255, 255 } 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 White colour... Link to comment
xeon17 Posted February 4, 2014 Author Share Posted February 4, 2014 What if player have a team ? it will show him still white color. Link to comment
Anubhav Posted February 4, 2014 Share Posted February 4, 2014 It will show to all players white afaik. Link to comment
DNL291 Posted February 4, 2014 Share Posted February 4, 2014 setBlipColor already is a MTA function. Also, the source of the onResourceStart event isn't a player element. Link to comment
xeon17 Posted February 4, 2014 Author Share Posted February 4, 2014 Will this work ? root = getRootElement () players = {} resourceRoot = getResourceRootElement ( getThisResource () ) function onResourceStart ( resource ) for id, player in ipairs( getElementsByType ( "player" ) ) do if ( players[player] ) then if ( getPlayerTeam" class="kw2">getPlayerTeam ( player ) ) then local r, g, b = getTeamColor ( player ) createBlipAttachedTo ( player, 0, 2, r, g, b ) else createBlipAttachedTo ( player, 0, 2, 255,255,255 ) end else createBlipAttachedTo ( player, 0, 2, r,g,b ) end end end function onPlayerSpawn ( spawnpoint ) if ( players[source] ) then if ( getPlayerTeam" class="kw2">getPlayerTeam ( player ) ) then local r, g, b = getTeamColor ( player ) createBlipAttachedTo ( player, 0, 2, r, g, b ) else createBlipAttachedTo ( player, 0, 2, 255,255,255 ) end else local r, g, b = getPlayerNametagColor ( player ) createBlipAttachedTo ( source, 0, 2, r, g, b ) 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 if ( getPlayerTeam" class="kw2">getPlayerTeam ( player ) ) then local r, g, b = getTeamColor ( player ) createBlipAttachedTo ( player, 0, 2, r, g, b ) else createBlipAttachedTo ( player, 0, 2, 255,255,255 ) end else local r, g, b = getPlayerNametagColor ( player ) createBlipAttachedTo ( player, 0, 2, r, g, b ) 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 ) } if ( getPlayerTeam" class="kw2">getPlayerTeam ( player ) ) then local r, g, b = getTeamColor ( player ) createBlipAttachedTo ( player, 0, 2, r, g, b ) else createBlipAttachedTo ( player, 0, 2, 255,255,255 ) end 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 Link to comment
Karuzo Posted February 4, 2014 Share Posted February 4, 2014 What are you trying to do with getPlayerTeam" class="kw2"> ? Link to comment
DNL291 Posted February 4, 2014 Share Posted February 4, 2014 No, just change the name of the setBlipColor function. What are you trying to do with getPlayerTeam" class="kw2"> ? It's a bug with [ lua ][ / lua ] tag. Link to comment
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