Raised This Month: $ Target: $400
 0% 

take user input from a menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
am_amx
Senior Member
Join Date: Jul 2010
Location: here
Old 08-06-2010 , 09:42   take user input from a menu
Reply With Quote #1

hi

i'm new to this scripting

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

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;


Last edited by am_amx; 08-06-2010 at 12:02. Reason: ADDED CODE
am_amx is offline
Old 08-06-2010, 15:01
Emp0wer
This message has been deleted by Emp0wer.
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-06-2010 , 19:05   Re: take user input from a menu
Reply With Quote #3

It will basically be the same as this example. I think you are smart enough to take it from there.
__________________
fysiks is offline
am_amx
Senior Member
Join Date: Jul 2010
Location: here
Old 08-06-2010 , 23:02   Re: take user input from a menu
Reply With Quote #4

Quote:
Originally Posted by fysiks View Post
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 ?

Last edited by am_amx; 08-06-2010 at 23:07.
am_amx is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-07-2010 , 13:14   Re: take user input from a menu
Reply With Quote #5

Quote:
Originally Posted by am_amx View Post
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.
__________________

Last edited by fysiks; 08-07-2010 at 13:58.
fysiks is offline
DarkGod
SourceMod DarkCrab
Join Date: Jul 2007
Location: Sweden
Old 08-06-2010 , 23:05   Re: take user input from a menu
Reply With Quote #6

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.
__________________
DarkGod is offline
Send a message via AIM to DarkGod Send a message via MSN to DarkGod
am_amx
Senior Member
Join Date: Jul 2010
Location: here
Old 08-07-2010 , 00:09   Re: take user input from a menu
Reply With Quote #7

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)


Last edited by am_amx; 08-07-2010 at 03:31. Reason: changed alot, will execute on connect :P thax to darkgod
am_amx is offline
RedRobster
Veteran Member
Join Date: Apr 2010
Location: Your Closet
Old 08-07-2010 , 01:57   Re: take user input from a menu
Reply With Quote #8

Quote:
Originally Posted by am_amx View Post
whts loose *indentation* error?
Fixed. And, it occurs because you did the indentation wrong some where in your plugin.
RedRobster is offline
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 00:11.


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