AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Call messagemode with params (https://forums.alliedmods.net/showthread.php?t=313108)

Airkish 12-28-2018 15:01

Call messagemode with params
 
I have a fair amount of user inputs and creating new function for every input doesn't seem good (unless it's the only way).

So is there a way to call messagemode with params?

PHP Code:

register_clcmd("iInput""@InputInt"); 

//This what Im using atm
PHP Code:

@InputInt(id) {
    new 
szText[16];
    
read_args(szTextcharsmax(szText));
    
remove_quotes(szText);

    
g_ePlayerShop[id][Quantity] = str_to_num(szText);
    @
ShopMenu(idPAGE_ONE);
    return 
PLUGIN_HANDLED;


//I would like to have an extra param
PHP Code:

@InputInt(idInputFor) {
    new 
szText[16];
    
read_args(szTextcharsmax(szText));
    
remove_quotes(szText);

    switch(
InputFor) {
        case 
INPUT_SHOP: {
            
g_ePlayerShop[id][Quantity] = str_to_num(szText);
            @
ShopMenu(idPAGE_ONE);
        }
        case 
INPUT_GIFT: {
            
g_ePlayerGift[id][Quantity] = str_to_num(szText);
            @
GiftMenu(idPAGE_ONE);
        }
        case 
INPUT_MARKET: {
            
g_ePlayerMarket[id][Quantity] = str_to_num(szText);
            @
MarketMenu(idPAGE_ONE);
        }
    }
    
    return 
PLUGIN_HANDLED;


PHP Code:

//how do I set extra param here (if its even possible)?
client_cmd(id"messagemode iInput"); 


OciXCrom 12-28-2018 15:12

Re: Call messagemode with params
 
You can read the entire input with "read_args" and separate the arguments with "parse".

Airkish 12-29-2018 05:35

Re: Call messagemode with params
 
Quote:

Originally Posted by OciXCrom (Post 2631481)
You can read the entire input with "read_args" and separate the arguments with "parse".

Im reading it already (not sure what exactly you mean by saying entire).

Natsheh 12-29-2018 06:04

Re: Call messagemode with params
 
Seems you are miss lead using register_clcmd function

Its function passed into it only 3 parameters id, level, cid. There is no such a parameter called inputfor

Inputfor should be a global user variable to determind which shop is the player using right now.

klippy 12-29-2018 06:28

Re: Call messagemode with params
 
You can use player_menu_info() to determine which menu is currently open and take action based on that, if it's possible to input those values only while those menus are open.

eat1k 12-29-2018 06:39

Re: Call messagemode with params
 
client_cmd(id, "messagemode iInput 1"); ?

Airkish 12-29-2018 06:49

Re: Call messagemode with params
 
Quote:

Originally Posted by Natsheh (Post 2631567)
Seems you are miss lead using register_clcmd function

Its function passed into it only 3 parameters id, level, cid. There is no such a parameter called inputfor

Inputfor should be a global user variable to determind which shop is the player using right now.

Oh ok, gonna use global variable.

Thanks everyone for contribution.


All times are GMT -4. The time now is 07:32.

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