Sasu Posted February 16, 2013 Share Posted February 16, 2013 -- needs configurable blip colors, and team support ._. root = getRootElement () local player = getPlayerTeam ( getRootElement () ) local r, g, b = getTeamColor ( player ) color = { r, g, b } 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, getTeamName, 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, getTeamName, 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 Bueno no me sale bien el script. Quisiera que los blips de los jugadores tengan el color de su Team. Me sale error: WARNING: blip\blips.lua:3: Bad 'player' pointer @ 'getPlayerTeam'<1> WARNING: blip\blips.lua:4: Bad argument @ 'getTeamColor' Por favor si alguien me puede ayudar. Gracias. Link to comment
Castillo Posted February 16, 2013 Share Posted February 16, 2013 Ese codigo no tiene sentido. Proba esto: players = { } function onResourceStart ( resource ) for _, player in ipairs ( getElementsByType ( "player" ) ) do local team = getPlayerTeam ( player ) local r, g, b = unpack ( ( team and { getTeamColor ( team ) } or { getPlayerNametagColor ( player ) } ) ) players [ player ] = createBlipAttachedTo ( player, 0, 2, r, g, b, 255 ) end end addEventHandler ( "onResourceStart", resourceRoot, onResourceStart ) function onPlayerSpawn ( spawnpoint ) local team = getPlayerTeam ( source ) local r, g, b = unpack ( ( team and { getTeamColor ( team ) } or { getPlayerNametagColor ( source ) } ) ) if ( players [ source ] ) then setBlipColor ( players [ source ], r, g, b, 255 ) else players [ source ] = createBlipAttachedTo ( source, 0, 2, r, g, b, 255 ) end end addEventHandler ( "onPlayerSpawn", root, onPlayerSpawn ) function destroyBlips ( totalammo, killer, killerweapon ) destroyBlipsAttachedTo ( source ) end addEventHandler ( "onPlayerQuit", root, destroyBlips ) addEventHandler ( "onPlayerWasted", root, destroyBlips ) function destroyBlipsAttachedTo ( player ) local attached = getAttachedElements ( player ) if ( attached ) then for _, element in ipairs ( attached ) do if ( getElementType ( element ) == "blip" ) then destroyElement ( element ) end end end end Link to comment
Sasu Posted February 16, 2013 Author Share Posted February 16, 2013 Ese codigo no tiene sentido.Proba esto: players = { } function onResourceStart ( resource ) for _, player in ipairs ( getElementsByType ( "player" ) ) do local team = getPlayerTeam ( player ) local r, g, b = unpack ( ( team and { getTeamColor ( team ) } or { getPlayerNametagColor ( player ) } ) ) players [ player ] = createBlipAttachedTo ( player, 0, 2, r, g, b ) end end addEventHandler ( "onResourceStart", resourceRoot, onResourceStart ) function onPlayerSpawn ( spawnpoint ) local team = getPlayerTeam ( source ) local r, g, b = unpack ( ( team and { getTeamColor ( team ) } or { getPlayerNametagColor ( source ) } ) ) if ( players [ source ] ) then setBlipColor ( players [ source ], r, g, b ) else players [ source ] = createBlipAttachedTo ( source, 0, 2, r, g, b ) end end addEventHandler ( "onPlayerSpawn", root, onPlayerSpawn ) function destroyBlips ( totalammo, killer, killerweapon ) destroyBlipsAttachedTo ( source ) end addEventHandler ( "onPlayerQuit", root, destroyBlips ) addEventHandler ( "onPlayerWasted", root, destroyBlips ) function destroyBlipsAttachedTo ( player ) local attached = getAttachedElements ( player ) if ( attached ) then for _, element in ipairs ( attached ) do if ( getElementType ( element ) == "blip" ) then destroyElement ( element ) end end end end @Solidsnake14, los blips se ponen en blanco y no me tira ningun error en debugscript. Link to comment
Recommended Posts