AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED] Register_concmd password (https://forums.alliedmods.net/showthread.php?t=236347)

extream87 03-03-2014 10:18

[SOLVED] Register_concmd password
 
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!") }

YamiKaitou 03-03-2014 11:31

Re: [HELP] Register_concmd password
 
Register the command plugin_pass and then check the arts in the handler, just like you would do for any other plugin...

extream87 03-03-2014 11:34

Re: [HELP] Register_concmd password
 
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... } }

YamiKaitou 03-03-2014 11:36

Re: [HELP] Register_concmd password
 
Have you ever made a plugin that has a command and takes args? It is the same thing

extream87 03-03-2014 11:41

Re: [HELP] Register_concmd password
 
You can send me a link or a example code plz?

YamiKaitou 03-03-2014 11:45

Re: [HELP] Register_concmd password
 
https://wiki.alliedmods.net/Intro_to...Admin_Commands

georgik57 03-03-2014 13:32

Re: [HELP] Register_concmd password
 
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... }

extream87 03-03-2014 14:25

Re: [HELP] Register_concmd password
 
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; }

YamiKaitou 03-03-2014 14:31

Re: [HELP] Register_concmd password
 
Check if szArg1 is equal to ""

georgik57 03-03-2014 14:35

Re: [HELP] Register_concmd password
 
Quote:

Originally Posted by extream87 (Post 2106896)
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; }


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

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