Jump to content

Login/register command


SpecT

Recommended Posts

Hello!

Is it possible and if yes how can I block the login command. I remember that the register command is in the Admin panel, but is it possible to block the /login ?

I tried to cancel the event onPlayerCommand when the command is login but didn't work.

Thanks!

Link to comment
Hello!

Is it possible and if yes how can I block the login command. I remember that the register command is in the Admin panel, but is it possible to block the /login ?

I tried to cancel the event onPlayerCommand when the command is login but didn't work.

Thanks!

Yes you can try to use sth like this:

local Commands = { 
    ["login"] = true, -- login command 
} 
  
local SerialAccess = { 
   [""] = true, -- maybe you can add your serial here only you will be able to use it 
} 
  
function noAccessCommands(command) 
    if (Commands[command]) then 
        local serial = getPlayerSerial(source) 
        if (not SerialAccess[serial]) then 
            cancelEvent() 
            outputChatBox("You can't use this Command ("..command..")", source, 255, 0, 0) 
            return 
        end 
    end 
end 
addEventHandler("onPlayerCommand", root, noAccessCommands) 

Link to comment

I made something similar to Walid's code month ago for the "aexec" command and it worked.

function banCommand(command) 
    if command == "aexec" then 
        if not getPlayerSerial(source) == "HIDDEN" then 
            cancelEvent() 
        end 
    end 
    if command =="login" then 
        if not getPlayerSerial(source) == "HIDDEN" then 
            cancelEvent() 
        end 
    end 
    if command =="register" then 
        if not getPlayerSerial(source) == "HIDDEN" then 
            cancelEvent() 
        end 
    end 
end 
addEventHandler("onPlayerCommand",getRootElement(),banCommand) 

Or maybe i should use "elseif" .. lel I gotta try that later, because now I dont have time

Link to comment
-- Server 
YourSerial = "" -- the serial that allowed to use this commands 
  
cmd = { 
    "login",-- add more commands in the table if you want 
    "", 
    "", 
     
} 
  
addEventHandler("onPlayerCommand",root, 
function(command) 
    if getPlayerSerial(source) ~= YourSerial then 
        for k,v in pairs(cmd) do 
            if command == v then  
                outputChatBox("You can't use this command /"..command.."",source,255,0,0) 
                cancelEvent(    ) 
            end 
        end  
    end 
end 
) 

Link to comment
Hello!

Is it possible and if yes how can I block the login command. I remember that the register command is in the Admin panel, but is it possible to block the /login ?

I tried to cancel the event onPlayerCommand when the command is login but didn't work.

Thanks!

Yes you can try to use sth like this:

local Commands = { 
    ["login"] = true, -- login command 
} 
  
local SerialAccess = { 
   [""] = true, -- maybe you can add your serial here only you will be able to use it 
} 
  
function noAccessCommands(command) 
    if (Commands[command]) then 
        local serial = getPlayerSerial(source) 
        if (not SerialAccess[serial]) then 
            cancelEvent() 
            outputChatBox("You can't use this Command ("..command..")", source, 255, 0, 0) 
            return 
        end 
    end 
end 
addEventHandler("onPlayerCommand", root, noAccessCommands) 

Finally I got time to test it. It works perfectly!

Thanks dude!

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