AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   take user input from a menu (https://forums.alliedmods.net/showthread.php?t=134561)

am_amx 08-06-2010 09:42

take user input from a menu
 
hi

i'm new to this scripting :wink:

after going through the tuts by red and PvtSmithFSSF .. i want to add a front end to some plugin(user registration ). here is my menu i was able to get it display in game

Code:

.::WELCOME::.
1.pass protect ur nick(new comers )
2.login

but now comes the hard part for me :down::down:

1.how to execute/run the plugin after user connects automatically(like that of join/left plugin)?

2.suppose user chose 1 or 2 option how to read the input frm user(password) and store it temporarily


PHP Code:

#include <amxmodx>
#define PLUGIN    "GUIFORReg"
#define AUTHOR    "am_amx"
#define VERSION    "1.0"

// I WANT THE PLUGIN TO BE EXECUTED WHEN USER CONNECTS
public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
 
    
register_clcmd("say /reg","PMenu");
}
public 
PMenu(id)
{
    new 
menu menu_create("\r.:: WELCOME ::. ""menu_handler");
    
menu_additem(menu"\yREGISTER(NEW USER )""1"0);
    
menu_additem(menu"\yLOGIN""2"0);
    
menu_additem(menu"\yGET U R ASS KIKCED ""3"0);
 
    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
menu_display(idmenu0);
}
public 
menu_handler(idmenuitem)
{
    if( 
item == MENU_EXIT)
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,5iName63callback);
    new 
key str_to_num(data);
    switch(
key)
    {
        case 
1:
        {
           
//NEED SOME MAGIC CODE HERE
          //GRRR
         // LIKE SHOULD ASK USER TO ENTER PASSWORD  AND STORE IN 
         //SAY 'PASS'(VARIABLE)
        
[URL="http://forums.alliedmods.net/showthread.php?t=59596"]amx_register[/URL1 PASS //COMPLETED THE REGISTRATION 
        
}
        case 
2:
        {
            
//NEED SOME MAGIC CODE HERE
            //ENTER THE PASSWORD AND STORE IT IN VARIABLE 'PASSWOR'
       
[URL="http://forums.alliedmods.net/showthread.php?t=59596"]amx_login[/URLPASSWOR  //   TO login with ALREADY REGISTRED password.
        
}
        case 
3:
        {
           
//NEED SOME MAGIC CODE HERE
        
}
        
    }
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;



fysiks 08-06-2010 19:05

Re: take user input from a menu
 
It will basically be the same as this example. I think you are smart enough to take it from there.

am_amx 08-06-2010 23:02

Re: take user input from a menu
 
Quote:

Originally Posted by fysiks (Post 1263712)
It will basically be the same as this example. I think you are smart enough to take it from there.


code has bug in it at function name
Quote:

register_clcmd("_mm_wordhere", "mmWord")
can u help me with my first problem ?

DarkGod 08-06-2010 23:05

Re: take user input from a menu
 
The "error": add return PLUGIN_HANDLED at the bottom of the function.

First problem: set a short task from client_putinserver(), or hook when they join a team and check if it's their first time joining.

am_amx 08-07-2010 00:09

Re: take user input from a menu
 
unable to get it work with this pls help

PHP Code:

#include <amxmodx> 
#define PLUGIN    "GUIFORReg" 
#define AUTHOR    "am_amx" 
#define VERSION    "1.0" 
new szTemp[64]

// I WANT THE PLUGIN TO BE EXECUTED WHEN USER CONNECTS 
public plugin_init() 

    
register_plugin(PLUGINVERSIONAUTHOR
  
    
register_clcmd("say /reg","PMenu"); 
     
register_clcmd("PUT_PASS1""Greada1"
    
register_clcmd("PUT_PASS2""Greada2"

public 
client_putinserver(id)
{
set_task(2.0,"client_execmd")
}
public 
client_execmd(id)
{
client_cmd(id,"say /reg")
}
public 
PMenu(id

    new 
menu menu_create("\r.:: WELCOME ::. ""menu_handler"); 
    
menu_additem(menu"\yREGISTER(NEW USER )""1"0); 
    
menu_additem(menu"\yLOGIN""2"0); 
    
menu_additem(menu"\yGET U R ASS KIKCED ""3"0); 
  
    
menu_setprop(menuMPROP_EXITMEXIT_ALL); 
    
menu_display(idmenu0); 

public 
menu_handler(idmenuitem

    if( 
item == MENU_EXIT
    { 
        
menu_destroy(menu); 
        return 
PLUGIN_HANDLED
    } 
    new 
data[6], iName[64]; 
    new 
accesscallback
    
menu_item_getinfo(menuitemaccessdata,5iName63callback); 
    new 
key str_to_num(data); 
    switch(
key
    { 
        case 
1
        { 
client_print(id,print_center,"enter u r passowrd!")
           
client_cmd(id"messagemode PUT_PASS1")
     
     
// console_cmd ( id,say "hiall")
        

        case 
2
        { 
client_print(id,print_center,"enter u r passowrd to login !")
           
client_cmd(id"messagemode PUT_PASS2")
           
        } 
        case 
3
        { 
         
server_cmd("kick #%i ^"You must to loginPlease retry...^""get_user_userid(id)); 
           
//NEED SOME MAGIC CODE HERE 
        

         
    } 
    
menu_destroy(menu); 
    return 
PLUGIN_HANDLED
}  
public 
Greada1(id
{  
    
read_args(szTempcharsmax(szTemp))  
    
client_cmd(id,"say amx_register 1 %s",szTemp)
}  
public 
Greada2(id
{  
    
read_args(szTempcharsmax(szTemp))   
    
client_cmd(id,"say amx_login %s",szTemp)



RedRobster 08-07-2010 01:57

Re: take user input from a menu
 
Quote:

Originally Posted by am_amx (Post 1263893)
whts loose *indentation* error?

Fixed. And, it occurs because you did the indentation wrong some where in your plugin.

fysiks 08-07-2010 13:14

Re: take user input from a menu
 
Quote:

Originally Posted by am_amx (Post 1263859)
code has bug in it at function name

Yeah, well, it was a typo. You don't have to be that smart to fix it. It still shows you how to do it.


All times are GMT -4. The time now is 00:11.

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