megaman54 Posted August 14, 2011 Share Posted August 14, 2011 I want to make a exported function to the freeroam resource. Like exports.freeroam:hideBlip(getPlayerFromName("Megaman54"), true) So i could hide blips with command or something. How can this be done? Link to comment
JR10 Posted August 14, 2011 Share Posted August 14, 2011 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
megaman54 Posted August 14, 2011 Author Share Posted August 14, 2011 Thanks but i only want to do it to specific players. Like in the example i gave in the first post. Link to comment
JR10 Posted August 14, 2011 Share Posted August 14, 2011 That's the function I gave you, you specify the player. destroyBlipAttachedTo(player) Link to comment
CapY Posted August 14, 2011 Share Posted August 14, 2011 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
megaman54 Posted August 14, 2011 Author Share Posted August 14, 2011 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
JR10 Posted August 14, 2011 Share Posted August 14, 2011 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
CapY Posted August 14, 2011 Share Posted August 14, 2011 It's supposted to hide ped, his name and blip , can you do it on script i posted . Link to comment
JR10 Posted August 14, 2011 Share Posted August 14, 2011 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
CapY Posted August 14, 2011 Share Posted August 14, 2011 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
qaisjp Posted August 14, 2011 Share Posted August 14, 2011 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
megaman54 Posted August 14, 2011 Author Share Posted August 14, 2011 Thanks for everyone (especially to JR10) fore being helpful. Thanks! Link to comment
CapY Posted August 14, 2011 Share Posted August 14, 2011 [lua] I don't like you CapY Community resource . When i type invisible it's all good , but when i type it again , ped and players name shows , but blip stays hidden. Link to comment
CapY Posted August 17, 2011 Share Posted August 17, 2011 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
JR10 Posted August 17, 2011 Share Posted August 17, 2011 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
CapY Posted August 17, 2011 Share Posted August 17, 2011 I still dont see the blip when returning ped from invisible to visible. Link to comment
JR10 Posted August 17, 2011 Share Posted August 17, 2011 That's because you copied it, without even looking. I made a comment, so you uncomment it, and put the arguments. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now