#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <sqlx>
#include <zombieplague>
#define PLUGIN "SIGN IN SYSTEM"
#define VERSION "1.0"
#define AUTHOR "NAG"
#define LOADING "^n^t%s v%s, Copyright (C) 2014 by %s^n"
new Handle:g_SqlTuple;
new g_Error[512];
new g_SetAllow[33];
new g_host[33];
new g_user[33];
new g_pass[33];
new g_dbname[33];
new g_tabname[33];
new g_retryonce[33];
new Handle:g_Sql = Empty_Handle
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
server_print(LOADING,PLUGIN,VERSION,AUTHOR);
register_forward(FM_ClientUserInfoChanged, "fwdClientUserInfoChanged");
register_cvar("amx_sql_host", "127.0.0.1");
register_cvar("amx_sql_user", "");
register_cvar("amx_sql_pass", "");
register_cvar("amx_sql_db", "");
register_cvar("amx_sql_table", "");
register_clcmd("say /qiandao","sign_say",ADMIN_ALL,"读取玩家说的话")
new configsDir[64];
get_configsdir(configsDir, 63);
server_cmd("exec %s/sql.cfg", configsDir);
server_exec();
}
public plugin_cfg()
{
get_cvar_string("amx_sql_host",g_host,32);
get_cvar_string("amx_sql_user",g_user,32);
get_cvar_string("amx_sql_pass",g_pass,32);
get_cvar_string("amx_sql_db",g_dbname,32);
get_cvar_string("amx_sql_table",g_tabname,32);
MySql_Init();
}
public MySql_Init()
{
g_SqlTuple = SQL_MakeDbTuple(g_host,g_user,g_pass,g_dbname);
new ErrorCode,Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,charsmax(g_Error));
if(SqlConnection == Empty_Handle)
set_fail_state(g_Error);
new Handle:Queries;
Queries = SQL_PrepareQuery(SqlConnection,"CREATE TABLE IF NOT EXISTS %s (date int(30),name varchar(64), state varchar(64))", g_tabname);
if(!SQL_Execute(Queries))
{
SQL_QueryError(Queries,g_Error,charsmax(g_Error));
set_fail_state(g_Error);
}
SQL_FreeHandle(Queries);
SQL_FreeHandle(SqlConnection);
}
public plugin_end()
SQL_FreeHandle(g_SqlTuple);
public sign_say(id){
new ErrorCode,Handle:SqlConnectionc = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,charsmax(g_Error));
new username[64]
new timed[9]
new xyb
xyb = random_num(10,100)
get_time("%m%d%Y",timed,8)
get_user_name(id,username,63)
if(is_user_connected(id))
{
new chaxun;
chaxun = SQL_QueryAndIgnore(SqlConnectionc,"SELECT * FROM %s WHERE date = %d AND name = %s", g_tabname, str_to_num(timed) ,username[id]);
if(chaxun == 0){
SQL_QueryAndIgnore(SqlConnectionc,"INSERT INTO %s SET date = %d , name = %s, state = 'on'", g_tabname, str_to_num(timed) ,username[id])
client_print(0,print_chat,"【元朝天尊每日签到】玩家[%s]签到成功,获得%d天尊币随机奖励!",username[id],xyb)
zp_set_user_ammo_packs(id,zp_get_user_ammo_packs(id) + xyb)
}
else
{
client_print(id,print_chat,"【元朝天尊每日签到】您今日已经签过到了,赶明儿再来签到吧!")
}
SQL_FreeHandle(chaxun) ;
}
}