AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   User buy hook [ Need help ] (https://forums.alliedmods.net/showthread.php?t=147957)

HoLLyWooD 01-16-2011 10:08

User buy hook [ Need help ]
 
A very interesting thing. Invoking the plugin is once per round and only one player! How can this be?

PHP Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "HoLLyWooD"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd"buy","clcmd_buy");
}

public 
clcmd_buy(id){
    
menu_go(id)
    
log_amx("%d call menu!",id);
}

menu_go(id){
    if(!
is_user_alive(id))
        return 
PLUGIN_HANDLED;
        
    
AwesomeMenu(id);
    return 
PLUGIN_CONTINUE;
}

public 
AwesomeMenu(id){
    new 
menu menu_create("\rLook at this awesome Menu!:""menu_handler");

    
menu_additem(menu"\wI'm Selection #1""1"0);
    
menu_additem(menu"\wI'm Selection #2""2"0);
    
menu_additem(menu"\wI'm Secret Selection #3""3"ADMIN_ADMIN);
   
    
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(idprint_chat"Hooray! You selected the Awesome 1st Selection");
            
menu_destroy(menu);
            return 
PLUGIN_HANDLED;
        }
        case 
2:{
            
client_print(idprint_chat"OH NO! You selected the Awesome 2nd Selection! BEWARE!");
        }
        case 
3:{
            
client_print(idprint_chat"You have selected the Awesome Admin Selection! Hail Teh Bail!");
        }
    }

    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;



Who can help - that cake:):avast:

menu get from http://forums.alliedmods.net/showthr...6364#BasicMenu

drekes 01-16-2011 10:36

Re: Plugin works once per round? O_o
 
You can make a new global bool and set it false at round start.
Then when the menu is called, check if bool is false.
If it's false, he hasn't used the menu yet, show the menu and set the bool true.

And you could create the awesome menu inside the clcmd_func along with the menu_go(id) function.

And you shouldn't just copy-paste a tutorial, you should read, understand and try to make it yourself.

HoLLyWooD 01-16-2011 11:13

Re: Plugin works once per round? O_o
 
You do not understand. I do not want to plug used once per round. And I know without the article as to make the menu. I have that plugin written by me working again on the round for one player. I want to help with the correction.

Since I do not see an error in the text that I posted.

GXLZPGX 01-16-2011 11:46

Re: Plugin works once per round? O_o
 
Quote:

Originally Posted by HoLLyWooD (Post 1394849)
I have that plugin written by me working again on the round for one player.

I'm sure you didn't.

What he said is what you need to do to achieve what you want, you're just being ignorant.

HoLLyWooD 01-16-2011 12:02

Re: Plugin works once per round? O_o
 
Well I can see, I figured out or not?

I wrote a plugin. Wrote his first with 0. He worked for 1 player per round. I decided that I might not correctly written menu, so he took a menu with a guide.

But it's not on the menu turned out to be. The point may be that I command buy for returning Handled

drekes 01-16-2011 12:36

Re: Plugin works once per round? O_o
 
to make it work do something like this:

PHP Code:

new boolg_MenuUsed[33];

public 
plugin_init()

    
register_logevent("LogEvent_RoundStart"2"1=Round_Start");

    
// Your other stuff.
}

public 
LogEvent_RoundStart()
    
arrayset(g_MenuUsedtruesizeof(g_MenuUsed));

public 
clcmd_buy(id)
{
    if(!
g_MenuUsed[id] && !is_user_alive(id))
    {
        
// Show the menu
    
        
g_MenuUsed[id] = true;
    }
 
    return 
PLUGIN_HANDLED;



HoLLyWooD 01-16-2011 12:45

Re: Plugin works once per round? O_o
 
Hmm. Or translater, distorts my message or you do not understand ...

I DO NOT WANT that he worked only 1 time. I want it to work all the time!

drekes 01-16-2011 14:12

Re: Plugin works once per round? O_o
 
Then what's wrong with the code you posted ?

Elusive138 01-16-2011 15:07

Re: Plugin works once per round? O_o
 
Quote:

Originally Posted by drekes (Post 1394946)
Then what's wrong with the code you posted ?

I believe that's what he's asking.

HoLLyWooD 01-16-2011 15:09

Re: Plugin works once per round? O_o
 
Actually I'm asking what is wrong in my code that causes a time to round it to work?


All times are GMT -4. The time now is 01:56.

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