Jump to content

[Question] Admin function


Recommended Posts

Posted

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?

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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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?

Posted
maybe there is a getElementData(thePlayer,"invincible") that sets it's alpha to 0?

invincible is a godmode i think...

Diet with russian vodka, lose 3 days in one week !

  • Moderators
Posted

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 ) 

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

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