Agon Posted February 13, 2012 Share Posted February 13, 2012 Hi this is my code and it says in line 3 there is an unexpected symbol near "if". i tried removing "(" and ")" but it said: ")" expected near "=".. what's wrong with that? function hideMe(source) local account = getAccountName(getPlayerAccount(source)) if (getElementAlpha(source) == 255) and if (isPlayerNametagShowing(source)) then if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then setPlayerNametagShowing(source, false) setElementAlpha(source, 0) elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then setPlayerNametagShowing(source, false) setElementAlpha(source, 0) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then setPlayerNametagShowing(source, false) setElementAlpha(source, 0) else outputChatBox("You are not allowed to use this command!", source, 255, 0, 0) end else setElementAlpha(source, 255) setPlayerNametagShowing(source, true) end addCommandHandler("hide", getRootElement(), hideMe) Link to comment
Kenix Posted February 13, 2012 Share Posted February 13, 2012 function hideMe( source ) local account = getAccountName( getPlayerAccount( source ) ) if getElementAlpha( source ) == 255 and isPlayerNametagShowing( source ) then if isObjectInACLGroup( "user." .. account, aclGetGroup( "Admin" ) ) then setPlayerNametagShowing( source, false ) setElementAlpha( source, 0 ) elseif isObjectInACLGroup( "user." .. account, aclGetGroup( "SuperModerator" ) ) then setPlayerNametagShowing( source, false ) setElementAlpha( source, 0 ) elseif isObjectInACLGroup( "user." .. account, aclGetGroup( "Moderator" ) ) then setPlayerNametagShowing( source, false ) setElementAlpha( source, 0 ) else outputChatBox( "You are not allowed to use this command!", source, 255, 0, 0 ) end else setElementAlpha( source, 255 ) setPlayerNametagShowing( source, true ) end end addCommandHandler( "hide", hideMe ) https://wiki.multitheftauto.com/wiki/Scr ... troduction http://www.lua.org/manual/5.1/ Link to comment
drk Posted February 13, 2012 Share Posted February 13, 2012 Server side: function hideMe() local acc = getAccountName(getPlayerAccount(source)) if getElementAlpha(source) == 255 and isPlayerNametagShowing(source) then if isObjectInACLGroup('user.' .. acc, aclGetGroup('Admin')) then setPlayerNametagShowing(source,false) setElementAlpha(source,0) end elseif isObjectInACLGroup('user.' .. acc, aclGetGroup('SuperModerator')) then setPlayerNametagShowing(source,false) setElementAlpha(source,0) end elseif isObjectInACLGroup('user.' .. acc, aclGetGroup('Moderator')) then setPlayerNametagShowing(source,false) setElementAlpha(source,0) end else outputChatBox('You are not allowed to use this command!', source, 255, 0, 0, false) end end addCommandHandler('hide',hideMe) Why he needs setElementAlpha(source,255) setPlayerNametagShowing(source,true) ? Link to comment
Agon Posted February 13, 2012 Author Share Posted February 13, 2012 Oh i see my fault thank you. Why he needs setElementAlpha(source,255) setPlayerNametagShowing(source,true) ? is it because I'm trying to make a script that makes admins, supmods, and mods invisible? Link to comment
drk Posted February 13, 2012 Share Posted February 13, 2012 It dont need setElementAlpha(source,255) setPlayerNametagShowing(source,true) because it will return if player is admin, smod or mod, if isn't one of these it will output in chat box, nothing more. Then dont need this Link to comment
Agon Posted February 13, 2012 Author Share Posted February 13, 2012 It dont need setElementAlpha(source,255) setPlayerNametagShowing(source,true) because it will return if player is admin, smod or mod, if isn't one of these it will output in chat box, nothing more. Then dont need this oh you mean it will make me visible again when i type /hide without putting setElementAlpha(source,255) and setPlayerNametagShowing(source,true) in the script? Link to comment
Kenix Posted February 13, 2012 Share Posted February 13, 2012 (edited) local state = { } function hideMe( source ) local account = getAccountName( getPlayerAccount( source ) ) if isObjectInACLGroup( "user." .. account, aclGetGroup( "Admin" ) ) or isObjectInACLGroup( "user." .. account, aclGetGroup( "SuperModerator" ) ) or isObjectInACLGroup( "user." .. account, aclGetGroup( "Moderator" ) ) then state[ source ] = not state[ source ] if state[ source ] then setElementAlpha( source,0 ) outputChatBox( 'invisible' ) else setElementAlpha( source,255 ) outputChatBox( 'visible' ) end else outputChatBox( 'Access denied for this command.' ) end end addCommandHandler( "hide", hideMe ) addEventHandler( 'onPlayerQuit',root, function( ) state[ source ] = nil end ) ?? Edited February 13, 2012 by Guest Link to comment
Agon Posted February 13, 2012 Author Share Posted February 13, 2012 (edited) local state = { } function hideMe( source ) local account = getAccountName( getPlayerAccount( source ) ) if isObjectInACLGroup( "user." .. account, aclGetGroup( "Admin" ) ) or isObjectInACLGroup( "user." .. account, aclGetGroup( "SuperModerator" ) ) or isObjectInACLGroup( "user." .. account, aclGetGroup( "Moderator" ) ) then state[ source ] = not state[ source ] if state[ source ] then setElementAlpha( source,0 ) outputChatBox( 'invisible' ) else setElementAlpha( source,255 ) outputChatBox( 'visible' ) end else outputChatBox( 'Access denied for this command.' ) end end addCommandHandler( "hide", hideMe ) addEventHandler( 'onPlayerQuit',root, function( ) state[ source ] = nil end ) ?? Oh seems easier. thank you again Edited February 13, 2012 by Guest Link to comment
drk Posted February 13, 2012 Share Posted February 13, 2012 It dont need setElementAlpha(source,255) setPlayerNametagShowing(source,true) because it will return if player is admin, smod or mod, if isn't one of these it will output in chat box, nothing more. Then dont need this oh you mean it will make me visible again when i type /hide without putting setElementAlpha(source,255) and setPlayerNametagShowing(source,true) in the script? No. This only get player acl group and if is in admin, smod or mod it will set element alpha and hide player nametag. If you want to set default again see what Kenix made. Link to comment
Kenix Posted February 13, 2012 Share Posted February 13, 2012 Take my code again. I fix small problem Link to comment
Agon Posted February 13, 2012 Author Share Posted February 13, 2012 (edited) oh ok then. thank you guys Edit: ok Kenix Edited February 13, 2012 by Guest 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