Jump to content

Admin hide


Recommended Posts

Ok so what I'm looking to do is make it so that an admin can hide themselves, so when trying to watch what's going on (in say an RP on an RP server) no player can see that the admin is there.

Here's the code I have server-side:

--ADMIN HIDDEN
function adminHide(sourcePlayer, command)
if isGuestAccount(getPlayerAccount(sourcePlayer)) ~= true then
if not isObjectInACLGroup("user."..getAccountName(getPlayerAccount(sourcePlayer)), aclGetGroup("Admin")) then
outputChatBox("Sorry, but you are not allowed to use the hide command", sourcePlayer)
return false
else
if getElementData(sourcePlayer, "hidden") then
setElementAlpha(sourcePlayer, 255)
removeElementData(sourcePlayer, "hidden")
			setPlayerNameTagShowing(sourcePlayer, true)
triggerClientEvent(sourcePlayer, "onUnhide", sourcePlayer)
outputChatBox("You are no longer invisible.", sourcePlayer)
else
setElementData(sourcePlayer, "hidden")
setElementAlpha(sourcePlayer, 0)
			setPlayerNameTagShowing(sourcePlayer, false)
triggerClientEvent(sourcePlayer, "onHide", sourcePlayer)
outputChatBox("You are now invisible.", sourcePlayer)
end
end
end
end
addCommandHandler("ahide", adminHide)

ISSUES:

[15:07:42] WARNING: admincmds/server/admincommands.lua:10: Bad argument @ 'setEl

ementData'

[15:07:42] ERROR: admincmds/server/admincommands.lua:12: attempt to call global

'setPlayerNameTagShowing' (a nil value)

Here's the code I have client-side:

function showToLocalPartial()
setElementAlpha(source, 150)
end
addEvent("onHide", true)
addEventHandler("onHide", getRootElement(), showToLocalPartial)
 
function showToLocalAbsolute()
setElementAlpha(source, 255)
end
addEvent("onUnhide", true)
addEventHandler("onUnhide", getRootElement(), showToLocalAbsolute)

ISSUES:

-The graphics go slightly red, the draw distance seems to drop and it doesn't make them partially visible.

-Maybe this is scripted wrong?

Any help is appreciated. :)

Link to comment

The serverside errors are very easy to fix.

1. You omitted an argument at setElementData. You have to provide a third argument as value for the element data, in your case it would be:

setElementData(sourcePlayer, "hidden", true)

2. It's 'setPlayerNametagShowing', not 'setPlayerNameTagShowing'. Functions are always case sensitive!

Because of the second mistake, the script probably stopped at this point and the clientside event never got triggered.

That should fix all your problems but the one with the graphics.

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