Jump to content

player blip not working


Xwad

Recommended Posts

The player blip is not working when the player spawns with id 21:/

server

function setBlip(theSkin) 
if theSkin == 21 then 
outputChatBox("medic_blip") 
local blip_medic = createBlipAttachedTo ( source, 22 ) 
local team_axis = getTeamFromName(Axis) 
local players = getPlayersInTeam(team_axis) 
setElementVisibleTo(blip_medic, players, true) 
end 
end 
addEventHandler ( "onPlayerSpawn", getRootElement(), setBlip ) 

Link to comment
  
function setBlip( posX, posY, posZ, spawnRotation, theTeam, theSkin, theInterior, theDimension ) 
if theSkin == 21 then 
outputChatBox("medic_blip", thePlayer, 255, 255 ,255) 
local blip_medic = createBlipAttachedTo ( source, 22 ) 
local players = getPlayersInTeam(theTeam) 
setElementVisibleTo(blip_medic, getRootElement(), true) 
end 
end 
addEventHandler ( "onPlayerSpawn", getRootElement(), setBlip ) 
  

Also, I don't see any 'createBlip' functions in your code?

Link to comment
function setBlip(_, _, _, _, _, theSkin) 
    if theSkin == 21 then 
        outputChatBox("medic_blip") 
        local blip_medic = createBlipAttachedTo ( source, 22 ) 
        local team_axis = getTeamFromName("Axis") 
        local players = getPlayersInTeam(team_axis) 
        for i, player in ipairs(players) do  
            setElementVisibleTo(blip_medic, player, true) 
        end 
    end 
end 
addEventHandler ( "onPlayerSpawn", getRootElement(), setBlip ) 

Link to comment

Try this(NOT TESTED):

  
local medicsTeam = createTeam("Axis",255,0,0) 
  
function medicBlip() 
    if getElementType(source) == "player" then 
         if getElementModel(source) == 21 then 
             setPlayerTeam(source,getTeamFromName("Axis")) 
             local medics = getPlayersInTeam(getTeamFromName("Axis")) 
             for i,v in pairs (medics) do 
                   createBlipAttachedTo(v,22) 
             end 
          end 
    end 
end 
addEventHandler("onPlayerSpawn",root,medicBlip) 
addEventHandler("onElementModelChange",root,medicBlip) 
  
  

Link to comment
still has the same bugs:/

Explain me the bug

EDIT:I tested the script and it works just perfect

SERVER:

local medicsTeam = createTeam("Axis",255,0,0) 
  
function medicBlip() 
    if getElementType(source) == "player" then 
         if getElementModel(source) == 21 then 
             setPlayerTeam(source,getTeamFromName("Axis")) 
             local medics = getPlayersInTeam(getTeamFromName("Axis")) 
             for i,v in pairs (medics) do 
                   createBlipAttachedTo(v,22) 
             end 
          end 
    end 
end 
addEventHandler("onPlayerSpawn",root,medicBlip) 
addEventHandler("onElementModelChange",root,medicBlip) 
  

META:

    

Link to comment
Now it has only one bug: players from other teams can see the blip. I want to make that only teammates can see each other blips

Forgot to setElementVisibleTo

local medicsTeam = createTeam("Axis",255,0,0) 
  
function medicBlip() 
    if getElementType(source) == "player" then 
         if getElementModel(source) == 21 then 
             setPlayerTeam(source,getTeamFromName("Axis")) 
             local medics = getPlayersInTeam(getTeamFromName("Axis")) 
             for i,v in pairs (medics) do 
                   local blip = createBlipAttachedTo(v,22) 
  
                   for i,v in pairs(getElementsByType("player")) do 
                       local playerTeam = getTeamName(getPlayerTeam(v)) 
                       if playerTeam == "Axis" then 
                          setElementVisibleTo(blip,v,true) 
                      else 
                          setElementVisibleTo(blip,v,false) 
                      end 
                  end 
             end 
          end 
    end 
end 
addEventHandler("onPlayerSpawn",root,medicBlip) 
addEventHandler("onElementModelChange",root,medicBlip) 

Link to comment

Humpf ... The createBlip or createBlipAttachedTo already got the "visibleto"

  
createBlipAttachedTo ( element elementToAttachTo [, int icon = 0, int size = 2, int r = 255, int g = 0, int b = 0, int a = 255, int ordering = 0, float visibleDistance = 99999.0, visibleTo = getRootElement( ) ] ) 
  

Try something like this :

createBlipAttachedTo(v,22,2,255,0,0,255,0,99999.0,v) 

Instead of

                    
 local blip = createBlipAttachedTo(v,22) 
for i,v in pairs(getElementsByType("player")) do 
                       local playerTeam = getTeamName(getPlayerTeam(v)) 
                       if playerTeam == "Axis" then 
                          setElementVisibleTo(blip,v,true) 
                      else 
                          setElementVisibleTo(blip,v,false) 
                      end 
                  end 

Link to comment

now my problem is that no one can see the blips:/

function blip() 
    if getElementType(source) == "player" then 
         if getElementModel(source) == 20 or getElementModel(source) == 21 or getElementModel(source) == 22 or getElementModel(source) == 23 or getElementModel(source) == 24 then 
             local players = getPlayersInTeam(getTeamFromName("Axis")) 
             for i,v in pairs (players) do 
                   createBlipAttachedTo(v,58,2,255,0,0,255,0,99999.0,v) 
                  end 
             end 
          end 
    end 
addEventHandler("onPlayerSpawn",root,blip) 
addEventHandler("onElementModelChange",root,blip) 

Link to comment
now my problem is that no one can see the blips:/
function blip() 
    if getElementType(source) == "player" then 
         if getElementModel(source) == 20 or getElementModel(source) == 21 or getElementModel(source) == 22 or getElementModel(source) == 23 or getElementModel(source) == 24 then 
             local players = getPlayersInTeam(getTeamFromName("Axis")) 
             for i,v in pairs (players) do 
                   createBlipAttachedTo(v,58,2,255,0,0,255,0,99999.0,v) 
                  end 
             end 
          end 
    end 
addEventHandler("onPlayerSpawn",root,blip) 
addEventHandler("onElementModelChange",root,blip) 

local medicsTeam = createTeam("Axis",255,0,0)

-_-

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