Jump to content

Hide blip in freeroam?


megaman54

Recommended Posts

You can destroy Blips by this function:

function destroyBlipAttachedTo(player) 
for id, attachedElement in ipairs(getAttachedElements(player)) do 
if getElementType(attachedElement) == "blip" then 
destroyElement(attachedElement) 
end 
end 
end 

Link to comment

And what with this ?

Blip is not destroyed .

Server side only:

iv = 0 
  
function toggleInvis( source ) 
    if iv == 0 then 
        iv = 1 
        setPlayerNametagShowing(source, false) 
        setElementAlpha(source, 0) 
    else 
        iv = 0 
        setPlayerNametagShowing(source, true) 
        setElementAlpha(source, 255) 
    end 
end 
  
function destroyBlipAttachedTo(player) 
for id, attachedElement in ipairs(getAttachedElements(player)) do 
if getElementType(attachedElement) == "blip" then 
destroyElement(attachedElement) 
end 
end 
end 
  
addCommandHandler ( "invisible", toggleInvis, destroyBlipAttachedTo ) 

Link to comment
That's the function I gave you, you specify the player.

destroyBlipAttachedTo(player)

Ahh.. I dint notice it was already like that :/. Thanks. But now i have other question: after the blip is destroyed, how i get it back? Because the blip is created by freeroam resource so i could have to recall the creation function. But there is some other code that must be executed only when a player joins.

Link to comment

WTF, 3 arguments at addCommandHandler.

You have no idea what you are doing.

addCommandHandler("hideblip", 
function(player,_,targetName) 
local target = getPlayerFromName(targetName) 
if target then 
destroyBlipAttachedTo(target) 
end 
end) 
  
function destroyBlipAttachedTo(player) 
for id, attachedElement in ipairs(getAttachedElements(player)) do 
if getElementType(attachedElement) == "blip" then 
destroyElement(attachedElement) 
end 
end 
end 

use it like this: /hideblip playerName

@megaman create it again with another script createBlipAttachedTo

Link to comment
iv = 0 
  
function toggleInvis( source ) 
    if iv == 0 then 
        iv = 1 
        setPlayerNametagShowing(source, false) 
        setElementAlpha(source, 0) 
        destroyBlipAttachedTo(source) 
    else 
        iv = 0 
        setPlayerNametagShowing(source, true) 
        setElementAlpha(source, 255) 
    end 
end 
  
function destroyBlipAttachedTo(player) 
for id, attachedElement in ipairs(getAttachedElements(player)) do 
if getElementType(attachedElement) == "blip" then 
destroyElement(attachedElement) 
end 
end 
end 
  
addCommandHandler ( "invisible", toggleInvis) 

???

Link to comment

And this must stay in the resource : iv = 0

  
iv = 0 
function toggleInvis( source ) 
    if iv == 0 then 
        iv = 1 
        setPlayerNametagShowing(source, false) 
        setElementAlpha(source, 0) 
    else 
        iv = 0 
        setPlayerNametagShowing(source, true) 
        setElementAlpha(source, 255) 
    end 
end 

Link to comment
  
noobData = {} 
function toggleInvis( source ) 
    if not noobData[source] then 
        noobData[source] = true 
        setPlayerNametagShowing(source, false) 
        setElementAlpha(source, 0) 
    else 
        noobData[source] = false 
        setPlayerNametagShowing(source, true) 
        setElementAlpha(source, 255) 
    end 
end addCommandHandler("stealth", toggleInvis) 

I don't like you CapY :)

Link to comment

What's is wrong here ?

Server:

iv = 0 
  
function toggleInvis( source ) 
    if iv == 0 then 
        iv = 1 
        setPlayerNametagShowing(source, false) 
        setElementAlpha(source, 0) 
        destroyBlipAttachedTo(source) 
    else 
        iv = 0 
        setPlayerNametagShowing(source, true) 
        setElementAlpha(source, 255) 
    end 
end 
  
function destroyBlipAttachedTo(player) 
for id, attachedElement in ipairs(getAttachedElements(player)) do 
if getElementType(attachedElement) == "blip" then 
destroyElement(attachedElement) 
else 
myPlayer = getRandomPlayer () 
-- Create a radar blip in the middle of the map 
myBlip = createBlip ( 0, 0, 0 ) 
-- Make the player the parent of the blip, so that the blip follows the player around 
setElementParent ( myBlip, myPlayer ) 
end 
end 
end 
  
  
  
  
  
addCommandHandler ( "invisible", toggleInvis) 

Link to comment

What is this??

It stays invisible because there is no code to create it back, it won't create itself back.

here:

iv = 0 
  
function toggleInvis( source ) 
    if iv == 0 then 
        iv = 1 
        setPlayerNametagShowing(source, false) 
        setElementAlpha(source, 0) 
        destroyBlipAttachedTo(source) 
    else 
        iv = 0 
        setPlayerNametagShowing(source, true) 
        setElementAlpha(source, 255) 
        --createBlipAttachedTo(source, arguments ... ) 
    end 
end 
  
function destroyBlipAttachedTo(player) 
for id, attachedElement in ipairs(getAttachedElements(player)) do 
if getElementType(attachedElement) == "blip" then 
destroyElement(attachedElement) 
end 
end 
end 
  
addCommandHandler ( "invisible", toggleInvis) 

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