Jump to content
  • 0

Disable a command to players


TheBite

Question

Recommended Posts

  • 0

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

Link to comment
  • 0
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?

Link to comment
  • 0

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
Link to comment
  • 0

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

Link to comment
  • 0
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
Link to comment
  • 0

Try this

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

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

Nothing :@@@@@

Link to comment
  • 0
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 
) 

Link to comment
  • 0
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 
) 

Link to comment
  • 0
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
Link to comment
  • 0
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. :(

Link to comment
  • 0

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) 

Link to comment
  • 0
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

Link to comment
  • 0

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.

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