Проблема с форумным плагином.

Статус
В этой теме нельзя размещать новые ответы.
Сообщения
6
Реакции
0
Ошибка
L 06/04/2020 - 19:21:29: String formatted incorrectly - parameter 4 (total 3)
L 06/04/2020 - 19:21:29: [AMXX] Displaying debug trace (plugin "report_to_forum.amxx", version "0.3b")
L 06/04/2020 - 19:21:29: Ошибка плагина 25: parameter error
L 06/04/2020 - 19:21:29: [AMXX] [0] report_to_forum.sma::SendForumPost (line 414)
L 06/04/2020 - 19:21:29: [AMXX] [1] report_to_forum.sma::SendReport (line 374)
L 06/04/2020 - 19:21:29: [AMXX] [2] report_to_forum.sma::ReportReasonHandler (line 301)
ОС
Linux
Amx Mod X
AMX Mod X 1.9.0-dev+5210 (http://www.amxmodx.org)
Билд
ReHLDS version: 3.4.0.668-dev
Build date: 09:47:42 Sep 29 2018 (1631)
Build from: https://github.com/dreamstalker/rehlds/commit/89be216
ReGamedll
ReGameDLL version: 5.13.0.447-dev+m
Build date: 18:11:04 Jan 15 2020
Build from: https://github.com/s1lentq/ReGameDLL_CS/commit/2eba3b1
Версия Metamod
Metamod-r v1.3.78, API (5:13)
Metamod-r build: 14:04:19 Jul 21 2017 (1.3.78)
Metamod-r from: https://github.com/theAsmodai/metamod-r/commit/7ffbf8f (asmodai)
Список метамодулей
[ 1] AMX Mod X RUN - amxmodx_mm_i386. v1.9.0-d ini Start ANY
[ 2] Reunion RUN - reunion_mm_i386. v0.1.75 ini Start Never
[ 3] Rechecker RUN - rechecker_mm_i38 v2.3 ini Chlvl ANY
[ 4] Revoice RUN - revoice_mm_i386. v0.1.0.3 ini Start Never
[ 5] ReSemiclip RUN - resemiclip_mm_i3 v2.3.9 ini Chlvl ANY
[ 6] ReAPI RUN - reapi_amxx_i386. v5.8.0.1 pl1 ANY Never
[ 7] Engine RUN - engine_amxx_i386 v1.9.0-d pl1 ANY ANY
[ 8] FakeMeta RUN - fakemeta_amxx_i3 v1.9.0-d pl1 ANY ANY
[ 9] MySQL RUN - mysql_amxx_i386. v1.9.0-d pl1 ANY ANY
[10] Ham Sandwich RUN - hamsandwich_amxx v1.9.0-d pl1 ANY ANY
[11] CSX RUN - csx_amxx_i386.so v1.9.0-d pl1 ANY ANY
Список плагинов
[ 1] [190] AMXBans RBS 20.03.19BE SKAJIbnEJIb & La amxbans_rbs.amx работает
[ 2] block ip 0.2 legenda amx_blockip.amx работает
[ 3] Slots Reservation 1.9.0-dev+ AMXX Dev Team adminslots.amxx работает
[ 4] Commands Menu 1.9.0-dev+ AMXX Dev Team cmdmenu.amxx работает
[ 5] Maps Menu 1.9.0-dev+ AMXX Dev Team mapsmenu.amxx работает
[ 6] Plugin Menu 1.9.0-dev+ AMXX Dev Team pluginmenu.amxx работает
[ 7] Admin Chat 1.9.0-dev+ AMXX Dev Team adminchat.amxx работает
[ 8] Anti Flash 1.3 Crush32 antiflash.amxx работает
[ 9] [190] NextMap 18.09.25 SKAJIbnEJIb & AM nextmap.amxx работает
[ 10] [190] TimeLeft 18.09.25 SKAJIbnEJIb & AM timeleft.amxx работает
[ 11] Pause Plugins 1.9.0-dev+ AMXX Dev Team pausecfg.amxx работает
[ 12] [ReAPI] Block 'Fire in 0.0.1 sergrib reapi_block_FIT работает
[ 13] RelaX_GAG 1.4.9 B.A.R.I.G.A. amx_gag.amxx работает
[ 14] Auto recording demo 2.0 IzI | Bonaqua (R amx_autodemorec работает
[ 15] mute menu 1.0 cheap_suit Mute_Menu.amxx работает
[ 16] [190] CsStats ResetSco 20.03.16 SKAJIbnEJIb csstats_resetsc работает
[ 17] [182] Parachute RBS 17.12.12 KRoT@L/JTP10181 parachute_rbs.a работает
[ 18] [183] Ad From Server 19.08.29 SKAJIbnEJIb ad_from_server. работает
[ 19] [190] AdminCmd RBS 20.03.20 SKAJIbnEJIb & AM admincmd_rbs.am работает
[ 20] Menus Front-End 18.12.18 AMXX Dev Team & amxmodmenu_rbs. работает
[ 21] [190] Chat RBS 19.12.23 SKAJIbnEJIb chat_rbs.amxx работает
[ 22] [183] Chat Addons 19.08.01 SKAJIbnEJIb chat_addons.amx работает
[ 23] [183] Damager RBS 19.08.30 SKAJIbnEJIb damager_rbs.amx работает
[ 24] [183] Kill Assist RBS 19.11.14 SKAJIbnEJIb & Di killassist_rbs. работает
[ 25] [190] MapChooser RBS 20.03.16 SKAJIbnEJIb & UF mapchooser_rbs. работает
[ 26] [190] Screen Player 20.03.20 SKAJIbnEJIb screen_player.a работает
[ 27] [190] VIP RBS 19.12.09 SKAJIbnEJIb vip_rbs.amxx работает
[ 28] [190] Warmup RBS 19.12.23 SKAJIbnEJIb warmup_rbs.amxx работает
[ 29] Voteban CSR 0.8.5beta Leo_[BH] csr_voteban.amx работает
[ 30] NEW_SKY 0.1 B.A.R.I.G.A. NEW_SKY.amxx работает
[ 31] [183] Ultimate Informe 17.10.30 SKAJIbnEJIb ultimate_inform работает
[ 32] [183] AR Pogony 17.10.30 SKAJIbnEJIb ar_pogony.amxx работает
[ 33] [190] Army Ranks Ultim 19.11.29 SKAJIbnEJIb army_ranks_ulti работает
[ 34] [183] Skill ELO 19.09.06 SKAJIbnEJIb skill_elo.amxx работает
[ 35] [183] CsStats MySQL 19.08.27 SKAJIbnEJIb csstats_mysql.a работает
[ 36] [183] Stats Configurat 18.05.15 SKAJIbnEJIb & AM statscfg_rbs.am работает
[ 37] [183] StatsX RBS 19.08.28 SKAJIbnEJIb & AM statsx_rbs.amxx работает
[ 38] Report To Forum 0.3b voed report_to_forum debug
Автор плагина
voed
Версия плагина
0.3b
Исходный код
/*This is a port sourcemod's "Report to Forums" plugin to AMX Mod X
Original plugin: http://forums.alliedmods.net/showthread.php?t=211126
Lastest verion of this plugin: http://c-s.net.ua/forum/topic69543s0.html
Author: voed
Special thanks: me <3, AndrewZ, Bloo
*/

#include <amxmodx>
#include <amxmisc>
#include <sqlx>
#include <report_to_forum>

#define DEBUG
//#define VOTEBAN_MODE
#define CONFIG_DIR "/report_to_forum/report_to_forum.cfg"
#define LOG_DIR "/report_to_forum/logs.txt"
#define LOG_FILE_SIZE 50 //maximum logfile size in kB

#if AMXX_VERSION_NUM < 183
#define MAX_NAME_LENGTH 33
#endif

new const PLUGIN_NAME[] = "Report To Forum";
new const PLUGIN_AUTHOR[] = "voed";
new const PLUGIN_VERSION[] = "0.3b";

new g_Reasons[][]={ "Wallhack",
"AIMBot",
"MultiCheat" }

enum SupportedForums
{
FORUM_UNSUPPORTED,
FORUM_VB4,
FORUM_MYBB,
FORUM_SMF,
FORUM_PHPBB,
FORUM_WBBLITE,
FORUM_AEF,
FORUM_USEBB,
FORUM_XMB,
FORUM_IPBOARDS,
FORUM_XENFORO
}

/* Plugin ConVars */
new g_Cvar_TablePrefix
new g_Cvar_ForumSoftwareID
new g_Cvar_VPSTimeDiff
new g_MySQL_User, g_MySQL_Pass, g_MySQL_Host, g_MySQL_DB

new g_Cvar_ForumID;
new g_Cvar_SenderID;
new g_Cvar_UserName ;
new g_Cvar_Email;
new g_Cvar_AdminFlag;
new g_Cvar_Delay;

/* Post Info */
new g_szPostTitle[512];
new g_szPostMessage[512];

/* Misc Variables */
new SupportedForums:g_iForumSoftwareID;
new g_iForumID;
new g_iThreadID;
new g_iPostID;
new g_iPostCount;
new g_iUserPostCount;
new g_iThreadCount;
new g_iSenderID;
new g_szTablePrefix[32];
new g_iTimeStamp;

new Handle:g_SqlTuple
new g_Error[512]
new Handle:SqlConnection

new g_pHostName
new g_iTarget[33]

new g_szUserName[MAX_NAME_LENGTH];
new g_szEmail[64];
new g_szHostName[64];
new g_szMapName[64];

new g_LogDir[128];

new bool:g_UserSteam[33];
new Float:g_fLastReport[33];

public plugin_init()
{
register_plugin( PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR )

/* RTF Version */
register_cvar( "rtf_version", PLUGIN_VERSION, FCVAR_SPONLY | FCVAR_SERVER );

/* Plugin ConVars */
g_Cvar_ForumSoftwareID = register_cvar( "rtf_forum_softwareid", "4" ); // Forum Software ID.
g_Cvar_VPSTimeDiff = register_cvar( "rtf_vps_time_diff", "0"); // Time difference used for VPS servers.

g_Cvar_ForumID = register_cvar( "rtf_forum_id", "22" ) // Forum ID to post the report
g_Cvar_SenderID = register_cvar( "rtf_sender_id", "2" ) // Sender ID to post under.
g_Cvar_UserName = register_cvar( "rtf_username", "RelaXbot" ) // Sender User Name to use.
g_Cvar_Email = register_cvar( "rtf_email", "" ) // Sender Email Address. (Optional)
g_Cvar_AdminFlag = register_cvar( "rtf_adminflag", "q" ) // Only Post if no admin is available.
g_Cvar_Delay = register_cvar( "rtf_report_delay", "1" ) // Cooldown on using report command (in minutes)

g_MySQL_Host = register_cvar( "rtf_host", "127.0.0.1" )
g_MySQL_User = register_cvar( "rtf_user", "user" )
g_MySQL_Pass = register_cvar( "rtf_pass", "pass" )
g_MySQL_DB = register_cvar( "rtf_database", "user_db" )
g_Cvar_TablePrefix = register_cvar( "rtf_table_prefix", "" ) // Prefix to the tables in your forums database.

#if defined VOTEBAN_MODE
register_clcmd( "say /rp", "SayReport" )
#else
register_clcmd( "say /rp", "SayReport" )
#endif

g_pHostName = get_cvar_pointer( "hostname" )

register_dictionary( "report_to_forum.txt" )

new cdir[ 64 ], cfg_dir[ 64 ]
get_configsdir( cfg_dir, charsmax( cdir ) )
formatex( cdir, charsmax( cdir ), "%s%s", cfg_dir, CONFIG_DIR )
formatex( g_LogDir, charsmax( g_LogDir ), "%s%s", cfg_dir, LOG_DIR )

rtf_error( 0, "log testing" )

if( file_size( g_LogDir ) > LOG_FILE_SIZE*1024 )
{
delete_file( g_LogDir )
}

if( file_exists( cdir ) )
{
server_cmd( "exec %s", cdir )
server_exec()
}
else
rtf_error( 1, "[RTF] Config file %s does not exists", cdir )


new conn[4][33]
get_pcvar_string( g_MySQL_Host, conn[0], 32)
get_pcvar_string( g_MySQL_User, conn[1], 32)
get_pcvar_string( g_MySQL_Pass, conn[2], 32)
get_pcvar_string( g_MySQL_DB, conn[3], 32 )

SQL_SetAffinity( "mysql" )
g_SqlTuple = SQL_MakeDbTuple( conn[ 0 ], conn[ 1 ], conn[ 2 ], conn[ 3 ] )
#if AMXX_VERSION_NUM < 182
SQL_SetCharset( g_SqlTuple, "utf8" )
#endif

// ok, we're ready to connect
new ErrorCode
SqlConnection = SQL_Connect( g_SqlTuple, ErrorCode, g_Error, charsmax( g_Error ) )
if( SqlConnection == Empty_Handle )
rtf_error( 1, "[MYSQL] %s", g_Error )
}

public plugin_cfg()
{
get_pcvar_string( g_Cvar_UserName, g_szUserName, charsmax( g_szUserName ) )
get_pcvar_string( g_Cvar_Email, g_szEmail, charsmax( g_szEmail ) )
g_iForumID = get_pcvar_num( g_Cvar_ForumID )
g_iSenderID = get_pcvar_num( g_Cvar_SenderID )

/* Cache the Forum Softare ID */
g_iForumSoftwareID = SupportedForums:get_pcvar_num( g_Cvar_ForumSoftwareID )

/* Get the Table Prefix */
get_pcvar_string( g_Cvar_TablePrefix, g_szTablePrefix, charsmax( g_szTablePrefix ) )
get_mapname( g_szMapName, charsmax ( g_szMapName ) )

}

public client_connect( id )
{
g_UserSteam[ id ] = is_user_steam( id )
}
public client_disconnected(id)
{
g_fLastReport[ id ] = 0.0
}

public plugin_end()
{
SQL_FreeHandle( g_SqlTuple )
}

public SayReport(id)
{
new Float:gametime = get_gametime();
if(g_fLastReport[id])
{
new Float:delay = get_pcvar_float(g_Cvar_Delay)*60;
new Float:timeleft = gametime - g_fLastReport[id];
if(timeleft < delay)
{
new Float:rem = (delay - timeleft)
if(floatround(rem/60, floatround_floor))
{
client_print(id, print_chat, "%L", id, "RTF_CANT_USE_MINUTES", rem/60)
}
else
{
client_print(id, print_chat, "%L", id, "RTF_CANT_USE_SECONDS", rem)
}

return PLUGIN_HANDLED
}
}

g_fLastReport[id] = gametime;
new title[128]
formatex(title, charsmax(title), "%L", id, "RTF_MENU_CHOOSE_PLAYER")
new i_Menu = menu_create(title, "SayReportHandler", 1)

new s_Players[32], i_Num, i_Player
new s_Name[33], s_Player[10]
new flags[32]
get_pcvar_string(g_Cvar_AdminFlag, flags, charsmax(flags))
get_players(s_Players, i_Num, "ch")

for (new i; i < i_Num; i++)
{
i_Player = s_Players[i]
#if !defined(DEBUG)
if (i_Player == id)
continue

if(flags[0] && (get_user_flags(i_Player) & read_flags(flags)))
{
client_print(id, print_chat, "%L", id, "RTF_ADMINS_ONLINE")
menu_destroy(i_Menu)
return PLUGIN_HANDLED
}
#endif
get_user_name(i_Player, s_Name, charsmax(s_Name))
num_to_str(i_Player, s_Player, charsmax(s_Player))
menu_additem(i_Menu, s_Name, s_Player, 0)
}

menu_display(id, i_Menu, 0)
return PLUGIN_HANDLED
}

public SayReportHandler(id, menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}

new s_Data[6], i_Access, i_Callback
menu_item_getinfo(menu, item, i_Access, s_Data, charsmax(s_Data), _, _, i_Callback )

g_iTarget[id] = str_to_num(s_Data)

ReportReason(id)

menu_destroy(menu)
return PLUGIN_HANDLED

}

public ReportReason(id)
{
new title[128]
formatex(title, charsmax(title), "%L", id, "RTF_MENU_CHOOSE_REASON")
new i_Menu = menu_create(title, "ReportReasonHandler", 1)

for(new i=0; i<sizeof(g_Reasons); i++)
{
new key[4]
num_to_str(i, key, charsmax(key))
menu_additem(i_Menu, g_Reasons[i], key)
}

menu_display(id, i_Menu, 0)
return PLUGIN_HANDLED
}

public ReportReasonHandler(id, menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}

new s_Data[6], s_Name[32], i_Access, i_Callback
menu_item_getinfo(menu, item, i_Access, s_Data, charsmax(s_Data), s_Name, charsmax(s_Name), i_Callback )

SendReport(id, g_iTarget[id], s_Name)

menu_destroy(menu)
return PLUGIN_HANDLED
}
public SendReport(sender_id, target_id, reason[])
{
new szReason[64]
if((!sender_id) || (!target_id) || (!reason[0]))
return PLUGIN_HANDLED

formatex(szReason, charsmax(szReason), reason)
new sender_name[32], name[32], steamid[32], ip[16]
get_user_name(target_id, name, charsmax(name))
get_user_name(sender_id, sender_name, charsmax(sender_name))
get_user_authid(target_id, steamid, charsmax(steamid))
get_user_ip(target_id, ip, charsmax(ip), 1)
get_pcvar_string( g_pHostName, g_szHostName, 63 );
new br[10]
if(g_iForumSoftwareID == FORUM_IPBOARDS)
{
formatex(br, charsmax(br), "<br />")
}
else
{
formatex(br, charsmax(br), "^n")
}

formatex(g_szPostTitle, charsmax(g_szPostTitle), "%s %L %s", name, LANG_SERVER, "RTF_REPORTED_FOR", szReason)
formatex(g_szPostMessage, charsmax(g_szPostMessage), "%L %s%s", LANG_SERVER, "RTF_HOST_NAME", g_szHostName, br)
format(g_szPostMessage, charsmax(g_szPostMessage), "%s%L %s%s", g_szPostMessage, LANG_SERVER, "RTF_SENDER_NAME", sender_name, br)
format(g_szPostMessage, charsmax(g_szPostMessage), "%s%L %s%s", g_szPostMessage, LANG_SERVER, "RTF_NAME", name, br)

if(g_UserSteam[target_id])
{
new url[64]
rtf_get_steamurl(steamid, url, charsmax(url))
format(g_szPostMessage, charsmax(g_szPostMessage), "%s%L %s ", g_szPostMessage, LANG_SERVER, "RTF_STEAMID", steamid)
format(g_szPostMessage, charsmax(g_szPostMessage), "%s[url=%s %L [/url]%s", g_szPostMessage, url, LANG_SERVER, "RTF_STEAM_URL", br)
}
else
{
format(g_szPostMessage, charsmax(g_szPostMessage), "%s%L %s%s", g_szPostMessage, LANG_SERVER, "RTF_STEAMID", steamid, br)
}

format(g_szPostMessage, charsmax(g_szPostMessage), "%s%L %s%s", g_szPostMessage, LANG_SERVER, "RTF_IP", ip, br)
format(g_szPostMessage, charsmax(g_szPostMessage), "%s%L %s", g_szPostMessage, LANG_SERVER, "RTF_REASON", szReason)

GetWebSafeString(g_szPostTitle, charsmax(g_szPostTitle));
GetWebSafeString(g_szUserName, charsmax(g_szUserName));
mysql_escape_string(g_szPostTitle, charsmax(g_szPostTitle));
mysql_escape_string(g_szUserName, charsmax(g_szUserName));
mysql_escape_string(g_szPostMessage, charsmax(g_szPostMessage));

g_iTimeStamp = (get_systime() - get_pcvar_num(g_Cvar_VPSTimeDiff));

if(!g_szTablePrefix[0])
{
switch(g_iForumSoftwareID)
{
//case FORUM_VB4:
//case FORUM_MYBB:
case FORUM_SMF:g_szTablePrefix = "smf_"
case FORUM_PHPBB:g_szTablePrefix = "phpbb_"
//case FORUM_WBBLITE:
//case FORUM_AEF:
//case FORUM_USEBB:
//case FORUM_XMB:
//case FORUM_IPBOARDS:
case FORUM_XENFORO:g_szTablePrefix = "xf_"
}
}

SendForumPost()
FindRecentThread()
CreateThreadPost()
if(g_iForumSoftwareID != FORUM_MYBB)
{
GetPostId()
SetPostId()
}

GetCurrentForumPostData()
UpdateForumPostCount(g_iThreadCount, g_iPostCount)

GetUserPostInfo();
UpdateUserPostCount(g_iUserPostCount);

client_print(sender_id, print_chat, "%L", sender_id, "RTF_REPORT_SENDED")
return PLUGIN_HANDLED
}

public SendForumPost()
{
new szSeoTitle[256], szSeoName[64]
formatex(szSeoTitle, charsmax(szSeoTitle), "%s", g_szPostTitle, charsmax(g_szPostTitle))
SeoTitle(szSeoTitle, charsmax(szSeoTitle))

formatex(szSeoName, charsmax(szSeoName), "%s", g_szUserName, charsmax(g_szUserName))
SeoTitle(szSeoName, charsmax(szSeoName))

new szSQLQuery[1024]
switch(g_iForumSoftwareID)
{
case FORUM_VB4:
formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %sthread (title, lastpost, forumid, open, postusername, postuserid, lastposter, lastposterid, dateline, visible) VALUES ('%s', '%d', '%d', '1', '%s', '%d', '%s', '%d', '%d', '1');", g_szTablePrefix, g_szPostTitle, g_iTimeStamp, g_iForumID, g_szUserName, g_iSenderID, g_szUserName, g_iSenderID, g_iTimeStamp);
case FORUM_MYBB:
formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %sthreads (fid, subject, uid, username, dateline, firstpost, lastpost, visible) VALUES ('%d', '%s', '%d', '%s', '%d', '1', '%d', '1');", g_szTablePrefix, g_iForumID, g_szPostTitle, g_iSenderID, g_szUserName, g_iTimeStamp, g_iTimeStamp);
case FORUM_SMF:
formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %stopics (id_board, approved) VALUES ('%d', '1');", g_szTablePrefix, g_iForumID);

case FORUM_PHPBB:
{
formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %stopics (forum_id, topic_title, topic_poster, topic_time, topic_views, topic_first_poster_name, topic_first_poster_colour, topic_last_poster_id, topic_last_poster_name, topic_last_post_subject, topic_last_post_time, topic_last_view_time, topic_posts_approved)")
format(szSQLQuery, charsmax(szSQLQuery), "%s VALUES ('%d', '%s', '%d', '%d', '1', '%s', 'AA0000', '%d', '%s', '%s', '%d', '%d', '1');", szSQLQuery, g_szTablePrefix, g_iForumID, g_szPostTitle, g_iSenderID, g_iTimeStamp, g_szUserName, g_iSenderID, g_szUserName, g_szPostTitle, g_iTimeStamp, g_iTimeStamp);
}

case FORUM_WBBLITE:
formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %sthread (boardID, topic, time, userID, username, lastPostTime, lastPosterID, lastPoster) VALUES ('%d', '%s', '%d', '%d', '%s', '%d', '%d', '%s');", g_szTablePrefix, g_iForumID, g_szPostTitle, g_iTimeStamp, g_iSenderID, g_szUserName, g_iTimeStamp, g_iSenderID, g_szUserName);
case FORUM_AEF:
formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %stopics (topic, t_bid, t_status, t_mem_id, t_approved) VALUES ('%s', '%d', '1', '%d', '1');", g_szTablePrefix, g_szPostTitle, g_iForumID, g_iSenderID);
case FORUM_USEBB:
formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %stopics (forum_id, topic_title) VALUES ('%d', '%s');", g_szTablePrefix, g_iForumID, g_szPostTitle);
case FORUM_XMB:
formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %sthreads (fid, subject, author) VALUES ('%d', '%s', '%s');", g_szTablePrefix, g_iForumID, g_szPostTitle, g_szUserName);
case FORUM_IPBOARDS:
{
formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %stopics (title, state, posts, starter_id, start_date, last_poster_id, last_post, starter_name, last_poster_name, poll_state, last_vote, views, forum_id, approved, author_mode, pinned, title_seo, seo_first_name, seo_last_name, last_real_post)", g_szTablePrefix)
format(szSQLQuery, charsmax(szSQLQuery), "%s VALUES ('%s', 'open', '1', '%d', '%d', '%d', '%d', '%s', '%s', '0', '0', '1','%d', '1', '1', '0', '%s', '%s', '%s', '%d');", szSQLQuery, g_szPostTitle, g_iSenderID, g_iTimeStamp, g_iSenderID, g_iTimeStamp, g_szUserName, g_szUserName, g_iForumID, szSeoTitle, szSeoName, szSeoName, g_iTimeStamp);
}
case FORUM_XENFORO:
formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %sthread (node_id, title, reply_count, view_count, user_id, username, post_date, last_post_date, discussion_state, last_post_id, last_post_user_id, last_post_username) VALUES ('%d', '%s', '0', '0', '%d', '%s', '%d', '%d', 'visible', '%d', '%d', '%s');", g_szTablePrefix, g_iForumID, g_szPostTitle, g_iSenderID, g_szUserName, g_iTimeStamp, g_iTimeStamp, g_iForumID, g_iSenderID, g_szUserName);
}
new Handle:Query = SQL_PrepareQuery(SqlConnection, szSQLQuery);
if(!SQL_Execute(Query))
{
// if there were any problems
SQL_QueryError(Query,g_Error,511)
rtf_error(0, "[MYSQL] Cant create thread. Error: %s", g_Error)
}
// close the handle
SQL_FreeHandle(Query)
}


/* Finds the Thread ID for the thread we just created */
public FindRecentThread()
{
if (g_Error[0])
return

new szSQLQuery[512];
switch(g_iForumSoftwareID)
{
case FORUM_VB4:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT threadid FROM %sthread WHERE dateline='%d';", g_szTablePrefix, g_iTimeStamp);
case FORUM_MYBB:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT tid FROM %sthreads WHERE dateline='%d';", g_szTablePrefix, g_iTimeStamp);
case FORUM_SMF:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT MAX(id_topic) FROM %stopics;", g_szTablePrefix);
case FORUM_PHPBB:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT topic_id FROM %stopics WHERE topic_time='%d';", g_szTablePrefix, g_iTimeStamp);
case FORUM_WBBLITE:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT threadID FROM %sthread WHERE time='%d';", g_szTablePrefix, g_iTimeStamp);
case FORUM_AEF:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT MAX(tid) FROM %stopics;", g_szTablePrefix);
case FORUM_USEBB:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT MAX(id) FROM %stopics;", g_szTablePrefix);
case FORUM_XMB:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT tid FROM %stopics WHERE lastpost='%d';", g_szTablePrefix, g_iTimeStamp);
case FORUM_IPBOARDS:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT tid FROM %stopics WHERE last_post='%d';", g_szTablePrefix, g_iTimeStamp);
case FORUM_XENFORO:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT thread_id FROM %sthread WHERE post_date='%d';", g_szTablePrefix, g_iTimeStamp);
}

new Handle:Query = SQL_PrepareQuery(SqlConnection, szSQLQuery);
if(!SQL_Execute(Query))
{
// if there were any problems
SQL_QueryError(Query,g_Error,511)
rtf_error(0, "[RTF] Cant find thread. Error: %s", g_Error)
}

if(SQL_NumResults(Query))
{
g_iThreadID = SQL_ReadResult(Query, 0)
}
else
g_iThreadID = 1
SQL_FreeHandle(Query)
}

/* Creates the Post (message) for the thread we created */
public CreateThreadPost()
{
if (g_Error[0])
return

new szSQLQuery[1024];
switch(g_iForumSoftwareID)
{
case FORUM_VB4:
formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %spost (threadid, username, userid, title, dateline, pagetext, allowsmilie, visible, htmlstate) VALUES ('%d', '%s', '%d', '%s', '%d', '%s', '1', '1', 'on_nl2br');", g_szTablePrefix, g_iThreadID, g_szUserName, g_iSenderID, g_szPostTitle, g_iTimeStamp, g_szPostMessage);
case FORUM_MYBB:
formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %sposts (tid, fid, subject, uid, username, dateline, message, visible) VALUES ('%d', '%d', '%s', '%d', '%s', '%d', '%s', '1');", g_szTablePrefix, g_iThreadID, g_iForumID, g_szPostTitle, g_iSenderID, g_szUserName, g_iTimeStamp, g_szPostMessage);
case FORUM_SMF:
formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %smessages (id_topic, id_board, poster_time, id_member, subject, poster_name, poster_email, body, approved) VALUES ('%d', '%d', '%d', '%d', '%s', '%s', '%s', '%s', '1');", g_szTablePrefix, g_iThreadID, g_iForumID, g_iTimeStamp, g_iSenderID, g_szPostTitle, g_szUserName, g_szEmail, g_szPostMessage);
case FORUM_PHPBB:
formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %sposts (topic_id, forum_id, poster_id, post_username, post_time, enable_bbcode, post_subject, post_text, post_postcount, post_visibility) VALUES ('%d', '%d', '%d', '%s', '%d', '1', '%s', '%s', '1', '1');", g_szTablePrefix, g_iThreadID, g_iForumID, g_iSenderID, g_szUserName, g_iTimeStamp, g_szPostTitle, g_szPostMessage);
case FORUM_WBBLITE:
formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %spost (threadID, userID, username, message, time, enableSmilies, enableBBCodes) VALUES ('%d', '%d', '%s', '%s', '%d', '0', '1');", g_szTablePrefix, g_iThreadID, g_iSenderID, g_szUserName, g_szPostMessage, g_iTimeStamp);
case FORUM_AEF:
formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %sposts (post_tid, post_fid, ptime, poster_id, post, use_smileys, p_approved) VALUES ('%d', '%d', '%d', '%d', '%s', '0', '1');", g_szTablePrefix, g_iThreadID, g_iForumID, g_iTimeStamp, g_iSenderID, g_szPostMessage);
case FORUM_USEBB:
formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %sposts (topic_id, poster_id, content, post_time, enable_smilies) VALUES ('%d', '%d', '%s', '%d', '0');", g_szTablePrefix, g_iThreadID, g_iSenderID, g_szPostMessage, g_iTimeStamp);
case FORUM_XMB:
formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %sposts (fid, tid, author, message, subject, dateline, useip, bbcodeoff, smileyoff) VALUES ('%d', '%d', '%s', '%s', '%s', '%d', '%s', 'no', 'yes');", g_szTablePrefix, g_iForumID, g_iThreadID, g_szUserName, g_szPostMessage, g_szPostTitle, g_iTimeStamp);
case FORUM_IPBOARDS:
formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %sposts (author_id, author_name, post_date, post, topic_id, new_topic) VALUES ('%d', '%s', '%d', '%s', '%d', '1');", g_szTablePrefix, g_iSenderID, g_szUserName, g_iTimeStamp, g_szPostMessage, g_iThreadID);
case FORUM_XENFORO:
formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %spost (thread_id, user_id, username, post_date, message, message_state) VALUES ('%d', '%d', '%s', '%d', '%s', 'visible');", g_szTablePrefix, g_iThreadID, g_iSenderID, g_szUserName, g_iTimeStamp, g_szPostMessage);
}

new Handle:Query = SQL_PrepareQuery(SqlConnection, szSQLQuery);
if(!SQL_Execute(Query))
{
// if there were any problems
SQL_QueryError(Query,g_Error,511)
rtf_error(0, "[MYSQL] Cant create post. Error: %s", g_Error)
}

// close the handle
SQL_FreeHandle(Query)
}

/* Finds the Post ID for the thread we just created */
public GetPostId()
{
if (g_Error[0])
return

new szSQLQuery[256];
switch(g_iForumSoftwareID)
{
case FORUM_VB4:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT postid FROM %spost WHERE dateline='%d';", g_szTablePrefix, g_iTimeStamp);
case FORUM_SMF:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT id_msg FROM %smessages WHERE poster_time='%d';", g_szTablePrefix, g_iTimeStamp);
case FORUM_PHPBB:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT post_id FROM %sposts WHERE post_time='%d';", g_szTablePrefix, g_iTimeStamp);
case FORUM_WBBLITE:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT postID FROM %spost WHERE time='%d';", g_szTablePrefix, g_iTimeStamp);
case FORUM_AEF:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT pid FROM %sposts WHERE ptime='%d';", g_szTablePrefix, g_iTimeStamp);
case FORUM_USEBB:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT id FROM %sposts WHERE post_time='%d';", g_szTablePrefix, g_iTimeStamp);
case FORUM_XMB:
formatex(szSQLQuery, charsmax(szSQLQuery), "SLECT pid FROM %sposts WHERE dateline='%d';", g_szTablePrefix, g_iTimeStamp);
case FORUM_IPBOARDS:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT pid FROM %sposts WHERE post_date='%d';", g_szTablePrefix, g_iTimeStamp);
case FORUM_XENFORO:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT post_id FROM %spost WHERE post_date='%d';", g_szTablePrefix, g_iTimeStamp);
}

new Handle:Query = SQL_PrepareQuery(SqlConnection, szSQLQuery);
if(!SQL_Execute(Query))
{
// if there were any problems
SQL_QueryError(Query,g_Error,511)
rtf_error(0, "[MYSQL] Cant get post ID. Error: %s", g_Error)
}
if(SQL_NumResults(Query))
{
g_iPostID = SQL_ReadResult(Query, 0)
}
else g_iPostID = 1

// close the handle
SQL_FreeHandle(Query)
}

/* Sets the Post ID for the thread we just created */
public SetPostId()
{
if (g_Error[0])
return

new szSQLQuery[256];
switch(g_iForumSoftwareID)
{
case FORUM_VB4:
formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %sthread SET firstpostid=%d, lastpostid=%d WHERE threadid=%d;", g_szTablePrefix, g_iPostID, g_iPostID, g_iThreadID);
case FORUM_SMF:
formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %stopics SET id_first_msg=%d, id_last_msg=%d WHERE id_topic=%d;", g_szTablePrefix, g_iPostID, g_iPostID, g_iThreadID);
case FORUM_PHPBB:
formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %stopics SET topic_first_post_id=%d, topic_last_post_id=%d WHERE topic_id=%d;", g_szTablePrefix, g_iPostID, g_iPostID, g_iThreadID);
case FORUM_WBBLITE:
formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %sthread SET firstPostID=%d WHERE threadID=%d;", g_szTablePrefix, g_iPostID, g_iThreadID);
case FORUM_AEF:
formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %stopics SET first_post_id=%d, last_post_id=%d, mem_id_last_post=%d WHERE tid=%d;", g_szTablePrefix, g_iPostID, g_iPostID, g_iSenderID, g_iThreadID);
case FORUM_USEBB:
formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %stopics SET first_post_id=%d, last_post_id=%d WHERE id=%d;", g_szTablePrefix, g_iPostID, g_iPostID, g_iThreadID);
case FORUM_XMB:
formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %sthreads SET lastpost='%d|%s|%d' WHERE tid=%d;", g_szTablePrefix, g_iTimeStamp, g_szUserName, g_iPostID, g_iThreadID);
case FORUM_IPBOARDS:
formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %stopics SET topic_firstpost='%d' WHERE last_post='%d';", g_szTablePrefix, g_iPostID, g_iTimeStamp);
case FORUM_XENFORO:
formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %sthread SET first_post_id='%d', last_post_date='%d', last_post_id='%s', last_post_user_id='%d', last_post_username='%s' WHERE thread_id='%d';", g_szTablePrefix, g_iPostID, g_iTimeStamp, g_iPostID, g_iSenderID, g_szUserName, g_iPostID);
}

new Handle:Query = SQL_PrepareQuery(SqlConnection, szSQLQuery);
if(!SQL_Execute(Query))
{
// if there were any problems
SQL_QueryError(Query,g_Error,511)
rtf_error(1, "[MYSQL] Cant set Post ID. Error: %s", g_Error)
}
// close the handle
SQL_FreeHandle(Query)
}

/* Gets the Current Post and Thread count for the specified thread */
public GetCurrentForumPostData()
{
if (g_Error[0])
return
new szSQLQuery[256];
switch(g_iForumSoftwareID)
{
case FORUM_VB4:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT replycount, threadcount FROM %sforum WHERE forumid='%d';", g_szTablePrefix, g_iForumID);
case FORUM_MYBB:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT posts, threads FROM %sforums WHERE fid='%d';", g_szTablePrefix, g_iForumID);
case FORUM_SMF:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT num_posts, num_topics FROM %sboards WHERE id_board='%d';", g_szTablePrefix, g_iForumID);
case FORUM_PHPBB:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT forum_posts_approved, forum_topics_approved FROM %sforums WHERE forum_id='%d';", g_szTablePrefix, g_iForumID);
case FORUM_WBBLITE:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT posts, threads FROM %sboard WHERE boardID='%d';", g_szTablePrefix, g_iForumID);
case FORUM_AEF:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT nposts, ntopic FROM %sforums WHERE fid='%d';", g_szTablePrefix, g_iForumID);
case FORUM_USEBB:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT posts, topics FROM %sforums WHERE id='%d';", g_szTablePrefix, g_iForumID);
case FORUM_XMB:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT posts, threads FROM %sforums WHERE fid='%d';", g_szTablePrefix, g_iForumID);
case FORUM_IPBOARDS:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT posts, topics FROM %sforums WHERE id='%d';", g_szTablePrefix, g_iForumID);
case FORUM_XENFORO:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT message_count, discussion_count FROM %sforum WHERE node_id='%i';", g_szTablePrefix, g_iForumID);
}

new Handle:Query = SQL_PrepareQuery(SqlConnection, szSQLQuery);
if(!SQL_Execute(Query))
{
// if there were any problems
SQL_QueryError(Query,g_Error,511)
rtf_error(0, "[MYSQL] Cant get post count. Error: %s", g_Error)
}
if(SQL_NumResults(Query))
{
g_iPostCount = SQL_ReadResult(Query, 0) + 1
g_iThreadCount = SQL_ReadResult(Query, 1) + 1
}
else
{
g_iPostCount = 1
g_iThreadCount = 1
}
// close the handle
SQL_FreeHandle(Query)
}

/* Increase the Thread and Post count accordingly */
public UpdateForumPostCount(iPostCount, iThreadCount)
{
if (g_Error[0])
return
new szSQLQuery[512];
switch(g_iForumSoftwareID)
{
case FORUM_VB4:
formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %sforum SET threadcount='%d', replycount='%d', lastpost='%d', lastposter='%s', lastposterid='%d', lastpostid='%d', lastthread='%s', lastthreadid='%d' WHERE forumid='%d';", g_szTablePrefix, iThreadCount, iPostCount, g_iTimeStamp, g_szUserName, g_iSenderID, g_iPostID, g_szPostTitle, g_iThreadID, g_iForumID);
case FORUM_MYBB:
formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %sforums SET threads='%d', posts='%d', lastpost='%d', lastposter='%s', lastposteruid='%d', lastposttid='%d', lastpostsubject='%s' WHERE fid='%d';", g_szTablePrefix, iThreadCount, iPostCount, g_iTimeStamp, g_szUserName, g_iSenderID, g_iThreadID, g_szPostTitle, g_iForumID);
case FORUM_SMF:
formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %sboards SET num_topics='%d', num_posts='%d', id_last_msg='%d', id_msg_updated='%d' WHERE id_board='%d';", g_szTablePrefix, iThreadCount, iPostCount, g_iPostID, g_iPostID, g_iForumID);
case FORUM_PHPBB:
formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %sforums SET forum_topics_approved='%d', forum_posts_approved='%d', forum_last_post_id='%d', forum_last_post_subject='%s', forum_last_post_time='%d', forum_last_poster_id='%d', forum_last_poster_name='%s' WHERE forum_id='%d';", g_szTablePrefix, iThreadCount, iPostCount, g_iPostID, g_szPostTitle, g_iTimeStamp, g_iSenderID, g_szUserName, g_iForumID);
case FORUM_WBBLITE:
formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %sboard SET threads='%d', posts='%d' WHERE boardID='%d';", g_szTablePrefix, iThreadCount, iPostCount, g_iForumID);
case FORUM_AEF:
formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %sforums SET ntopic='%d', nposts='%d', f_last_pid='%d' WHERE fid ='%d';", g_szTablePrefix, iThreadCount, iPostCount, g_iPostID, g_iForumID);
case FORUM_USEBB:
formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %sforums SET topics='%d', posts='%d', last_topic_id='%d' WHERE id='%d';", g_szTablePrefix, iThreadCount, iPostCount, g_iThreadID, g_iForumID);
case FORUM_XMB:
formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %sforums SET lastpost='%d', posts='%d', threads='%d' WHERE fid='%d';", g_szTablePrefix, g_iTimeStamp, iPostCount, iThreadCount, g_iForumID);
case FORUM_IPBOARDS:
formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %sforums SET topics='%d', last_post='%d', last_poster_id='%d', last_poster_name='%s', last_title='%s', last_id='%d', newest_title='%s', newest_id='%d' WHERE id='%d';", g_szTablePrefix, iThreadCount, iPostCount, g_iTimeStamp, g_iSenderID, g_szUserName, g_szPostTitle, g_iPostID, g_szPostTitle, g_iPostID, g_iForumID);
case FORUM_XENFORO:
formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %sforum SET discussion_count='%d', message_count='%d', last_post_id='%d', last_post_date='%d', last_post_user_id='%d', last_post_username='%s', last_thread_title='%s' WHERE node_id='%d';", g_szTablePrefix, iThreadCount, iPostCount, g_iPostID, g_iTimeStamp, g_iSenderID, g_szUserName, g_szPostTitle, g_iForumID);
}
new Handle:Query = SQL_PrepareQuery(SqlConnection, szSQLQuery);
if(!SQL_Execute(Query))
{
// if there were any problems
SQL_QueryError(Query,g_Error,511)
rtf_error(0, "[MYSQL] Cant set post count. Error: %s", g_Error)
}
// close the handle
SQL_FreeHandle(Query)
}

/* Get the Users post count */
public GetUserPostInfo()
{
if (g_Error[0])
return
new szSQLQuery[256];
switch(g_iForumSoftwareID)
{
case FORUM_VB4:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT posts FROM %suser WHERE userid='%d';", g_szTablePrefix, g_iSenderID)
case FORUM_MYBB:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT postnum FROM %susers WHERE uid='%d';", g_szTablePrefix, g_iSenderID);
case FORUM_SMF:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT posts FROM %smembers WHERE id_member='%d';", g_szTablePrefix, g_iSenderID);
case FORUM_PHPBB:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT user_posts FROM %susers WHERE user_id='%d';", g_szTablePrefix, g_iSenderID);
case FORUM_WBBLITE:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT posts FROM %suser WHERE userID='%d';", g_szTablePrefix, g_iSenderID);
case FORUM_AEF:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT posts FROM %susers WHERE id='%d';", g_szTablePrefix, g_iSenderID);
case FORUM_USEBB:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT posts FROM %smembers WHERE id='%d';", g_szTablePrefix, g_iSenderID);
case FORUM_XMB:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT postnum FROM %smembers WHERE uid='%d';", g_szTablePrefix, g_iSenderID);
case FORUM_IPBOARDS:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT posts FROM %smembers WHERE member_id='%d';", g_szTablePrefix, g_iSenderID);
case FORUM_XENFORO:
formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT message_count FROM %suser WHERE user_id='%d';", g_szTablePrefix, g_iSenderID);
}

new Handle:Query = SQL_PrepareQuery(SqlConnection, szSQLQuery);
if(!SQL_Execute(Query))
{
// if there were any problems
SQL_QueryError(Query,g_Error,511)
rtf_error(0, "[MYSQL] Cant get user message count. Error: %s", g_Error)
}

if(SQL_NumResults(Query))
{
g_iUserPostCount = SQL_ReadResult(Query, 0) + 1
}
else g_iUserPostCount = 1

// close the handle
SQL_FreeHandle(Query)
}

/* Increase the users post count accordingly */
public UpdateUserPostCount(iPostCount)
{
if (g_Error[0])
return
new szSQLQuery[512];

switch(g_iForumSoftwareID)
{
case FORUM_VB4:
formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %suser SET posts='%d', lastvisit='%d', lastactivity='%d', lastpost='%d', lastpostid='%d' WHERE userid=%d;", g_szTablePrefix, iPostCount, g_iTimeStamp, g_iTimeStamp, g_iTimeStamp, g_iPostID, g_iSenderID);
case FORUM_MYBB:
formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %susers SET postnum='%d' WHERE uid='%d';", g_szTablePrefix, iPostCount, g_iSenderID);
case FORUM_SMF:
formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %smembers SET posts='%d', last_login='%d' WHERE id_member=%d;", g_szTablePrefix, iPostCount, g_iTimeStamp, g_iSenderID);
case FORUM_PHPBB:
formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %susers SET user_posts='%d', user_lastpost_time='%d' WHERE user_id=%d;", g_szTablePrefix, iPostCount, g_iTimeStamp, g_iSenderID);
case FORUM_WBBLITE:
formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %suser SET posts='%d', boardLastVisitTime='%d', boardLastActivityTime='%d' WHERE userID=%d;", g_szTablePrefix, iPostCount, g_iTimeStamp, g_iTimeStamp, g_iSenderID);
case FORUM_AEF:
formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %susers SET lastlogin='%d', lastlogin_1='%d', posts='%d' WHERE id=%d;", g_szTablePrefix, g_iTimeStamp, g_iTimeStamp, iPostCount, g_iSenderID);
case FORUM_USEBB:
formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %smembers SET last_login='%d', last_pageview='%d', posts='%d' WHERE id=%d;", g_szTablePrefix, g_iTimeStamp, g_iTimeStamp, iPostCount, g_iSenderID);
case FORUM_XMB:
formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %smembers SET postnum='%d', lastvisit='%d';", g_szTablePrefix, iPostCount, g_iTimeStamp);
case FORUM_IPBOARDS:
formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %smembers SET posts='%d', last_post='%d', last_visit='%d', last_activity='%d' WHERE member_id=%d;", g_szTablePrefix, iPostCount, g_iTimeStamp, g_iTimeStamp, g_iTimeStamp, g_iSenderID);
case FORUM_XENFORO:
formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %suser SET message_count='%d', last_activity='%d' WHERE user_id = '%d';", g_szTablePrefix, iPostCount, g_iTimeStamp, g_iSenderID);
}

new Handle:Query = SQL_PrepareQuery(SqlConnection, szSQLQuery);
if(!SQL_Execute(Query))
{
// if there were any problems
SQL_QueryError(Query,g_Error,511)
rtf_error(0, "[MYSQL] Cant set user message count. Error: %s", g_Error)
}

// close the handle
SQL_FreeHandle(Query)
}

public rtf_error( const failstate, const message[], any:... )
{
new msg[192]
vformat( msg, charsmax( msg ), message, 3 )

log_to_file(g_LogDir, msg)

if(failstate)
{
set_fail_state(msg)
}
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
*/
Добрый день, есть плагин, который посылает жалобу на нечестного игрока, и эта жалоба формируется в виде сообщения и отправка идет непосредственно на форум, но возникла проблема с переменными, голова трескаеться второй день смотрю на код и вроде как с переменными все отлично, но может я чтото не доглядел, хотел вашей помощи попросить. Буду рад любой помощи.
Версия форума - phpBB 3.2.8
 
В этой теме было размещено решение! Перейти к решению.
Сообщения
2,143
Реакции
1,225
Помог
44 раз(а)
%stopics
4 Июн 2020
В строке 414 добавь, 4-ым аргументом, g_szTablePrefix
 
Сообщения
6
Реакции
0
Minni,
%stopics
4 Июн 2020
В строке 414 добавь, 4-ым аргументом, g_szTablePrefix
К сожалению не помогло:
L 06/05/2020 - 14:28:49: String formatted incorrectly - parameter 4 (total 3)
L 06/05/2020 - 14:28:49: [AMXX] Displaying debug trace (plugin "report_to_forum.amxx", version "0.3b")
L 06/05/2020 - 14:28:49: Ошибка плагина 25: parameter error
L 06/05/2020 - 14:28:49: [AMXX] [0] report_to_forum.sma::SendForumPost (line 414)
L 06/05/2020 - 14:28:49: [AMXX] [1] report_to_forum.sma::SendReport (line 374)
L 06/05/2020 - 14:28:49: [AMXX] [2] report_to_forum.sma::ReportReasonHandler (line 301)

Вот тут добавил аргумент:
formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %stopics (forum_id, topic_title, topic_poster, topic_time, topic_views, topic_first_poster_name, topic_first_poster_colour, topic_last_poster_id, topic_last_poster_name, topic_last_post_subject, topic_last_post_time, topic_last_view_time, topic_posts_approved)")
format(szSQLQuery, charsmax(szSQLQuery), "%s VALUES ('%d', '%s', '%d', '%d', '1', '%s', 'AA0000', '%d', '%s', '%s', '%d', '%d', '1');", szSQLQuery, g_szTablePrefix, g_iForumID, g_szTablePrefix, g_szPostTitle, g_iSenderID, g_iTimeStamp, g_szUserName, g_iSenderID, g_szUserName, g_szPostTitle, g_iTimeStamp, g_iTimeStamp);
 
Сообщения
2,143
Реакции
1,225
Помог
44 раз(а)
Impuls_113, попробуй
Код:
/*This is a port sourcemod's "Report to Forums" plugin to AMX Mod X
Original plugin: http://forums.alliedmods.net/showthread.php?t=211126
Lastest verion of this plugin: http://c-s.net.ua/forum/topic69543s0.html
Author: voed
Special thanks: me <3, AndrewZ, Bloo
*/

#include <amxmodx>
#include <amxmisc>
#include <sqlx>
#include <report_to_forum>

#define DEBUG
//#define VOTEBAN_MODE
#define CONFIG_DIR "/report_to_forum/report_to_forum.cfg"
#define LOG_DIR "/report_to_forum/logs.txt"
#define LOG_FILE_SIZE 50 //maximum logfile size in kB

#if AMXX_VERSION_NUM < 183
#define MAX_NAME_LENGTH 33
#endif

new const PLUGIN_NAME[] = "Report To Forum";
new const PLUGIN_AUTHOR[] = "voed";
new const PLUGIN_VERSION[] = "0.3b";

new g_Reasons[][]={    "Wallhack",
            "AIMBot",
            "MultiCheat" }

enum SupportedForums
{
    FORUM_UNSUPPORTED,
    FORUM_VB4,
    FORUM_MYBB,
    FORUM_SMF,
    FORUM_PHPBB,
    FORUM_WBBLITE,
    FORUM_AEF,
    FORUM_USEBB,
    FORUM_XMB,
    FORUM_IPBOARDS,
    FORUM_XENFORO
}

/* Plugin ConVars */
new g_Cvar_TablePrefix
new g_Cvar_ForumSoftwareID
new g_Cvar_VPSTimeDiff
new g_MySQL_User, g_MySQL_Pass, g_MySQL_Host, g_MySQL_DB

new g_Cvar_ForumID;
new g_Cvar_SenderID;
new g_Cvar_UserName ;
new g_Cvar_Email;
new g_Cvar_AdminFlag;
new g_Cvar_Delay;

/* Post Info */
new g_szPostTitle[512];
new g_szPostMessage[512];

/* Misc Variables */
new SupportedForums:g_iForumSoftwareID;
new g_iForumID;
new g_iThreadID;
new g_iPostID;
new g_iPostCount;
new g_iUserPostCount;
new g_iThreadCount;
new g_iSenderID;
new g_szTablePrefix[32];
new g_iTimeStamp;

new Handle:g_SqlTuple
new g_Error[512]
new Handle:SqlConnection

new g_pHostName
new g_iTarget[33]

new g_szUserName[MAX_NAME_LENGTH];
new g_szEmail[64];
new g_szHostName[64];
new g_szMapName[64];

new g_LogDir[128];

new bool:g_UserSteam[33];
new Float:g_fLastReport[33];

public plugin_init()
{
    register_plugin( PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR )
   
    /* RTF Version */
    register_cvar( "rtf_version", PLUGIN_VERSION, FCVAR_SPONLY | FCVAR_SERVER );
   
    /* Plugin ConVars */
    g_Cvar_ForumSoftwareID     = register_cvar( "rtf_forum_softwareid", "4" );        // Forum Software ID.
    g_Cvar_VPSTimeDiff     = register_cvar( "rtf_vps_time_diff", "0");        // Time difference used for VPS servers.
   
    g_Cvar_ForumID         = register_cvar( "rtf_forum_id", "22" )        // Forum ID to post the report
    g_Cvar_SenderID     = register_cvar( "rtf_sender_id", "2" )        // Sender ID to post under.
    g_Cvar_UserName     = register_cvar( "rtf_username", "RelaXbot" )    // Sender User Name to use.
    g_Cvar_Email         = register_cvar( "rtf_email", "" )        // Sender Email Address. (Optional)
    g_Cvar_AdminFlag    = register_cvar( "rtf_adminflag", "q" )        // Only Post if no admin is available.
    g_Cvar_Delay        = register_cvar( "rtf_report_delay", "1" )     // Cooldown on using report command (in minutes)
   
    g_MySQL_Host        = register_cvar( "rtf_host", "127.0.0.1" )
    g_MySQL_User         = register_cvar( "rtf_user", "user" )
    g_MySQL_Pass        = register_cvar( "rtf_pass", "pass" )
    g_MySQL_DB        = register_cvar( "rtf_database", "user_db" )
    g_Cvar_TablePrefix     = register_cvar( "rtf_table_prefix", "" )        // Prefix to the tables in your forums database.
   
    #if defined VOTEBAN_MODE
    register_clcmd( "say /rp", "SayReport" )
    #else
    register_clcmd( "say /rp", "SayReport" )
    #endif
   
    g_pHostName      = get_cvar_pointer( "hostname" )
   
    register_dictionary( "report_to_forum.txt" )
   
    new cdir[ 64 ], cfg_dir[ 64 ]
    get_configsdir( cfg_dir, charsmax( cdir ) )
    formatex( cdir, charsmax( cdir ), "%s%s", cfg_dir, CONFIG_DIR )
    formatex( g_LogDir, charsmax( g_LogDir ), "%s%s", cfg_dir, LOG_DIR )
   
    rtf_error( 0, "log testing" )
   
    if( file_size( g_LogDir ) > LOG_FILE_SIZE*1024 )
    {
        delete_file( g_LogDir )
    }
   
    if( file_exists( cdir ) )
    {
        server_cmd( "exec %s", cdir )
        server_exec()
    }
    else
        rtf_error( 1, "[RTF] Config file %s does not exists", cdir )
       
       
    new conn[4][33]
    get_pcvar_string( g_MySQL_Host, conn[0], 32)
    get_pcvar_string( g_MySQL_User, conn[1], 32)
    get_pcvar_string( g_MySQL_Pass, conn[2], 32)
    get_pcvar_string( g_MySQL_DB, conn[3], 32 )
   
    SQL_SetAffinity( "mysql" )  
    g_SqlTuple = SQL_MakeDbTuple( conn[ 0 ], conn[ 1 ], conn[ 2 ], conn[ 3 ] )
    #if AMXX_VERSION_NUM < 182
    SQL_SetCharset( g_SqlTuple, "utf8" )
    #endif
 
    // ok, we're ready to connect
    new ErrorCode
    SqlConnection = SQL_Connect( g_SqlTuple, ErrorCode, g_Error, charsmax( g_Error ) )
    if( SqlConnection == Empty_Handle )
        rtf_error( 1, "[MYSQL] %s", g_Error )
}

public plugin_cfg()
{  
    get_pcvar_string( g_Cvar_UserName, g_szUserName, charsmax( g_szUserName ) )
    get_pcvar_string( g_Cvar_Email, g_szEmail, charsmax( g_szEmail ) )
    g_iForumID = get_pcvar_num( g_Cvar_ForumID )
    g_iSenderID = get_pcvar_num( g_Cvar_SenderID )
   
    /* Cache the Forum Softare ID */
    g_iForumSoftwareID = SupportedForums:get_pcvar_num( g_Cvar_ForumSoftwareID )
   
    /* Get the Table Prefix */
    get_pcvar_string( g_Cvar_TablePrefix, g_szTablePrefix, charsmax( g_szTablePrefix ) )
    get_mapname( g_szMapName, charsmax ( g_szMapName ) )
   
}

public client_connect( id )
{
    g_UserSteam[ id ] = is_user_steam( id )
}
public client_disconnected(id)
{
    g_fLastReport[ id ] = 0.0
}

public plugin_end()
{
    SQL_FreeHandle( g_SqlTuple )
}

public SayReport(id)
{
    new Float:gametime = get_gametime();
    if(g_fLastReport[id])
    {
        new Float:delay = get_pcvar_float(g_Cvar_Delay)*60;
        new Float:timeleft = gametime - g_fLastReport[id];
        if(timeleft < delay)
        {
            new Float:rem  = (delay - timeleft)
            if(floatround(rem/60, floatround_floor))
            {
                client_print(id, print_chat, "%L", id, "RTF_CANT_USE_MINUTES", rem/60)
            }
            else
            {
                client_print(id, print_chat, "%L", id, "RTF_CANT_USE_SECONDS", rem)
            }
           
            return PLUGIN_HANDLED
        }
    }
   
    g_fLastReport[id] = gametime;
    new title[128]
    formatex(title, charsmax(title), "%L", id, "RTF_MENU_CHOOSE_PLAYER")
    new i_Menu = menu_create(title, "SayReportHandler", 1)
   
    new s_Players[32], i_Num, i_Player
    new s_Name[33], s_Player[10]
    new flags[32]
    get_pcvar_string(g_Cvar_AdminFlag, flags, charsmax(flags))
    get_players(s_Players, i_Num, "ch")
   
    for (new i; i < i_Num; i++)
    {
        i_Player = s_Players[i]
        #if !defined(DEBUG)
        if (i_Player == id)
            continue
           
        if(flags[0] && (get_user_flags(i_Player) & read_flags(flags)))
        {
            client_print(id, print_chat, "%L", id, "RTF_ADMINS_ONLINE")
            menu_destroy(i_Menu)
            return PLUGIN_HANDLED
        }
        #endif
        get_user_name(i_Player, s_Name, charsmax(s_Name))
        num_to_str(i_Player, s_Player, charsmax(s_Player))
        menu_additem(i_Menu, s_Name, s_Player, 0)
    }
   
    menu_display(id, i_Menu, 0)
    return PLUGIN_HANDLED
}

public SayReportHandler(id, menu, item)
{
    if (item == MENU_EXIT)
    {
        menu_destroy(menu)
        return PLUGIN_HANDLED
    }
   
    new s_Data[6], i_Access, i_Callback
    menu_item_getinfo(menu, item, i_Access, s_Data, charsmax(s_Data), _, _, i_Callback )
   
    g_iTarget[id] = str_to_num(s_Data)
   
    ReportReason(id)
   
    menu_destroy(menu)
    return PLUGIN_HANDLED
   
}

public ReportReason(id)
{
    new title[128]
    formatex(title, charsmax(title), "%L", id, "RTF_MENU_CHOOSE_REASON")
    new i_Menu = menu_create(title, "ReportReasonHandler", 1)
   
    for(new i=0; i<sizeof(g_Reasons); i++)
    {
        new key[4]
        num_to_str(i, key, charsmax(key))
        menu_additem(i_Menu, g_Reasons[i], key)
    }
   
    menu_display(id, i_Menu, 0)
    return PLUGIN_HANDLED
}

public ReportReasonHandler(id, menu, item)
{
    if (item == MENU_EXIT)
    {
        menu_destroy(menu)
        return PLUGIN_HANDLED
    }
   
    new s_Data[6], s_Name[32], i_Access, i_Callback
    menu_item_getinfo(menu, item, i_Access, s_Data, charsmax(s_Data), s_Name, charsmax(s_Name), i_Callback )
   
    SendReport(id, g_iTarget[id], s_Name)
   
    menu_destroy(menu)
    return PLUGIN_HANDLED
}
public SendReport(sender_id, target_id, reason[])
{
    new szReason[64]
    if((!sender_id) || (!target_id) || (!reason[0]))
        return PLUGIN_HANDLED
       
    formatex(szReason, charsmax(szReason), reason)
    new sender_name[32], name[32], steamid[32], ip[16]
    get_user_name(target_id, name, charsmax(name))
    get_user_name(sender_id, sender_name, charsmax(sender_name))
    get_user_authid(target_id, steamid, charsmax(steamid))
    get_user_ip(target_id, ip, charsmax(ip), 1)
    get_pcvar_string( g_pHostName, g_szHostName, 63 );
    new br[10]
    if(g_iForumSoftwareID == FORUM_IPBOARDS)
    {
        formatex(br, charsmax(br), "<br />")
    }
    else
    {
        formatex(br, charsmax(br), "^n")
    }
   
    formatex(g_szPostTitle, charsmax(g_szPostTitle), "%s %L %s", name, LANG_SERVER, "RTF_REPORTED_FOR", szReason)
    formatex(g_szPostMessage, charsmax(g_szPostMessage), "%L %s%s", LANG_SERVER, "RTF_HOST_NAME", g_szHostName, br)
    format(g_szPostMessage, charsmax(g_szPostMessage), "%s%L %s%s", g_szPostMessage, LANG_SERVER, "RTF_SENDER_NAME", sender_name, br)
    format(g_szPostMessage, charsmax(g_szPostMessage), "%s%L %s%s", g_szPostMessage, LANG_SERVER, "RTF_NAME", name, br)
   
    if(g_UserSteam[target_id])
    {
        new url[64]
        rtf_get_steamurl(steamid, url, charsmax(url))
        format(g_szPostMessage, charsmax(g_szPostMessage), "%s%L %s ", g_szPostMessage, LANG_SERVER, "RTF_STEAMID", steamid)
        format(g_szPostMessage, charsmax(g_szPostMessage), "%s[url=%s %L [/url]%s", g_szPostMessage, url, LANG_SERVER, "RTF_STEAM_URL", br)
    }
    else
    {
        format(g_szPostMessage, charsmax(g_szPostMessage), "%s%L %s%s", g_szPostMessage, LANG_SERVER, "RTF_STEAMID", steamid, br)
    }
   
    format(g_szPostMessage, charsmax(g_szPostMessage), "%s%L %s%s", g_szPostMessage, LANG_SERVER, "RTF_IP", ip, br)
    format(g_szPostMessage, charsmax(g_szPostMessage), "%s%L %s", g_szPostMessage, LANG_SERVER, "RTF_REASON", szReason)
   
    GetWebSafeString(g_szPostTitle, charsmax(g_szPostTitle));
    GetWebSafeString(g_szUserName, charsmax(g_szUserName));
    mysql_escape_string(g_szPostTitle, charsmax(g_szPostTitle));
    mysql_escape_string(g_szUserName, charsmax(g_szUserName));
    mysql_escape_string(g_szPostMessage, charsmax(g_szPostMessage));
   
    g_iTimeStamp = (get_systime() - get_pcvar_num(g_Cvar_VPSTimeDiff));
   
    if(!g_szTablePrefix[0])
    {
        switch(g_iForumSoftwareID)
        {
            //case FORUM_VB4:
            //case FORUM_MYBB:          
            case FORUM_SMF:g_szTablePrefix         = "smf_"
            case FORUM_PHPBB:g_szTablePrefix     = "phpbb_"
            //case FORUM_WBBLITE:
            //case FORUM_AEF:
            //case FORUM_USEBB:
            //case FORUM_XMB:
            //case FORUM_IPBOARDS:
            case FORUM_XENFORO:g_szTablePrefix     = "xf_"
        }
    }
   
    SendForumPost()
    FindRecentThread()
    CreateThreadPost()
    if(g_iForumSoftwareID != FORUM_MYBB)
    {
        GetPostId()
        SetPostId()
    }
   
    GetCurrentForumPostData()
    UpdateForumPostCount(g_iThreadCount, g_iPostCount)
   
    GetUserPostInfo();
    UpdateUserPostCount(g_iUserPostCount);
   
    client_print(sender_id, print_chat, "%L", sender_id, "RTF_REPORT_SENDED")
    return PLUGIN_HANDLED
}

public SendForumPost()
{
    new szSeoTitle[256], szSeoName[64]
    formatex(szSeoTitle, charsmax(szSeoTitle), "%s", g_szPostTitle, charsmax(g_szPostTitle))
    SeoTitle(szSeoTitle, charsmax(szSeoTitle))
   
    formatex(szSeoName, charsmax(szSeoName), "%s", g_szUserName, charsmax(g_szUserName))
    SeoTitle(szSeoName, charsmax(szSeoName))
   
    new szSQLQuery[1024]
    switch(g_iForumSoftwareID)
    {
        case FORUM_VB4:
            formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %sthread (title, lastpost, forumid, open, postusername, postuserid, lastposter, lastposterid, dateline, visible) VALUES ('%s', '%d', '%d', '1', '%s', '%d', '%s', '%d', '%d', '1');", g_szTablePrefix, g_szPostTitle, g_iTimeStamp, g_iForumID, g_szUserName, g_iSenderID, g_szUserName, g_iSenderID, g_iTimeStamp);
        case FORUM_MYBB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %sthreads (fid, subject, uid, username, dateline, firstpost, lastpost, visible) VALUES ('%d', '%s', '%d', '%s', '%d', '1', '%d', '1');", g_szTablePrefix, g_iForumID, g_szPostTitle, g_iSenderID, g_szUserName, g_iTimeStamp, g_iTimeStamp);          
        case FORUM_SMF:
            formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %stopics (id_board, approved) VALUES ('%d', '1');", g_szTablePrefix, g_iForumID);
       
        case FORUM_PHPBB:
        {
            formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %stopics (forum_id, topic_title, topic_poster, topic_time, topic_views, topic_first_poster_name, topic_first_poster_colour, topic_last_poster_id, topic_last_poster_name, topic_last_post_subject, topic_last_post_time, topic_last_view_time, topic_posts_approved)", g_szTablePrefix)
            format(szSQLQuery, charsmax(szSQLQuery), "%s VALUES ('%d', '%s', '%d', '%d', '1', '%s', 'AA0000', '%d', '%s', '%s', '%d', '%d', '1');", szSQLQuery, g_iForumID, g_szPostTitle, g_iSenderID, g_iTimeStamp, g_szUserName, g_iSenderID, g_szUserName, g_szPostTitle, g_iTimeStamp, g_iTimeStamp);
        }
       
        case FORUM_WBBLITE:
            formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %sthread (boardID, topic, time, userID, username, lastPostTime, lastPosterID, lastPoster) VALUES ('%d', '%s', '%d', '%d', '%s', '%d', '%d', '%s');", g_szTablePrefix, g_iForumID, g_szPostTitle, g_iTimeStamp, g_iSenderID, g_szUserName, g_iTimeStamp, g_iSenderID, g_szUserName);
        case FORUM_AEF:
            formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %stopics (topic, t_bid, t_status, t_mem_id, t_approved) VALUES ('%s', '%d', '1', '%d', '1');", g_szTablePrefix, g_szPostTitle, g_iForumID, g_iSenderID);
        case FORUM_USEBB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %stopics (forum_id, topic_title) VALUES ('%d', '%s');", g_szTablePrefix, g_iForumID, g_szPostTitle);
        case FORUM_XMB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %sthreads (fid, subject, author) VALUES ('%d', '%s', '%s');", g_szTablePrefix, g_iForumID, g_szPostTitle, g_szUserName);
        case FORUM_IPBOARDS:
        {
            formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %stopics (title, state, posts, starter_id, start_date, last_poster_id, last_post, starter_name, last_poster_name, poll_state, last_vote, views, forum_id, approved, author_mode, pinned, title_seo, seo_first_name, seo_last_name, last_real_post)", g_szTablePrefix)
            format(szSQLQuery, charsmax(szSQLQuery), "%s VALUES ('%s', 'open', '1', '%d', '%d', '%d', '%d', '%s', '%s', '0', '0', '1','%d', '1', '1', '0', '%s', '%s', '%s', '%d');", szSQLQuery, g_szPostTitle, g_iSenderID, g_iTimeStamp, g_iSenderID, g_iTimeStamp, g_szUserName, g_szUserName, g_iForumID, szSeoTitle, szSeoName, szSeoName, g_iTimeStamp);
        }
        case FORUM_XENFORO:
            formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %sthread (node_id, title, reply_count, view_count, user_id, username, post_date, last_post_date, discussion_state, last_post_id, last_post_user_id, last_post_username) VALUES ('%d', '%s', '0', '0', '%d', '%s', '%d', '%d', 'visible', '%d', '%d', '%s');", g_szTablePrefix, g_iForumID, g_szPostTitle, g_iSenderID, g_szUserName, g_iTimeStamp, g_iTimeStamp, g_iForumID, g_iSenderID, g_szUserName);
    }
    new Handle:Query = SQL_PrepareQuery(SqlConnection, szSQLQuery);
    if(!SQL_Execute(Query))
        {
            // if there were any problems
            SQL_QueryError(Query,g_Error,511)
            rtf_error(0, "[MYSQL] Cant create thread. Error: %s", g_Error)
        }
        // close the handle
        SQL_FreeHandle(Query)
}


/* Finds the Thread ID for the thread we just created */
public FindRecentThread()
{
    if (g_Error[0])
        return
       
    new szSQLQuery[512];
    switch(g_iForumSoftwareID)
    {
        case FORUM_VB4:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT threadid FROM %sthread WHERE dateline='%d';", g_szTablePrefix, g_iTimeStamp);
        case FORUM_MYBB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT tid FROM %sthreads WHERE dateline='%d';", g_szTablePrefix, g_iTimeStamp);
        case FORUM_SMF:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT MAX(id_topic) FROM %stopics;", g_szTablePrefix);
        case FORUM_PHPBB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT topic_id FROM %stopics WHERE topic_time='%d';", g_szTablePrefix, g_iTimeStamp);
        case FORUM_WBBLITE:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT threadID FROM %sthread WHERE time='%d';", g_szTablePrefix, g_iTimeStamp);
        case FORUM_AEF:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT MAX(tid) FROM %stopics;", g_szTablePrefix);
        case FORUM_USEBB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT MAX(id) FROM %stopics;", g_szTablePrefix);
        case FORUM_XMB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT tid FROM %stopics WHERE lastpost='%d';", g_szTablePrefix, g_iTimeStamp);
        case FORUM_IPBOARDS:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT tid FROM %stopics WHERE last_post='%d';", g_szTablePrefix, g_iTimeStamp);
        case FORUM_XENFORO:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT thread_id FROM %sthread WHERE post_date='%d';", g_szTablePrefix, g_iTimeStamp);
    }
   
    new Handle:Query = SQL_PrepareQuery(SqlConnection, szSQLQuery);
    if(!SQL_Execute(Query))
        {
            // if there were any problems
            SQL_QueryError(Query,g_Error,511)
            rtf_error(0, "[RTF] Cant find thread. Error: %s", g_Error)
        }
   
    if(SQL_NumResults(Query))
    {
        g_iThreadID = SQL_ReadResult(Query, 0)
    }
    else    
        g_iThreadID = 1
        SQL_FreeHandle(Query)
}

/* Creates the Post (message) for the thread we created */
public CreateThreadPost()
{  
    if (g_Error[0])
        return
       
    new szSQLQuery[1024];
    switch(g_iForumSoftwareID)
    {
        case FORUM_VB4:
            formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %spost (threadid, username, userid, title, dateline, pagetext, allowsmilie, visible, htmlstate) VALUES ('%d', '%s', '%d', '%s', '%d', '%s', '1', '1', 'on_nl2br');", g_szTablePrefix, g_iThreadID, g_szUserName, g_iSenderID, g_szPostTitle, g_iTimeStamp, g_szPostMessage);          
        case FORUM_MYBB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %sposts (tid, fid, subject, uid, username, dateline, message, visible) VALUES ('%d', '%d', '%s', '%d', '%s', '%d', '%s', '1');", g_szTablePrefix, g_iThreadID, g_iForumID, g_szPostTitle, g_iSenderID, g_szUserName, g_iTimeStamp, g_szPostMessage);          
        case FORUM_SMF:
            formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %smessages (id_topic, id_board, poster_time, id_member, subject, poster_name, poster_email, body, approved) VALUES ('%d', '%d', '%d', '%d', '%s', '%s', '%s', '%s', '1');", g_szTablePrefix, g_iThreadID, g_iForumID, g_iTimeStamp, g_iSenderID, g_szPostTitle, g_szUserName, g_szEmail, g_szPostMessage);          
        case FORUM_PHPBB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %sposts (topic_id, forum_id, poster_id, post_username, post_time, enable_bbcode, post_subject, post_text, post_postcount, post_visibility) VALUES ('%d', '%d', '%d', '%s', '%d', '1', '%s', '%s', '1', '1');", g_szTablePrefix, g_iThreadID, g_iForumID, g_iSenderID, g_szUserName, g_iTimeStamp, g_szPostTitle, g_szPostMessage);
        case FORUM_WBBLITE:
            formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %spost (threadID, userID, username, message, time, enableSmilies, enableBBCodes) VALUES ('%d', '%d', '%s', '%s', '%d', '0', '1');", g_szTablePrefix, g_iThreadID, g_iSenderID, g_szUserName, g_szPostMessage, g_iTimeStamp);
        case FORUM_AEF:
            formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %sposts (post_tid, post_fid, ptime, poster_id, post, use_smileys, p_approved) VALUES ('%d', '%d', '%d', '%d', '%s', '0', '1');", g_szTablePrefix, g_iThreadID, g_iForumID, g_iTimeStamp, g_iSenderID, g_szPostMessage);
        case FORUM_USEBB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %sposts (topic_id, poster_id, content, post_time, enable_smilies) VALUES ('%d', '%d', '%s', '%d', '0');", g_szTablePrefix, g_iThreadID, g_iSenderID, g_szPostMessage, g_iTimeStamp);
        case FORUM_XMB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %sposts (fid, tid, author, message, subject, dateline, useip, bbcodeoff, smileyoff) VALUES ('%d', '%d', '%s', '%s', '%s', '%d', '%s', 'no', 'yes');", g_szTablePrefix, g_iForumID, g_iThreadID, g_szUserName, g_szPostMessage, g_szPostTitle, g_iTimeStamp);
        case FORUM_IPBOARDS:
            formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %sposts (author_id, author_name, post_date, post, topic_id, new_topic) VALUES ('%d', '%s', '%d', '%s', '%d', '1');", g_szTablePrefix, g_iSenderID, g_szUserName, g_iTimeStamp, g_szPostMessage, g_iThreadID);
        case FORUM_XENFORO:
            formatex(szSQLQuery, charsmax(szSQLQuery), "INSERT INTO %spost (thread_id, user_id, username, post_date, message, message_state) VALUES ('%d', '%d', '%s', '%d', '%s', 'visible');", g_szTablePrefix, g_iThreadID, g_iSenderID, g_szUserName, g_iTimeStamp, g_szPostMessage);
    }
   
    new Handle:Query = SQL_PrepareQuery(SqlConnection, szSQLQuery);
    if(!SQL_Execute(Query))
        {
            // if there were any problems
            SQL_QueryError(Query,g_Error,511)
            rtf_error(0, "[MYSQL] Cant create post. Error: %s", g_Error)
        }

        // close the handle
        SQL_FreeHandle(Query)
}

/* Finds the Post ID for the thread we just created */
public GetPostId()
{
    if (g_Error[0])
        return
       
    new szSQLQuery[256];
    switch(g_iForumSoftwareID)
    {
        case FORUM_VB4:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT postid FROM %spost WHERE dateline='%d';", g_szTablePrefix, g_iTimeStamp);
        case FORUM_SMF:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT id_msg FROM %smessages WHERE poster_time='%d';", g_szTablePrefix, g_iTimeStamp);
        case FORUM_PHPBB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT post_id FROM %sposts WHERE post_time='%d';", g_szTablePrefix, g_iTimeStamp);
        case FORUM_WBBLITE:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT postID FROM %spost WHERE time='%d';", g_szTablePrefix, g_iTimeStamp);
        case FORUM_AEF:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT pid FROM %sposts WHERE ptime='%d';", g_szTablePrefix, g_iTimeStamp);
        case FORUM_USEBB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT id FROM %sposts WHERE post_time='%d';", g_szTablePrefix, g_iTimeStamp);
        case FORUM_XMB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SLECT pid FROM %sposts WHERE dateline='%d';", g_szTablePrefix, g_iTimeStamp);
        case FORUM_IPBOARDS:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT pid FROM %sposts WHERE post_date='%d';", g_szTablePrefix, g_iTimeStamp);
        case FORUM_XENFORO:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT post_id FROM %spost WHERE post_date='%d';", g_szTablePrefix, g_iTimeStamp);
    }
   
    new Handle:Query = SQL_PrepareQuery(SqlConnection, szSQLQuery);
    if(!SQL_Execute(Query))
        {
            // if there were any problems
            SQL_QueryError(Query,g_Error,511)
            rtf_error(0, "[MYSQL] Cant get post ID. Error: %s", g_Error)
        }
    if(SQL_NumResults(Query))
    {
        g_iPostID =  SQL_ReadResult(Query, 0)
    }
    else g_iPostID = 1
   
        // close the handle
        SQL_FreeHandle(Query)
}

/* Sets the Post ID for the thread we just created */
public SetPostId()
{
    if (g_Error[0])
        return
       
    new szSQLQuery[256];
    switch(g_iForumSoftwareID)
    {
        case FORUM_VB4:
            formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %sthread SET firstpostid=%d, lastpostid=%d WHERE threadid=%d;", g_szTablePrefix, g_iPostID, g_iPostID, g_iThreadID);
        case FORUM_SMF:
            formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %stopics SET id_first_msg=%d, id_last_msg=%d WHERE id_topic=%d;", g_szTablePrefix, g_iPostID, g_iPostID, g_iThreadID);
        case FORUM_PHPBB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %stopics SET topic_first_post_id=%d, topic_last_post_id=%d WHERE topic_id=%d;", g_szTablePrefix, g_iPostID, g_iPostID, g_iThreadID);
        case FORUM_WBBLITE:
            formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %sthread SET firstPostID=%d WHERE threadID=%d;", g_szTablePrefix, g_iPostID, g_iThreadID);
        case FORUM_AEF:
            formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %stopics SET first_post_id=%d, last_post_id=%d, mem_id_last_post=%d WHERE tid=%d;", g_szTablePrefix, g_iPostID, g_iPostID, g_iSenderID, g_iThreadID);
        case FORUM_USEBB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %stopics SET first_post_id=%d, last_post_id=%d WHERE id=%d;", g_szTablePrefix, g_iPostID, g_iPostID, g_iThreadID);
        case FORUM_XMB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %sthreads SET lastpost='%d|%s|%d' WHERE tid=%d;", g_szTablePrefix, g_iTimeStamp, g_szUserName, g_iPostID, g_iThreadID);
        case FORUM_IPBOARDS:
            formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %stopics SET topic_firstpost='%d' WHERE last_post='%d';", g_szTablePrefix, g_iPostID, g_iTimeStamp);
        case FORUM_XENFORO:
            formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %sthread SET first_post_id='%d', last_post_date='%d', last_post_id='%s', last_post_user_id='%d', last_post_username='%s' WHERE thread_id='%d';", g_szTablePrefix, g_iPostID, g_iTimeStamp, g_iPostID, g_iSenderID, g_szUserName, g_iPostID);
    }
   
    new Handle:Query = SQL_PrepareQuery(SqlConnection, szSQLQuery);
    if(!SQL_Execute(Query))
        {
            // if there were any problems
            SQL_QueryError(Query,g_Error,511)
            rtf_error(1, "[MYSQL] Cant set Post ID. Error: %s", g_Error)
        }
        // close the handle
        SQL_FreeHandle(Query)
}

/* Gets the Current Post and Thread count for the specified thread */
public GetCurrentForumPostData()
{
    if (g_Error[0])
        return
    new szSQLQuery[256];
    switch(g_iForumSoftwareID)
    {
        case FORUM_VB4:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT replycount, threadcount FROM %sforum WHERE forumid='%d';", g_szTablePrefix, g_iForumID);
        case FORUM_MYBB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT posts, threads FROM %sforums WHERE fid='%d';", g_szTablePrefix, g_iForumID);
        case FORUM_SMF:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT num_posts, num_topics FROM %sboards WHERE id_board='%d';", g_szTablePrefix, g_iForumID);
        case FORUM_PHPBB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT forum_posts_approved, forum_topics_approved FROM %sforums WHERE forum_id='%d';", g_szTablePrefix, g_iForumID);
        case FORUM_WBBLITE:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT posts, threads FROM %sboard WHERE boardID='%d';", g_szTablePrefix, g_iForumID);
        case FORUM_AEF:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT nposts, ntopic FROM %sforums WHERE fid='%d';", g_szTablePrefix, g_iForumID);
        case FORUM_USEBB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT posts, topics FROM %sforums WHERE id='%d';", g_szTablePrefix, g_iForumID);
        case FORUM_XMB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT posts, threads FROM %sforums WHERE fid='%d';", g_szTablePrefix, g_iForumID);
        case FORUM_IPBOARDS:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT posts, topics FROM %sforums WHERE id='%d';", g_szTablePrefix, g_iForumID);
        case FORUM_XENFORO:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT message_count, discussion_count FROM %sforum WHERE node_id='%i';", g_szTablePrefix, g_iForumID);
    }
   
    new Handle:Query = SQL_PrepareQuery(SqlConnection, szSQLQuery);
    if(!SQL_Execute(Query))
        {
            // if there were any problems
            SQL_QueryError(Query,g_Error,511)
            rtf_error(0, "[MYSQL] Cant get post count. Error: %s", g_Error)
        }
    if(SQL_NumResults(Query))
    {
        g_iPostCount = SQL_ReadResult(Query, 0) + 1
        g_iThreadCount = SQL_ReadResult(Query, 1) + 1
    }
    else
    {
        g_iPostCount = 1
        g_iThreadCount = 1
    }
        // close the handle
        SQL_FreeHandle(Query)
}

/* Increase the Thread and Post count accordingly */
public UpdateForumPostCount(iPostCount, iThreadCount)
{
    if (g_Error[0])
        return
    new szSQLQuery[512];
    switch(g_iForumSoftwareID)
    {
        case FORUM_VB4:
            formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %sforum SET threadcount='%d', replycount='%d', lastpost='%d', lastposter='%s', lastposterid='%d', lastpostid='%d', lastthread='%s', lastthreadid='%d' WHERE forumid='%d';", g_szTablePrefix, iThreadCount, iPostCount, g_iTimeStamp, g_szUserName, g_iSenderID, g_iPostID, g_szPostTitle, g_iThreadID, g_iForumID);          
        case FORUM_MYBB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %sforums SET threads='%d', posts='%d', lastpost='%d', lastposter='%s', lastposteruid='%d', lastposttid='%d', lastpostsubject='%s' WHERE fid='%d';", g_szTablePrefix, iThreadCount, iPostCount, g_iTimeStamp, g_szUserName, g_iSenderID, g_iThreadID, g_szPostTitle, g_iForumID);          
        case FORUM_SMF:
            formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %sboards SET num_topics='%d', num_posts='%d', id_last_msg='%d', id_msg_updated='%d' WHERE id_board='%d';", g_szTablePrefix, iThreadCount, iPostCount, g_iPostID, g_iPostID, g_iForumID);          
        case FORUM_PHPBB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %sforums SET forum_topics_approved='%d', forum_posts_approved='%d', forum_last_post_id='%d', forum_last_post_subject='%s', forum_last_post_time='%d', forum_last_poster_id='%d', forum_last_poster_name='%s' WHERE forum_id='%d';", g_szTablePrefix, iThreadCount, iPostCount, g_iPostID, g_szPostTitle, g_iTimeStamp, g_iSenderID, g_szUserName, g_iForumID);          
        case FORUM_WBBLITE:
            formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %sboard SET threads='%d', posts='%d' WHERE boardID='%d';", g_szTablePrefix, iThreadCount, iPostCount, g_iForumID);
        case FORUM_AEF:
            formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %sforums SET ntopic='%d', nposts='%d', f_last_pid='%d' WHERE fid ='%d';", g_szTablePrefix, iThreadCount, iPostCount, g_iPostID, g_iForumID);
        case FORUM_USEBB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %sforums SET topics='%d', posts='%d', last_topic_id='%d' WHERE id='%d';", g_szTablePrefix, iThreadCount, iPostCount, g_iThreadID, g_iForumID);
        case FORUM_XMB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %sforums SET lastpost='%d', posts='%d', threads='%d' WHERE fid='%d';", g_szTablePrefix, g_iTimeStamp, iPostCount, iThreadCount, g_iForumID);
        case FORUM_IPBOARDS:
            formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %sforums SET topics='%d', last_post='%d', last_poster_id='%d', last_poster_name='%s', last_title='%s', last_id='%d', newest_title='%s', newest_id='%d' WHERE id='%d';", g_szTablePrefix, iThreadCount, iPostCount, g_iTimeStamp, g_iSenderID, g_szUserName, g_szPostTitle, g_iPostID, g_szPostTitle, g_iPostID, g_iForumID);
        case FORUM_XENFORO:
            formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %sforum SET discussion_count='%d', message_count='%d', last_post_id='%d', last_post_date='%d', last_post_user_id='%d', last_post_username='%s', last_thread_title='%s' WHERE node_id='%d';", g_szTablePrefix, iThreadCount, iPostCount, g_iPostID, g_iTimeStamp, g_iSenderID, g_szUserName, g_szPostTitle, g_iForumID);
    }
    new Handle:Query = SQL_PrepareQuery(SqlConnection, szSQLQuery);
    if(!SQL_Execute(Query))
        {
            // if there were any problems
            SQL_QueryError(Query,g_Error,511)
            rtf_error(0, "[MYSQL] Cant set post count. Error: %s", g_Error)
        }
        // close the handle
        SQL_FreeHandle(Query)
}

/* Get the Users post count */
public GetUserPostInfo()
{
    if (g_Error[0])
        return
    new szSQLQuery[256];
    switch(g_iForumSoftwareID)
    {
        case FORUM_VB4:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT posts FROM %suser WHERE userid='%d';", g_szTablePrefix, g_iSenderID)
        case FORUM_MYBB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT postnum FROM %susers WHERE uid='%d';", g_szTablePrefix, g_iSenderID);
        case FORUM_SMF:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT posts FROM %smembers WHERE id_member='%d';", g_szTablePrefix, g_iSenderID);
        case FORUM_PHPBB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT user_posts FROM %susers WHERE user_id='%d';", g_szTablePrefix, g_iSenderID);
        case FORUM_WBBLITE:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT posts FROM %suser WHERE userID='%d';", g_szTablePrefix, g_iSenderID);
        case FORUM_AEF:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT posts FROM %susers WHERE id='%d';", g_szTablePrefix, g_iSenderID);
        case FORUM_USEBB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT posts FROM %smembers WHERE id='%d';", g_szTablePrefix, g_iSenderID);
        case FORUM_XMB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT postnum FROM %smembers WHERE uid='%d';", g_szTablePrefix, g_iSenderID);
        case FORUM_IPBOARDS:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT posts FROM %smembers WHERE member_id='%d';", g_szTablePrefix, g_iSenderID);
        case FORUM_XENFORO:
            formatex(szSQLQuery, charsmax(szSQLQuery), "SELECT message_count FROM %suser WHERE user_id='%d';", g_szTablePrefix, g_iSenderID);
    }
   
    new Handle:Query = SQL_PrepareQuery(SqlConnection, szSQLQuery);
    if(!SQL_Execute(Query))
        {
            // if there were any problems
            SQL_QueryError(Query,g_Error,511)
            rtf_error(0, "[MYSQL] Cant get user message count. Error: %s", g_Error)
        }
   
    if(SQL_NumResults(Query))
    {
        g_iUserPostCount = SQL_ReadResult(Query, 0) + 1
    }
    else g_iUserPostCount = 1
   
        // close the handle
        SQL_FreeHandle(Query)
}

/* Increase the users post count accordingly */
public UpdateUserPostCount(iPostCount)
{
    if (g_Error[0])
        return
    new szSQLQuery[512];

    switch(g_iForumSoftwareID)
    {
        case FORUM_VB4:
            formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %suser SET posts='%d', lastvisit='%d', lastactivity='%d', lastpost='%d', lastpostid='%d' WHERE userid=%d;", g_szTablePrefix, iPostCount, g_iTimeStamp, g_iTimeStamp, g_iTimeStamp, g_iPostID, g_iSenderID);
        case FORUM_MYBB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %susers SET postnum='%d' WHERE uid='%d';", g_szTablePrefix, iPostCount, g_iSenderID);
        case FORUM_SMF:
            formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %smembers SET posts='%d', last_login='%d' WHERE id_member=%d;", g_szTablePrefix, iPostCount, g_iTimeStamp, g_iSenderID);
        case FORUM_PHPBB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %susers SET user_posts='%d', user_lastpost_time='%d' WHERE user_id=%d;", g_szTablePrefix, iPostCount, g_iTimeStamp, g_iSenderID);          
        case FORUM_WBBLITE:
            formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %suser SET posts='%d', boardLastVisitTime='%d', boardLastActivityTime='%d' WHERE userID=%d;", g_szTablePrefix, iPostCount, g_iTimeStamp, g_iTimeStamp, g_iSenderID);
        case FORUM_AEF:
            formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %susers SET lastlogin='%d', lastlogin_1='%d', posts='%d' WHERE id=%d;", g_szTablePrefix, g_iTimeStamp, g_iTimeStamp, iPostCount, g_iSenderID);
        case FORUM_USEBB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %smembers SET last_login='%d', last_pageview='%d', posts='%d' WHERE id=%d;", g_szTablePrefix, g_iTimeStamp, g_iTimeStamp, iPostCount, g_iSenderID);
        case FORUM_XMB:
            formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %smembers SET postnum='%d', lastvisit='%d';", g_szTablePrefix, iPostCount, g_iTimeStamp);
        case FORUM_IPBOARDS:
            formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %smembers SET posts='%d', last_post='%d', last_visit='%d', last_activity='%d' WHERE member_id=%d;", g_szTablePrefix, iPostCount, g_iTimeStamp, g_iTimeStamp, g_iTimeStamp, g_iSenderID);
        case FORUM_XENFORO:
            formatex(szSQLQuery, charsmax(szSQLQuery), "UPDATE %suser SET message_count='%d', last_activity='%d' WHERE user_id = '%d';", g_szTablePrefix, iPostCount, g_iTimeStamp, g_iSenderID);
    }
       
    new Handle:Query = SQL_PrepareQuery(SqlConnection, szSQLQuery);
    if(!SQL_Execute(Query))
        {
            // if there were any problems
            SQL_QueryError(Query,g_Error,511)
            rtf_error(0, "[MYSQL] Cant set user message count. Error: %s", g_Error)
        }
   
        // close the handle
        SQL_FreeHandle(Query)
}

public rtf_error( const failstate, const message[], any:... )
{
    new msg[192]
    vformat( msg, charsmax( msg ), message, 3 )
   
    log_to_file(g_LogDir, msg)
   
    if(failstate)
    {
        set_fail_state(msg)
    }
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
*/
 
Сообщения
6
Реакции
0
Minni, Все отлично работает, правда, после изменений, код просил чтоб я подровнял по табуляции )) Незнаю с чем это связано, но результат отличный, единственная проблема с отображением, но я использовал латиницу вместо русских символов, хотя плагин и исходник сохранял в utf8 без BOM, в коде плагина также указан utf8, БД - utf8mb4_general_ci, а отображение русской кириллицы по факту:"ИмÑ?? Ñ??ервера"
Но это ерунда, спасибо! Ты очень помог!!! Результат в скринах )
 

Download all Attachments

Статус
В этой теме нельзя размещать новые ответы.

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу