Jump to content
  • 0

Disable a command to players


TheBite

Question

Posted

Hey to all, how to disable a command like /superman for general users?

I tryed to type in ace - everyone "" but normal users can type superman and fly, now?

Recommended Posts

  • 0
Posted

Not tested, Try :

addEventHandler ( 'onPlayerCommand', root, function ( player, cmd ) 
    if cmd == 'superman' then 
        local account = getPlayerAccount ( player ); 
        if isGuestAccount ( account ) then 
            cancelEvent ( ); 
        end 
    end 
end ); 

  • 0
Posted
Not tested, Try :
addEventHandler ( 'onPlayerCommand', root, function ( player, cmd ) 
    if cmd == 'superman' then 
        local account = getPlayerAccount ( player ); 
        if isGuestAccount ( account ) then 
            cancelEvent ( ); 
        end 
    end 
end ); 

In a new script?

  • 0
Posted (edited)

This script I tryed to make:

disable.lua

    addEventHandler ( 'onPlayerCommand', root, function ( player, cmd ) 
        if cmd == 'superman' then 
            local account = getPlayerAccount ( player ); 
            if isGuestAccount ( account ) then 
                cancelEvent ( ); 
            end 
        end 
    end ); 

meta.xml

<meta> 
    <info author="name" name="Disable"  version="1.0" type="script"/> 
    <script src="disable.lua" type="serverside" /> 
</meta> 

also I tryed to type:

    <script src="disable.lua" type="server" /> 

Edited by Guest
  • 0
Posted
So the script is not showing in the resources grid list in the admin panel ? or it's not working ?

I can start it, but is not working...

  • 0
Posted

Yeah, when i changed the server to serverslide consle said (when restart scipt):

[2013-05-03 19:12:36] Unknown script type specified in Disable. Assuming 'server' 

  • 0
Posted

try this:

script.lua:

addEventHandler ('onPlayerCommand', root, function ( player, cmd ) 
    if cmd:lower() ~= 'superman' then return end 
    if not isGuestAccount ( getPlayerAccount ( player ) ) then return end 
    cancelEvent() 
end) 

meta.xml:

>    author="Nathanasiou" name="Disable"  version="1.0.0" type="script" />    ="script.lua" />>

Make sure that these are all in the same folder and the script is called "script.lua" and the xml/meta is called "meta.xml".

If this doesn't work, please post a screenshot of your folder with these scripts and the debug error shown after command "/debugscript 3".

  • 0
Posted (edited)
try this:

script.lua:

addEventHandler ('onPlayerCommand', root, function ( player, cmd ) 
    if cmd:lower() ~= 'superman' then return end 
    if not isGuestAccount ( getPlayerAccount ( player ) ) then return end 
    cancelEvent() 
end) 

meta.xml:

>    author="name" name="Disable"  version="1.0.0" type="script" />    ="script.lua" />>

Make sure that these are all in the same folder and the script is called "script.lua" and the xml/meta is called "meta.xml".

If this doesn't work, please post a screenshot of your folder with these scripts and the debug error shown after command "/debugscript 3".

Not working..

http://i.imgur.com/RMTas90.png

[2013-05-03 22:58:07] debugscript: Incorrect client type for this command 

and when I play as guest and I type superman on the same time console says:

[2013-05-03 22:56:23] ERROR: Disable\script.lua:2: attempt to index local 'cmd' (a nil value) 

Edited by Guest
  • 0
Posted

Try this

addEventHandler ( 'onPlayerCommand', root,  
    function ( cmd ) 
        if ( cmd == "superman" and isGuestAccount ( getPlayerAccount ( source ) ) ) then 
            cancelEvent ( ) 
        end 
    end 
) 

  • 0
Posted
Try this
addEventHandler ( 'onPlayerCommand', root,  
    function ( cmd ) 
        if ( cmd == "superman" and isGuestAccount ( getPlayerAccount ( source ) ) ) then 
            cancelEvent ( ) 
        end 
    end 
) 

Nothing :@@@@@

  • 0
Posted
addEventHandler ('onPlayerCommand', root, 
    function ( cmd ) 
        if (cmd == "superman") then 
        local accName = getAccountName(getPlayerAccount(source)) 
        if (isObjectInACLGroup("user." .. accName, aclGetGroup("Admin"))) then 
            cancelEvent ( ) 
        end 
    end 
    end 
) 

  • 0
Posted
addEventHandler ("onPlayerCommand", root, 
    function (command) 
        if (command == "superman") then 
        local accName = getAccountName(getPlayerAccount(source)) 
        if (isObjectInACLGroup("user." .. accName, aclGetGroup("Admin"))) then 
            cancelEvent () 
        end 
    end 
    end 
) 

  • 0
Posted (edited)
addEventHandler ("onPlayerCommand", root, 
    function (command) 
        if (command == "superman") then 
        local accName = getAccountName(getPlayerAccount(source)) 
        if (isObjectInACLGroup("user." .. accName, aclGetGroup("Admin"))) then 
            cancelEvent () 
        end 
    end 
    end 
) 

Edited by Guest
  • 0
Posted

wait, Are you restarting the resource after you updated the script and meta.xml?

If not, type in "restart Disable" in the console/dark-window.

  • 0
Posted
wait, Are you restarting the resource after you updated the script and meta.xml?

If not, type in "restart Disable" in the console/dark-window.

I already do it, but nothing, pls, can you give me a tested resource why is very strange?

I Want exclude the possibility it may be a problem in my server. :(

  • 0
Posted

Thanks.

Try this:

addEventHandler ('onPlayerCommand', root, function (cmd) 
    outputChatBox(cmd,source) 
    if cmd:lower() ~= 'superman' then return end 
    outputChatBox("superman",source) 
    if not isGuestAccount ( getPlayerAccount ( source ) ) then return end 
    cancelEvent() 
end) 

  • 0
Posted
Thanks.

Try this:

addEventHandler ('onPlayerCommand', root, function (cmd) 
    outputChatBox(cmd,source) 
    if cmd:lower() ~= 'superman' then return end 
    outputChatBox("superman",source) 
    if not isGuestAccount ( getPlayerAccount ( source ) ) then return end 
    cancelEvent() 
end) 

Well, it's not working but when I type /superman (as guest of course) the game chat (not console) says:

2 times per 1 /sperman says:

superman 

and some times says (for two times):

Toggle 

and all with grey color

PS: When I type anything in chat, chat says:

Say 
My message 

The "Say" with grey color

  • 0
Posted

oh, it's because all those are bind to a command, like talking in the chat via '/say'.

ok, everything works, but if you're trying to not let the player use the superman command then you would need to go to the actual script with the superman command.

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