SpecT Posted May 9, 2015 Share Posted May 9, 2015 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
WhoAmI Posted May 9, 2015 Share Posted May 9, 2015 If onPlayerCommand event doesn't work, there isn't any solution, I guess. Link to comment
SpecT Posted May 9, 2015 Author Share Posted May 9, 2015 If onPlayerCommand event doesn't work, there isn't any solution, I guess. Hmm, yeah but it doesn't cancel the event even when the cmd is register (from the admin panel). Link to comment
WhoAmI Posted May 9, 2015 Share Posted May 9, 2015 Show me your why how you cancel it. Link to comment
Walid Posted May 9, 2015 Share Posted May 9, 2015 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
SpecT Posted May 9, 2015 Author Share Posted May 9, 2015 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
Walid Posted May 9, 2015 Share Posted May 9, 2015 Or maybe i should use "elseif" .. lel I gotta try that later, because now I dont have time Use my code Link to comment
MKH Posted May 9, 2015 Share Posted May 9, 2015 Idk but try this function login (plr) kickPlayer(plr, "this command not allowed") end addCommandHandler("login", login) Link to comment
The Don Posted May 9, 2015 Share Posted May 9, 2015 -- 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
Walid Posted May 9, 2015 Share Posted May 9, 2015 i Already gave him the solution wait till he try it. Link to comment
Enargy, Posted May 9, 2015 Share Posted May 9, 2015 addEventHandler("onPlayerCommand", getRootElement(), function(cmd) if (cmd == "login") then cancelEvent() end end) : Link to comment
SpecT Posted May 9, 2015 Author Share Posted May 9, 2015 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
Walid Posted May 9, 2015 Share Posted May 9, 2015 Finally I got time to test it. It works perfectly! Thanks dude! you are welcome Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now