AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   need help with amxx scripting, would appreciate if you would help me (https://forums.alliedmods.net/showthread.php?t=163152)

ajjt 07-27-2011 08:22

need help with amxx scripting, would appreciate if you would help me
 
Hi everybody

I am working with my first amx mod x plugin.
And I was asking how I can make a plugin that ask a question about the rules example, "Is team kill allowed" and the option is gonna be yes or no, so if they answer wrong they will be kicked and banned 2min from the server. The question should be different. I hope someone give me idea how I could make it.

Best regards ajjt

ajjt 07-27-2011 08:37

Re: need help with amxx scripting, would appreciate if you would help me
 
I would appreciate if you told how to do it.

SnoW 07-27-2011 09:10

Re: need help with amxx scripting, would appreciate if you would help me
 
I would appreciate if no one would never do this plugin.

ajjt 07-27-2011 09:14

Re: need help with amxx scripting, would appreciate if you would help me
 
Quote:

Originally Posted by SnoW (Post 1519611)
I would appreciate if no one would never do this plugin.

This is my first plugin that I am making, that's way it's a easy plugin.
And the problem is how can they get random question and if they answer wrong they will be kicked and banned 2min

SnoW 07-27-2011 09:23

Re: need help with amxx scripting, would appreciate if you would help me
 
Could you write some code and ask something more specific because I am pretty sure you will find how to kick and ban a player. Anyway for random number use this and create the menu you show the question in with the help of this.

hornet 07-27-2011 09:24

Re: need help with amxx scripting, would appreciate if you would help me
 
You need a list of questions and a list of answers, each in their own string variable, in corresponding order. It then depends on what kind of ban system your running ... AmxBans? AdvancedBans? ...? Otherwise just stick with kick.

ajjt 07-27-2011 09:28

Re: need help with amxx scripting, would appreciate if you would help me
 
Quote:

Originally Posted by hornet (Post 1519624)
You need a list of questions and a list of answers, each in their own string variable, in corresponding order. It then depends on what kind of ban system your running ... AmxBans? AdvancedBans? ...? Otherwise just stick with kick.

What do you mean with "their own string variable, in corresponding order"

ajjt 07-27-2011 10:04

Re: need help with amxx scripting, would appreciate if you would help me
 
Quote:

Originally Posted by hornet (Post 1519624)
You need a list of questions and a list of answers, each in their own string variable, in corresponding order. It then depends on what kind of ban system your running ... AmxBans? AdvancedBans? ...? Otherwise just stick with kick.

Can you show a example how it should be like?

hornet 07-27-2011 10:11

Re: need help with amxx scripting, would appreciate if you would help me
 
Like this:

PHP Code:

new g_iQuestion33 ];

new const 
g_szQuestions[][] = { "Are you allowed to teamkill?",
                
"Question 2",
                
"Question 3" };
                
new 
g_iAnswers[] = { 21};
//no, yes, yes

public ShowQuestionid )
{
    new 
szMenuStr64 ];
    
g_iQuestionid ] = randomsizeof g_szQuestions);
    
formatszMenuStrcharsmaxszMenuStr ), "\y%s"g_szQuestionsg_iQuestionid ] ] );
    new 
menu menu_createszMenuStr"handleQuestion" );
    
    
menu_additemmenu"Yes""1");
    
menu_additemmenu"No""2");
    
    
menu_setpropmenuMPROP_EXITMEXIT_NEVER );
    
menu_displayidmenu); 
}

public 
handleQuestionidmenuitem )
{
    new 
data], szName32 ];
    new 
accesscallback;
    
menu_item_getinfomenuitemaccessdatacharsmaxdata ), szNamecharsmaxszName ), callback );
    
    new 
key str_to_numdata );
    
    if( 
key != g_iAnswersg_iQuestionid ] ] )
    {
        
server_cmd"kick #%d ^"You failed to answer the question correctly^""id );
    }



ajjt 07-28-2011 15:38

PHP Code:

new g_iQuestion33 ];

new const 
g_szQuestions[][] = { "Are you allowed to teamkill?",
                
"Question 2",
                
"Question 3" };
                
new 
g_iAnswers[] = { 21};
//no, yes, yes

public ShowQuestionid )
{
    new 
szMenuStr64 ];
    
g_iQuestionid ] = randomsizeof g_szQuestions);
    
formatszMenuStrcharsmaxszMenuStr ), "\y%s"g_szQuestionsg_iQuestionid ] ] );
    new 
menu menu_createszMenuStr"handleQuestion" );
    
    
menu_additemmenu"Yes""1");
    
menu_additemmenu"No""2");
    
    
menu_setpropmenuMPROP_EXITMEXIT_NEVER );
    
menu_displayidmenu); 
}

public 
handleQuestionidmenuitem )
{
    new 
data], szName32 ];
    new 
accesscallback;
    
menu_item_getinfomenuitemaccessdatacharsmaxdata ), szNamecharsmaxszName ), callback );
    
    new 
key str_to_numdata );
    
    if( 
key != g_iAnswersg_iQuestionid ] ] )
    {
        
server_cmd"kick #%d ^"You failed to answer the question correctly^""id );
    }

new 
g_iQuestion33 ];

new const 
g_szQuestions[][] = { "Are you allowed to freekill?",
                
"Question 2",
                
"Question 3" };
                
new 
g_iAnswers[] = { 21};
//no, yes, yes

public ShowQuestionid )
{
    new 
szMenuStr64 ];
    
g_iQuestionid ] = randomsizeof g_szQuestions);
    
formatszMenuStrcharsmaxszMenuStr ), "\y%s"g_szQuestionsg_iQuestionid ] ] );
    new 
menu menu_createszMenuStr"handleQuestion" );
    
    
menu_additemmenu"Yes""1");
    
menu_additemmenu"No""2");
    
    
menu_setpropmenuMPROP_EXITMEXIT_NEVER );
    
menu_displayidmenu); 
}

public 
handleQuestionidmenuitem )
{
    new 
data], szName32 ];
    new 
accesscallback;
    
menu_item_getinfomenuitemaccessdatacharsmaxdata ), szNamecharsmaxszName ), callback );
    
    new 
key str_to_numdata );
    
    if( 
key != g_iAnswersg_iQuestionid ] ] )
    {
        
server_cmd"kick #%d ^"You failed to answer the question correctly^""id );
    } 

So basically I am gonna continue like that, but I want people to only answer 1 question when they join.
And how do I change the answer?

EDIT:

Should it be like that.

EDIT:

I get 8 errors with the code you showed,epic


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

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