- 15.01.2024
- 5
- 0
Блин помогите пожалуйста,рассталкуйте.
Запускаю плагин а он ругается, прописал дебаг выдал строки но не понимаю вроде все нормально там.
bonpref.sma:
#include <amxmodx>
#include <sqlx>
native aes_add_player_exp(id,exp,override = 0);
native aes_add_player_bonus(id,bonus,plug[] = "bonpref");
native ar_add_user_anew(admin,id,bonus);
native ar_set_user_addxp(id,experience);
new Handle:g_sql = Empty_Handle;
new fw_load_bonpref;
new chat_addons_prefix;
enum eInfo { ai, count }
new bonus[33][eInfo];
new exp[33][eInfo];
new ammo[33][eInfo];
new msg_SayText;
new aes_exp, aes_bonus, ar_exp, ar_bonus;
public native_filter( const name[], index, trap )
{
if( equal( name, "aes_add_player_exp" ) )
{
aes_exp = true;
} else if( equal( name, "aes_add_player_bonus" ) )
{
aes_bonus = true;
} else if( equal( name, "ar_set_user_addxp" ) )
{
ar_exp = true;
} else if( equal( name, "ar_add_user_anew" ) )
{
ar_bonus = true;
}
return PLUGIN_HANDLED_MAIN;
}
public get_bonpref( id )
{
if( !is_user_connected( id ) ) {
return PLUGIN_CONTINUE;
}
if( bonus[id][count] > 0 )
{
if( add_bonus(id,bonus[id][count]) )
{
native_used_bonpref( id, bonus[id][ai] );
ChatColor( id, "^4[^1bonpref^4] ^3Вы получили бонусы %i", bonus[id][count] );
bonus[id][count] = 0
return PLUGIN_CONTINUE;
}
}
if( exp[id][count] > 0 )
{
if( add_exp(id,exp[id][count]) )
{
native_used_bonpref( id, exp[id][ai] );
ChatColor( id, "^4[^1bonpref^4] ^3Вы получили опыт %i", exp[id][count] );
exp[id][count] = 0
return PLUGIN_CONTINUE;
}
}
/* if( ammo[id][count] > 0 )
{
if( add_ammo(id,ammo[id][count]) )
{
native_used_bonpref( id, ammo[id][ai] );
ChatColor( id, "^4[^1bonpref^4] ^3Вы получили аммопак %i", ammo[id][count] );
ammo[id][count] = 0
return PLUGIN_CONTINUE;
}
} */
ChatColor( id, "^4[^1bonpref^4] ^3Увы, активных покупок у вас нет" );
return PLUGIN_CONTINUE;
}
stock bool:add_bonus(id,icnt)
{
if( !aes_bonus )
{
aes_add_player_bonus( id, icnt );
return true;
} else if( !ar_bonus )
{
ar_add_user_anew( -1, id, icnt );
return true;
}
return false;
}
stock bool:add_exp(id,icnt)
{
if( !aes_exp )
{
aes_add_player_exp( id, icnt );
return true;
} else if( !ar_exp )
{
ar_set_user_addxp( id, icnt );
return true;
}
return false;
}
stock bool:add_ammo(id,icnt)
{
return false;
}
public plugin_init( )
{
register_plugin("bonprefs loader", "0.1", "ko1dun");
register_clcmd("say /bonpref", "get_bonpref")
msg_SayText = get_user_msgid("SayText");
// new_boom()
fw_load_bonpref = CreateMultiForward("fw_load_bonpref", ET_IGNORE, FP_CELL, FP_CELL, FP_STRING, FP_STRING);
chat_addons_prefix = CreateMultiForward("chat_addons_prefix", ET_IGNORE, FP_CELL, FP_STRING);
new szConfigsDir[64];
get_localinfo("amxx_configsdir", szConfigsDir, charsmax(szConfigsDir));
server_cmd("exec %s/sql.cfg", szConfigsDir);
server_exec();
new error[128], res;
g_sql = SQL_MakeStdTuple()
new Handle:sql = SQL_Connect(g_sql, res, error, charsmax(error))
if( sql == Empty_Handle )
{
log_amx( "[SQLX sql error] %s ", error );
g_sql = Empty_Handle;
return PLUGIN_CONTINUE;
}
SQL_FreeHandle( sql );
SQL_SetCharset( g_sql, "utf8" );
SQL_ThreadQuery( g_sql, "QueryHandler", "CREATE TABLE IF NOT EXISTS `bonpref_module` (\
`id` int(11) NOT NULL AUTO_INCREMENT,\
`user_id` int(3) NOT NULL DEFAULT '0',\
`authid` varchar(32) NOT NULL,\
`efield` varchar(32) NOT NULL,\
`etype` varchar(32) NOT NULL,\
`estate` int(11) NOT NULL DEFAULT '0',\
`created_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\
`expire_date` timestamp NULL DEFAULT NULL,\
PRIMARY KEY (`id`)\
) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
return PLUGIN_CONTINUE;
}
public client_putinserver( id ) {
if( is_user_connected( id ) )
{
new szQuery[256], cData[1], steam[MAX_AUTHID_LENGTH];
// clear
arrayset(bonus[id], 0, eInfo);
arrayset(exp[id], 0, eInfo);
arrayset(ammo[id], 0, eInfo);
get_user_authid( id, steam, charsmax(steam) ); cData[0] = id;
formatex(szQuery, charsmax(szQuery),
"SELECT * FROM `bonpref_module` WHERE \
`authid` = '%s' AND `estate` != 1 \
AND (`expire_date` > FROM_UNIXTIME('%d') OR `expire_date` IS NULL)",
steam, get_systime()
)
SQL_ThreadQuery(g_sql, "SqlLoad", szQuery, cData, sizeof cData);
}
}
public QueryHandler(failstate, Handle:query, error[], errnum, data[], size, Float:queuetime) {
if(failstate != TQUERY_SUCCESS)
{
log_amx("QueryHandler(): %s %d", error, errnum)
}
}
public SqlLoad(failstate, Handle:query, error[], errnum, data[], size, Float:queuetime)
{
if( failstate != TQUERY_SUCCESS ) {
log_amx("SqlLoad() %s %d", error, errnum)
return
}
new id = data[0];
if( !is_user_connected(id) ) {
return
}
new ret;
if( !SQL_NumRows(query) ) {
ExecuteForward( fw_load_bonpref, ret, id, 0, "0", "[all]" );
return
}
new field_id, field_str[32], field_type[32];
while(SQL_MoreResults(query))
{
field_id = SQL_ReadResult( query, SQL_FieldNameToNum(query, "id") );
SQL_ReadResult( query, SQL_FieldNameToNum(query, "efield"), field_str, charsmax(field_str) );
SQL_ReadResult( query, SQL_FieldNameToNum(query, "etype"), field_type, charsmax(field_type) );
ExecuteForward( fw_load_bonpref, ret, id, field_id, field_str, field_type );
SendTypeField( id, field_id, field_type, field_str );
SQL_NextRow( query );
}
}
SendTypeField( const id, const field_id, const field_type[], const field_str[] )
{
if( equal(field_type,"prefix") )
{
new ret; ExecuteForward(chat_addons_prefix, ret, id, field_str );
} else if( equal(field_type,"bonus") )
{
bonus[id][ai] = field_id;
bonus[id][count] = str_to_num(field_str);
} else if( equal(field_type,"experience") )
{
exp[id][ai] = field_id;
exp[id][count] = str_to_num(field_str);
} else if( equal(field_type,"ammopack") )
{
ammo[id][ai] = field_id;
ammo[id][count] = str_to_num(field_str);
}
}
public plugin_natives()
{
set_native_filter( "native_filter" );
register_native( "used_bonpref", "native_used_bonpref", true );
}
public native_used_bonpref( id, field_id )
{
new szQuery[72];
formatex(szQuery, charsmax(szQuery), "UPDATE `bonpref_module` SET `estate`=1 WHERE `id` = %i", field_id )
SQL_ThreadQuery( g_sql, "SqlUpdate", szQuery );
}
public SqlUpdate(failstate, Handle:query, error[], errnum, data[], size, Float:queuetime)
{
if( failstate != TQUERY_SUCCESS ) {
log_amx("SqlUpdate() %s %d", error, errnum);
}
}
public plugin_end()
{
SQL_FreeHandle(g_sql)
}
stock ChatColor(const id, const input[], any:...)
{
static msg[191]
vformat(msg, 190, input, 3)
replace_all(msg, 190, "!g", "^4") // Green Color
replace_all(msg, 190, "!y", "^1") // Default Color
replace_all(msg, 190, "!team", "^3") // Team Color
replace_all(msg, 190, "!team2", "^0") // Team2 Color
if(is_user_connected(id))
{
message_begin(MSG_ONE_UNRELIABLE, msg_SayText, _, id)
write_byte(id);
write_string(msg);
message_end();
}
}