Jump to content

[Question] Admin function


Recommended Posts

Hi,

I have download the "invisible script" , and now i want that the command only can be used by the ACL group "Nick en Mitchel"

This is my script:

iv = 0 
  
function toggleInvis( source ) 
    local account = getPlayerAccount(thePlayer) 
    if (not account or isGuestAccount(account)) then return end 
    local accountName = getAccountName(account) 
    if ( isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Nick en Mitchel" ) ) ) then 
    if iv == 0 then 
        iv = 1 
        setPlayerNametagShowing(source, false) 
        setElementAlpha(source, 0) 
    else 
        iv = 0 
        setPlayerNametagShowing(source, true) 
        setElementAlpha(source, 255) 
    end 
end 
end 
  
addCommandHandler ( "invisible", toggleInvis ) 

I get the errors:

[2012-05-10 21:44:35] WARNING: invisible\invisible.lua:4: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] 
[2012-05-10 21:46:33] WARNING: invisible\invisible.lua:4: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil] 

Maybe someone can learn me how to do this?

Link to comment
iv = { } 
  
function toggleInvis ( thePlayer ) 
    local account = getPlayerAccount ( thePlayer ) 
    if ( not account or isGuestAccount ( account ) ) then  
        return  
    end 
  
    local accountName = getAccountName ( account ) 
    if ( isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Nick en Mitchel" ) ) ) then 
        if ( iv [ thePlayer ] == 0 ) then 
            iv [ thePlayer ] = 1 
            setPlayerNametagShowing ( thePlayer, false ) 
            setElementAlpha ( thePlayer, 0 ) 
        else 
            iv [ thePlayer ] = 0 
            setPlayerNametagShowing ( thePlayer, true ) 
            setElementAlpha ( thePlayer, 255 ) 
        end 
    end 
end 
addCommandHandler ( "invisible", toggleInvis ) 

Errors:

1: You we're using "thePlayer" insead of "source" @ getPlayerAccount.

2: You had a global variable, you should use a table to check the player invisibility status.

Link to comment

Thanks for your reaction, but how is it possible that my godmode script works fine with the same things:

  
    function toggleGodMode(thePlayer) 
    local account = getPlayerAccount(thePlayer) 
    if (not account or isGuestAccount(account)) then return end 
    local accountName = getAccountName(account) 
    if ( isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Nick en Mitchel" ) ) ) or accountName == "driessen9" then 
        if getElementData(thePlayer,"invincible") then 
            setElementData(thePlayer,"invincible",false) 
            outputChatBox("Nick en Mitchel zijn niet aardig ;D - godmode is nu uit.",thePlayer,0,255,0) 
        else 
            setElementData(thePlayer,"invincible",true) 
            outputChatBox("Nick en Mitchel Zijn aardig ;D - godmode is aan!",thePlayer,0,255,0) 
            end 
        end 
    end 
    addCommandHandler("godmode",toggleGodMode) 
  

Because you got nothing wrong there?

Link to comment
  • Moderators

It does works te same...

You can't see element data as a trigger. It is just saved data.

Je bedoeld dit als toevoeging? (NL)

function Spawn ( thePlayer ) 
if getElementData(thePlayer,"invincible") then 
setElementAlpha(source, 0) 
end 
end 
  
addEventHandler ( "onPlayerSpawn", getRootElement(), Spawn ) 

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