Jump to content

unexpected symbols


Agon

Recommended Posts

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

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) ? :S

Link to comment
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
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 by Guest
Link to comment
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 by Guest
Link to comment
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

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