Jump to content

blip for all expect player


Recommended Posts

i want to make a blip appear for ALL player expect myself.

this is what i tried so far...

  
  
blip = createBlipAttachedTo (source, 56) 
        i = getElementsByType ( "player" ) 
        for k, v in ipairs(i) do 
            if(i ~= source) then 
                setElementVisibleTo ( blip, v, false ) 
            end 
        end 
  
  

no errors but i can still see the blip on the mini map over myself

Link to comment
blip = createBlipAttachedTo (source, 56) 
      setElementVisibleTo ( blip, source, false ) 
      players = getElementsByType ( "player" ) 
      for k, v in ipairs(players) do 
      if(v ~= source) then 
      setElementVisibleTo ( blip, v, true ) 
      end 
end 

Link to comment

I Don't Tested but do this

function createblip() 
random = getPlayerFromName(getRandomPlayer()) 
createBlipAttachedTo(random, 41) 
end 
-- addEventHandler("onPlayerJoin",getRootElement(),createblip) or addCommandHandler("randomblip",createblip) 

I think its this you need

Cya later,

Maaaaria.

Link to comment
I Don't Tested but do this

No.

this is my code Solidsnake14...

  
  
--local sourceP 
        blip = createBlipAttachedTo (sourceP, 56) 
        setElementVisibleTo ( blip, sourceP, false ) 
        players = getElementsByType ( "player" ) 
        for k, v in ipairs(players) do 
            if(v ~= source) then 
                setElementVisibleTo ( blip, v, true ) 
            end 
        end 
  

Link to comment

I think he's a newbie? because if that's the full script, he's forgeting some things.

addCommandHandler("blip", 
function (sourceP) 
local blip = createBlipAttachedTo (sourceP, 56) 
setElementVisibleTo ( blip, sourceP, false ) 
end) 

I think that should work.

Link to comment

Okay, if you are trying to create a single blip that is shown for ALL player EXCEPT for one player, try this.

NOTE: this code snippet assumes that source is a player that triggered some event. Whether or not this is what is going in I am unsure since you won't show us your full script.

  
local blip = createBlipAttachedTo (source, 56) --Create the blip - it will be visible for all players.. 
setElementVisibleTo(blip, source, false ) --Hide the blip. 
  

Also, ignore the weird "sourceP" advice - that makes no sense.

Also note: this is just a snippet - it wont work just on it's own, so I assume you have this all within a function.

Link to comment
Okay, if you are trying to create a single blip that is shown for ALL player EXCEPT for one player, try this.

NOTE: this code snippet assumes that source is a player that triggered some event. Whether or not this is what is going in I am unsure since you won't show us your full script.

  
local blip = createBlipAttachedTo (source, 56) --Create the blip - it will be visible for all players.. 
setElementVisibleTo(blip, source, false ) --Hide the blip. 
  

Also, ignore the weird "sourceP" advice - that makes no sense.

Also note: this is just a snippet - it wont work just on it's own, so I assume you have this all within a function.

it does make sense.some functions/events have build in source argument, and if you define something else with it it overwrites.

therefore, for example, you wont be able to know, what player triggered some event.

Link to comment

MY QUESTION IS, HOW TO define SourceP

ffs cant u see i did '--local sourceP' in my script but it doesnt work?!?

  
  
     
function player_Spawn ( posX, posY, posZ, spawnRotation, theTeam, theSkin, theInterior, theDimension ) 
    if(not firstspawn[source]) then 
        firstspawn[source] = true; 
        givePlayerMoney ( source, 10000 ) 
        local sourceP 
        blip = createBlipAttachedTo (sourceP, 56) 
        setElementVisibleTo ( blip, sourceP, false ) 
        players = getElementsByType ( "player" ) 
        for k, v in ipairs(players) do 
            if(v ~= source) then 
                setElementVisibleTo ( blip, v, true ) 
            end 
        end 
    end 
end 
addEventHandler ( "onPlayerSpawn", getRootElement(), player_Spawn ) 
  

Happy?

Link to comment
function player_Spawn ( posX, posY, posZ, spawnRotation, theTeam, theSkin, theInterior, theDimension ) 
    if(not firstspawn[source]) then 
        firstspawn[source] = true; 
        givePlayerMoney ( source, 10000 ) 
        blip = createBlipAttachedTo (source, 56) 
        setElementVisibleTo ( blip, source, false ) 
    end 
end 
addEventHandler ( "onPlayerSpawn", getRootElement(), player_Spawn ) 

You don't need sourceP here, since source is already the player element who just spawned.

Link to comment

source doesnt work... i can still see myself

  
  
function player_Spawn ( posX, posY, posZ, spawnRotation, theTeam, theSkin, theInterior, theDimension ) 
    if(not firstspawn[source]) then 
        firstspawn[source] = true; 
        givePlayerMoney ( source, 10000 ) 
        blip = createBlipAttachedTo (source, 56) 
        setElementVisibleTo ( blip, source, false ) 
        players = getElementsByType ( "player" ) 
        for k, v in ipairs(players) do 
            if(v ~= source) then 
                setElementVisibleTo ( blip, v, true ) 
            end 
        end 
    end 
    giveWeapon (source, 31, 400) 
    giveWeapon (source, 26, 200) 
    giveWeapon (source, 9, 1) 
    giveWeapon (source, 29, 400) 
end 
addEventHandler ( "onPlayerSpawn", getRootElement(), player_Spawn ) 
  
  

Link to comment
source doesnt work... i can still see myself
  
  
function player_Spawn ( posX, posY, posZ, spawnRotation, theTeam, theSkin, theInterior, theDimension ) 
    if(not firstspawn[source]) then 
        firstspawn[source] = true; 
        givePlayerMoney ( source, 10000 ) 
        blip = createBlipAttachedTo (source, 56) 
        setElementVisibleTo ( blip, source, false ) 
        players = getElementsByType ( "player" ) 
        for k, v in ipairs(players) do 
            if(v ~= source) then 
                setElementVisibleTo ( blip, v, true ) 
            end 
        end 
    end 
    giveWeapon (source, 31, 400) 
    giveWeapon (source, 26, 200) 
    giveWeapon (source, 9, 1) 
    giveWeapon (source, 29, 400) 
end 
addEventHandler ( "onPlayerSpawn", getRootElement(), player_Spawn ) 
  
  

thats exact reason you don't want to use source as any other arguments, cuz it overwrites normal ones.

and forget this:

  
        players = getElementsByType ( "player" ) 
        for k, v in ipairs(players) do 
            if(v ~= source) then 
                setElementVisibleTo ( blip, v, true ) 
            end 
        end 
  

this is not needed, it is set visible by default.

Link to comment
Karlis, that dosent make any sense - source is the player that the blip needs to be hidden from. So you use setElementVisibleTo(blip, source, false).

wait, isn't the source defined anywhere else?

oh i see, sry, tought he did define smthing like source=...

edit: so this should still work just fine

  
firstspawn={ } 
function player_Spawn () 
    if (not firstspawn[source]) then 
        firstspawn[source] = true 
        givePlayerMoney ( source, 10000 ) 
        local blip = createBlipAttachedTo (source, 56) 
        setElementVisibleTo ( blip, source, false ) 
    end 
    giveWeapon (source, 31, 400) 
    giveWeapon (source, 26, 200) 
    giveWeapon (source, 9, 1) 
    giveWeapon (source, 29, 400) 
end 
addEventHandler ( "onPlayerSpawn", getRootElement(), player_Spawn ) 
  

Link to comment
The event "onPlayerSpawn" defines source as the player who just spawned, and passes it along to player_Spawn (the handler function) automatically. So source is defined automatically.

i did understand that all the time, just thought its overwritten after that, as i said, nvm, sorry for that.

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