Думаю лучше переделать версию 1.0, она самая простая и безглючная
Код:
/*
Number Quiz v1.0
----------------
At each round start, a quiz consisting of addition or subtraction of two numbers will shown in the chat.
The first alive player to answer the quiz will win an HP award.
cvar: quiz_hp ( default = 20 )
*/
#include <amxmodx>
#include <fun>
#define PLUGIN "Number Quiz"
#define VERSION "1.0"
#define AUTHOR "connoisseur"
#define TAG "[Number Quiz]"
new g_iAnswer
new bool:g_answered
new hp_cvar
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
hp_cvar = register_cvar("quiz_hp", "20")
register_logevent("eventRoundStart", 2, "1=Round_Start")
register_clcmd("say", "hookSay")
register_clcmd("say_team", "hookSay")
}
public eventRoundStart()
{
g_answered = false
client_print( 0, print_chat, "%s %s = ?", TAG, generateQuiz() )
}
public hookSay(id)
{
if( !g_answered )
{
new szArgs[7]
new szAns[7]
read_args( szArgs, charsmax( szArgs ) )
remove_quotes( szArgs )
num_to_str( g_iAnswer, szAns, charsmax( szAns ) )
if( !strcmp( szArgs, szAns ) )
{
if( is_user_alive(id) )
{
g_answered = true
new szNick[32]
get_user_name(id, szNick, charsmax( szNick ) )
new hp = get_pcvar_num( hp_cvar )
set_user_health( id, get_user_health(id) + hp )
client_print( 0, print_chat, "%s %s got %iHP for correct answer ^"%i^"", TAG, szNick, hp, g_iAnswer )
}
}
}
return PLUGIN_CONTINUE
}
generateQuiz()
{
new iOperand[2]
new charOP
new szQuiz[10]
iOperand[0] = random_num( 1, 100 )
iOperand[1] = random_num( 1, 100 )
charOP = random_num( 0, 1 ) ? '+' : '-'
if ( charOP == '+' )
g_iAnswer = iOperand[0] + iOperand[1]
else
g_iAnswer = iOperand[0] - iOperand[1]
formatex( szQuiz, charsmax( szQuiz ), "%i %c %i", iOperand[0], charOP, iOperand[1] )
return szQuiz
}