ÆBKV Posted January 25, 2018 Share Posted January 25, 2018 (edited) local ghostmode = false addCommandHandler("ghostmode", function(player) if not hasObjectPermissionTo(player,"general.adminpanel") then outputChatBox("You don't have permission to use this command.",player,255,0,0) return end local blip = getBlipAttachedTo(player) local r,g,b = getPlayerNametagColor(player) for index,players in ipairs(getElementsByType("player")) do if ghostmode == false then ghostmode = true setElementVisibleTo(player,players,false) setPlayerNametagShowing(player,false) setElementAlpha(player,200) destroyElement(blip) outputChatBox("Ghost Mode: #00FF00enabled",player,255,255,255,true) else ghostmode = false setElementVisibleTo(player,players,true) setPlayerNametagShowing(player,true) setElementAlpha(player,255) createBlipAttachedTo(player,0,2,r,g,b,255) outputChatBox("Ghost Mode: #FF0000disabled",player,255,255,255,true) end end end ) function getBlipAttachedTo(player) for index,blips in ipairs(getElementsByType("blip")) do if getElementAttachedTo(blips) == player then return blips end end return false end How can I restore everything when the resource stops? I've tried everything but it does not work. Edited January 25, 2018 by ÆBKV Link to comment
Arsilex Posted January 26, 2018 Share Posted January 26, 2018 local ghostmode = false addCommandHandler("ghostmode", function(player) if not hasObjectPermissionTo(player,"general.adminpanel") then outputChatBox("You don't have permission to use this command.",player,255,0,0) return end local blip = getBlipAttachedTo(player) local r,g,b = getPlayerNametagColor(player) for index,players in ipairs(getElementsByType("player")) do if ghostmode == false then ghostmode = true setElementVisibleTo(player,players,false) setPlayerNametagShowing(player,false) setElementAlpha(player,200) destroyElement(blip) outputChatBox("Ghost Mode: #00FF00enabled",player,255,255,255,true) else ghostmode = false setElementVisibleTo(player,players,true) setPlayerNametagShowing(player,true) setElementAlpha(player,255) createBlipAttachedTo(player,0,2,r,g,b,255) outputChatBox("Ghost Mode: #FF0000disabled",player,255,255,255,true) end end end) function getBlipAttachedTo(player) for index,blips in ipairs(getElementsByType("blip")) do if getElementAttachedTo(blips) == player then return blips end end return false end addEventHandler("onResourceStop", resourceRoot, function() for index, players in pairs(getElementsByType("player")) do setElementVisibleTo(player, players, true) setPlayerNametagShowing(player, true) setElementAlpha(player, 255) local blip = getBlipAttachedTo(player) if blip then destroyElement(blip) end end end) Didn't tested it but should work.. Link to comment
ÆBKV Posted January 26, 2018 Author Share Posted January 26, 2018 Is it the same if I use root instead of players. Do you know that maybe? like this setElementVisibleTo(player,root,false) Link to comment
DRW Posted January 26, 2018 Share Posted January 26, 2018 4 minutes ago, ÆBKV said: Is it the same if I use root instead of players. Do you know that maybe? like this setElementVisibleTo(player,root,false) It will work, the player elements that are children of the root element will be affected. So yes. 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