Jump to content

blip for all expect player


Recommended Posts

Posted

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

Posted
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 

Posted
  
blip = createBlipAttachedTo (sourceP, 56) 
setElementVisibleTo ( blip, sourceP, false ) 
  

better don't use variable source, as it is sometime defined by defaults.

Posted

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.

Posted
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 
  

Posted

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.

Posted

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.

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

Posted

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?

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

Posted

mastermax, sourceP isn't relevant, in fact it was really bad advice. You want to use SOURCE, and it is already defined by the event onPlayerSpawn.

Also, for future reference, you need to post ALL of the relevant info (either the entire script or the single function and event).

Posted

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 ) 
  
  

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

Posted
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 ) 
  

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

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