|
Junior Member
|

07-28-2011
, 15:38
|
#2
|
PHP Code:
new g_iQuestion[ 33 ];
new const g_szQuestions[][] = { "Are you allowed to teamkill?",
"Question 2",
"Question 3" };
new g_iAnswers[] = { 2, 1, 1 };
//no, yes, yes
public ShowQuestion( id )
{
new szMenuStr[ 64 ];
g_iQuestion[ id ] = random( sizeof g_szQuestions);
format( szMenuStr, charsmax( szMenuStr ), "\y%s", g_szQuestions[ g_iQuestion[ id ] ] );
new menu = menu_create( szMenuStr, "handleQuestion" );
menu_additem( menu, "Yes", "1", 0 );
menu_additem( menu, "No", "2", 0 );
menu_setprop( menu, MPROP_EXIT, MEXIT_NEVER );
menu_display( id, menu, 0 );
}
public handleQuestion( id, menu, item )
{
new data[ 6 ], szName[ 32 ];
new access, callback;
menu_item_getinfo( menu, item, access, data, charsmax( data ), szName, charsmax( szName ), callback );
new key = str_to_num( data );
if( key != g_iAnswers[ g_iQuestion[ id ] ] )
{
server_cmd( "kick #%d ^"You failed to answer the question correctly^"", id );
}
new g_iQuestion[ 33 ];
new const g_szQuestions[][] = { "Are you allowed to freekill?",
"Question 2",
"Question 3" };
new g_iAnswers[] = { 2, 1, 1 };
//no, yes, yes
public ShowQuestion( id )
{
new szMenuStr[ 64 ];
g_iQuestion[ id ] = random( sizeof g_szQuestions);
format( szMenuStr, charsmax( szMenuStr ), "\y%s", g_szQuestions[ g_iQuestion[ id ] ] );
new menu = menu_create( szMenuStr, "handleQuestion" );
menu_additem( menu, "Yes", "1", 0 );
menu_additem( menu, "No", "2", 0 );
menu_setprop( menu, MPROP_EXIT, MEXIT_NEVER );
menu_display( id, menu, 0 );
}
public handleQuestion( id, menu, item )
{
new data[ 6 ], szName[ 32 ];
new access, callback;
menu_item_getinfo( menu, item, access, data, charsmax( data ), szName, charsmax( szName ), callback );
new key = str_to_num( data );
if( key != g_iAnswers[ g_iQuestion[ id ] ] )
{
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
Last edited by Exolent[jNr]; 07-28-2011 at 21:19.
Reason: Triplepost.
|
|