Balgaa
No, what you want it sucks. MySQL best solution that can be associated with the web site. And then make donations associated with online payments. :-) But really, it's unnecessary. In CS 1.6 not earn much.
--------
SQL_ThreadQuery - asynchronous function. Processing occurs asynchronously.
Add protective logic:
g_async_loaded[id]
PHP Code:
public client_disconnect(id) {
if (!get_pcvar_num(g_cvar_enable) || g_Sql == Empty_Handle)
return ;
GetAuthId(id,g_szAuth[id],31);
if(g_async_loaded[id] == true)
SaveClientBank(id);
g_BankSqlOpened[id] = false;
}
if(g_BankSqlOpened[id] == true) - not work correctly.
PHP Code:
public LoadClient_QueryHandler(iFailState, Handle:hQuery, szError[], iErrnum, szData[], iSize, Float:fQueueTime) {
if(iFailState != TQUERY_SUCCESS) {
log_amx("%s SQL Error #%d - %s", PLUGIN_PREFIX, iErrnum, szError);
return ;
}
new id = szData[0];
if (szData[1] != get_user_userid(id))
return ;
new packs = get_pcvar_num(g_cvar_startedammo);
if(SQL_NumResults(hQuery))
packs = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "amount"));
g_BankSql[id] = packs;
if(g_BankSqlOpened[id] == true) {
if(get_pcvar_num(g_cvar_auto_load_on_connect)) {
zp_set_user_ammo_packs(id, g_BankSql[id]);
g_async_loaded[id] = true
}
}
}
PHP Code:
public SaveClientBank(id) {
if (g_Sql == Empty_Handle) return ;
new packs;
if(get_pcvar_num(g_cvar_auto_load_on_connect)) packs = zp_get_user_ammo_packs(id);
else packs = g_BankSql[id];
new limit = get_pcvar_num(g_cvar_save_limit);
if(limit && packs > limit) {
packs = limit;
}
new szQuery[200];
format(szQuery, 199, "REPLACE INTO %s (auth,amount,timestamp) VALUES('%s', '%d', '%d');", g_SqlTable, g_szAuth[id], packs, get_systime());
SQL_QueryAndIgnore(g_Sql, szQuery);
g_async_loaded[id] = false
}
If you're not careful with asynchronous functions, they can cause a loss of credits. As it was in earlier versions of my scripts :-)
RU: А вообще, там подводных камней предостаточно
__________________