If I have a plugin which uses MySQL to store data, Can I make the plugin use SQLite instead of MySQL without rewriting it?
If Yes, what should I do so I can make it run using SQLite.
If No, How should I make a plugin using MySQL, use SQLite instead of MySQL.
I know it may seem stupid question, but I'm dying on finding an answer, I've searching many times on MySQL and SQLite but couldn't find the answer that I want.
Nothing happens until you use natives in a plugin, and depending affinity, it will do stuff either in mysql or sqlite module. Both modules share the same API, and SQL_SetAffinity basically just allows you to switch module.
You don't explain really what you want to do, but if you want to change "mysql" to "sqlite", yes, just a matter to change what you say, and adding #pragma (the first) to make sqlite be autoloaded.
public plugin_cfg(){ sql = SQL_MakeDbTuple(host,user,pass,db) formatex(g_query,511,"CREATE TABLE IF NOT EXISTS `played_time` (name VARCHAR(32), playedtime INT, date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP)") SQL_ThreadQuery(sql,"query",g_query) }
public handle_say(id) { static said[12] read_argv(1, said, 11)
switch(get_pcvar_num(showpt)) { case 0: return PLUGIN_HANDLED;
case 1 : { client_print(id, print_chat, "[Played Time] You have been playing on the server for: %d minute%s.", timep, timep == 1 ? "" : "s"); client_print(id, print_chat, "[Played Time] Your total played time on the server: %d minute%s.", timep+PlayedTime[id], timep+PlayedTime[id] == 1 ? "" : "s"); } case 2 : { set_hudmessage(255, 50, 50, 0.34, 0.50, 0, 6.0, 4.0, 0.1, 0.2, -1); show_hudmessage(id, "[Played Time] You have been playing on the server for: %d minute%s.^n[AMXX]Current time: %s", timep, timep == 1 ? "" : "s", ctime); } } return PLUGIN_HANDLED; } else if(equal(said,"/top15_time")){ new data[1];data[0]=id
formatex(g_query,511,"SELECT * FROM played_time ORDER BY playedtime DESC LIMIT 15") SQL_ThreadQuery(sql,"show_top15",g_query,data,1)
} return PLUGIN_CONTINUE; }
public admin_showptime(id,level,cid) { if(!cmd_access(id, level, cid, 2)) return PLUGIN_HANDLED;
console_print(id, "-----------------------(#PlayedTime#)-----------------------"); console_print(id, "[Played Time] %s have been playing on the server for %d minute%s.",name, timep, timep == 1 ? "" : "s"); console_print(id, "[Played Time] %s's total played time on the server %d minute%s.",name, timep+PlayedTime[player], timep == 1 ? "" : "s"); // new console_print(id, "-----------------------------------------------------------------");