Raised This Month: $ Target: $400
 0% 

[SOLVED] Register_concmd password


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
extream87
Senior Member
Join Date: Aug 2011
Old 03-03-2014 , 10:18   [SOLVED] Register_concmd password
Reply With Quote #1

How can i make a plugin need password to access to menu?
If a player write in console plugin_pass "999" the plugin give him menu acess.

Example:
Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #define PLUGIN "New Plug-In" #define VERSION "1.0" #define AUTHOR "author" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         register_concmd(if write plugin_pass "999" in console | password_correct = true) } public test(){     if (true)     ColorChat(id, GREEN, "Ok you have access to this command!") }

Last edited by extream87; 03-03-2014 at 10:53.
extream87 is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 03-03-2014 , 11:31   Re: [HELP] Register_concmd password
Reply With Quote #2

Register the command plugin_pass and then check the arts in the handler, just like you would do for any other plugin...
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
extream87
Senior Member
Join Date: Aug 2011
Old 03-03-2014 , 11:34   Re: [HELP] Register_concmd password
Reply With Quote #3

Is the 1st time i make this "pass verify" so i dont know how to do this.

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #define PLUGIN "New Plug-In" #define VERSION "1.0" #define AUTHOR "author" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)           register_concmd("plugin_pass", "CmdConsole") } public CmdConsole(id) { //Here the if if (plugin_pass = 999) { ColorChat(id, GREEN, "Ok you have access to this command!") //Code continue... } }

Last edited by extream87; 03-03-2014 at 11:39.
extream87 is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 03-03-2014 , 11:36   Re: [HELP] Register_concmd password
Reply With Quote #4

Have you ever made a plugin that has a command and takes args? It is the same thing
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
extream87
Senior Member
Join Date: Aug 2011
Old 03-03-2014 , 11:41   Re: [HELP] Register_concmd password
Reply With Quote #5

You can send me a link or a example code plz?
extream87 is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 03-03-2014 , 11:45   Re: [HELP] Register_concmd password
Reply With Quote #6

https://wiki.alliedmods.net/Intro_to...Admin_Commands
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 03-03-2014 , 13:32   Re: [HELP] Register_concmd password
Reply With Quote #7

Code:
#include <amxmodx> #define MAX_PASSWORD_LENGHT 30 new const g_szPassword[MAX_PASSWORD_LENGHT] = "your password" public plugin_init()     register_clcmd("your_command", "ShowMenu") public ShowMenu(id) {     static szArg1[MAX_PASSWORD_LENGHT]         // read the arguments after your_command     read_args(szArg1, MAX_PASSWORD_LENGHT - 1)         // if the they differ from the defined password in this plugin, then block the access     if (!equali(g_szPassword, szArg1))     {         client_print(id, print_console, "Invalid password specified. Access denied.")                 return PLUGIN_HANDLED;     }         // Your code... }
or you can just simply
Code:
public plugin_init()     register_clcmd("your_command PASSWORD", "ShowMenu") public ShowMenu(id) {     // Your code... }
__________________

Last edited by georgik57; 03-03-2014 at 13:33.
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
extream87
Senior Member
Join Date: Aug 2011
Old 03-03-2014 , 14:25   Re: [HELP] Register_concmd password
Reply With Quote #8

Works, thank you.

How can i make for the password to be put in the middle of "" Example: amx_password "code"

And if i write amx_password "" in console appears:
client_print(id, print_console, "You need to insert the password.")

Code:
#include <amxmodx> #define MAX_PASSWORD_LENGHT 30 new const g_szPassword[MAX_PASSWORD_LENGHT] = "code" public plugin_init()     register_clcmd("amx_password", "ShowMenu") public ShowMenu(id) {     static szArg1[MAX_PASSWORD_LENGHT]         // read the arguments after your_command     read_args(szArg1, MAX_PASSWORD_LENGHT - 1)         // if the they differ from the defined password in this plugin, then block the access     if (!equali(g_szPassword, szArg1))     {         client_print(id, print_console, "Password invalida. Acesso negado.")                 return PLUGIN_HANDLED;     }         client_print(id, print_console, "Password valida. Acesso garantido.")     return PLUGIN_HANDLED; }

Last edited by extream87; 03-03-2014 at 14:27.
extream87 is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 03-03-2014 , 14:31   Re: [HELP] Register_concmd password
Reply With Quote #9

Check if szArg1 is equal to ""
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 03-03-2014 , 14:35   Re: [HELP] Register_concmd password
Reply With Quote #10

Quote:
Originally Posted by extream87 View Post
Works, thank you.

How can i make for the password to be put in the middle of "" Example: amx_password "code"

And if i write amx_password "" in console appears:
client_print(id, print_console, "You need to insert the password.")
It doesn't matter if you quote it or not, since the code reads all the following arguments after the command.

Code:
#include <amxmodx> #define MAX_PASSWORD_LENGHT 30 new const g_szPassword[MAX_PASSWORD_LENGHT] = "code" public plugin_init()     register_clcmd("amx_password", "ShowMenu") public ShowMenu(id) {     static szArg1[MAX_PASSWORD_LENGHT]         // read the arguments after your_command     read_args(szArg1, MAX_PASSWORD_LENGHT - 1)         if (!szArg1[0])     {         client_print(id, print_console, "Usage: amx_password YourPassword")                 return PLUGIN_HANDLED;     }         // if the they differ from the defined password in this plugin, then block the access     if (!equali(g_szPassword, szArg1))     {         client_print(id, print_console, "Password invalida. Acesso negado.")                 return PLUGIN_HANDLED;     }         client_print(id, print_console, "Password valida. Acesso garantido.")     return PLUGIN_HANDLED; }
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:54.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode