Пользователь
- Сообщения
- 12
- Реакции
- 2
- Ошибка
-
Ошибки нету
- ОС
- Linux
- Amx Mod X
-
AMX Mod X 1.9.0.5263
- Билд
-
Protocol version 48
Exe version 1.1.2.7/Stdio (cstrike)
ReHLDS version: 3.7.0.692-dev-mpatch
Build date: 18:13:20 Sep 30 2019 (1997)
- ReGamedll
-
ReGameDLL version: 5.12.0.425-dev
Build date: 08:48:23 Nov 2 2019
Build from: https://github.com/s1lentq/ReGameDLL_CS/commit/fd06d65
- Версия Metamod
-
Metamod v1.21p37 2013/05/30 (5:13)
by Will Day
http://www.metamod.org/
Patch: Metamod-P (mm-p) v37
by Jussi Kivilinna
http://metamod-p.sourceforge.net/
compiled: May 30 2013, 11:41:16 EET (optimized)
- Список метамодулей
-
description stat pend file vers src load unlod
[ 1] Reunion RUN - reunion_mm_i386. v0.1.75 ini Start Never
[ 2] VoiceTranscoder RUN - VoiceTranscoder. v2017RC4 ini ANY ANY
[ 3] SafeNameAndChat RUN - SafeNameAndChat. v1.1 ini ANY ANY
[ 4] Rechecker RUN - rechecker_mm_i38 v2.4 ini Chlvl ANY
[ 5] AMX Mod X RUN - amxmodx_mm_i386. v1.9.0.5 ini Start ANY
[ 6] MySQL RUN - mysql_amxx_i386. v1.9.0.5 pl5 ANY ANY
[ 7] FakeMeta RUN - fakemeta_amxx_i3 v1.9.0.5 pl5 ANY ANY
[ 8] CSX RUN - csx_amxx_i386.so v1.9.0.5 pl5 ANY ANY
[ 9] CStrike RUN - cstrike_amxx_i38 v1.9.0.5 pl5 ANY ANY
[10] Engine RUN - engine_amxx_i386 v1.9.0.5 pl5 ANY ANY
[11] Ham Sandwich RUN - hamsandwich_amxx v1.9.0.5 pl5 ANY ANY
[12] ReAPI RUN - reapi_amxx_i386. v5.11.0. pl5 ANY Never
[13] Fun RUN - fun_amxx_i386.so v1.9.0.5 pl5 ANY ANY
13 plugins, 13 running
- Список плагинов
-
[ 1] admin_loader 0.4 kanagava admin_loader.am running
[ 2] FreshBans 1.4.0b kanagava fresh_bans_140_ running
[ 3] Slots Reservation 1.9.0.5263 AMXX Dev Team adminslots.amxx running
[ 4] Admin Votes 1.9.0.5263 AMXX Dev Team adminvote.amxx running
[ 5] NextMap 1.9.0.5263 AMXX Dev Team nextmap.amxx running
[ 6] Nextmap Chooser 1.9.0.5263 AMXX Dev Team mapchooser.amxx running
[ 7] Anti Flood 1.9.0.5263 AMXX Dev Team antiflood.amxx running
[ 8] Scrolling Message 1.9.0.5263 AMXX Dev Team scrollmsg.amxx running
[ 9] Maps Menu 1.9.0.5263 AMXX Dev Team mapsmenu.amxx running
[ 10] Multi-Lingual System 1.9.0.5263 AMXX Dev Team multilingual.am running
[ 11] Stats Configuration 1.9.0.5249 AMXX Dev Team statscfg.amxx running
[ 12] StatsX Colored TOP15 1.9.0.5234 AMXX Dev Team Statsx_Colored_ running
[ 13] BlockKnifeBot versionCs raizo AntiCheat.amxx running
[ 14] AesInformerInfo lovecs b0t. AesInfo.amxx running
[ 15] Custom Environment 1.2 Lev CustomEnvironme running
[ 16] Advanced Gag 1.9.0 neygomon amx_gag.amxx running
[ 17] PrivatMessage lovecs b0t. pm.amxx running
[ 18] KnifeDuel lovecs b0t. kk.amxx running
[ 19] Jail_35hp_2 lovecs b0t. Jail.amxx running
[ 20] AFKCheck lovecs b0t. xAfkCheck.amxx running
[ 21] xServeRx lovecs b0t. EntoFiascoBrata running
[ 22] xUse lovecs b0t. parachute.amxx running
[ 23] CSModsHook lovecs b0t. CSMods_Hook.amx running
[ 24] CSModsGrab lovecs b0t. CSMods_Grab.amx running
[ 25] BestPlayer lovecs b0t. BestPlayer.amxx running
[ 26] [ReAPI] Custom Models 1.6.1 neugomon custom_models.a running
[ 27] Knife_GAMEGG.Ru lovecs b0t. GAMEGG.amxx running
[ 28] Autoresponder/Advertis 0.5 MaximusBrood ad_manager.amxx running
[ 29] Lite Translit 2.5.7b/11 neygomon lite_translit.a running
[ 30] SetTask lovecs b0t. reload.amxx running
[ 31] AutoDemo lovecs b0t. AutoDemo.amxx running
[ 32] Models Loader 0.1 mx?! models_loader.a running
[ 33] Hats 1.0 mx?! hats.amxx running
[ 34] Advanced Experience Sy 0.5 Vega serfreeman1337 aes_main.amxx running
[ 35] AES: CStrike Addon 0.5 Vega serfreeman1337 aes_exp_cstrike running
[ 36] AES: Informer 0.5 Vega serfreeman1337 aes_informer.am running
[ 37] KS: Core 1.0 mx?! ks_core.amxx debug
[ 38] KS: FrostNade 0.1 mx?! ks_frostnade.am debug
[ 39] KS: Gravity 1.0 mx?! ks_gravity.amxx debug
[ 40] KS: Lottery 1.0 mx?! ks_lottery.amxx debug
[ 41] KS: Form 1.0 mx?! ks_form.amxx debug
[ 42] KS: Drugs 1.0 mx?! ks_drugs.amxx debug
[ 43] KS: Deagle 1.0 mx?! ks_deagle.amxx debug
[ 44] KS: Health 1.0 mx?! ks_health.amxx debug
[ 45] KS: Invisibility 1.0 mx?! ks_invisibility debug
- Автор плагина
- serfreeman1337
- Версия плагина
- 0.5
- Исходный код
-
/*
* Advanced Experience System v. 0.5
* by serfreeman1337 http://1337.uz/
*/
#include <amxmodx>
#include <amxmisc>
#include <sqlx>
#define PLUGIN "Advanced Experience System"
#define VERSION "0.5 Vega"
#define AUTHOR "serfreeman1337"
#define LASTUPDATE "11, June (06), 2016"
#if AMXX_VERSION_NUM < 183
#include <colorchat>
#define print_team_default DontChange
#define print_team_grey Grey
#define print_team_red Red
#define print_team_blue Blue
#define MAX_NAME_LENGTH 32
#define MAX_PLAYERS 32
#define client_disconnected client_disconnect
new MaxClients
#endif
//
// Основано на CSstatsX SQL
// http://1337.uz/csstatsx-sql/
//
#pragma dynamic 32768
// -- КОНСТАНТЫ -- //
enum _:sql_que_type // тип sql запроса
{
SQL_DUMMY,
SQL_IMPORT, // импорт в БД из файла stats.ini
SQL_IMPORTFINISH,
SQL_LOAD, // загрузка статистики
SQL_UPDATE, // обновление
SQL_INSERT, // внесение новой записи
SQL_UPDATERANK, // получение ранков игроков,
SQL_GETSTATS // потоквый запрос на get_stats
}
enum _:load_state_type // состояние получение статистики
{
LOAD_NO, // данных нет
LOAD_WAIT, // ожидание данных
LOAD_NEW, // новая запись
LOAD_NEWWAIT, // новая запись, ждем ответа
LOAD_UPDATE, // перезагрузить после обновления
LOAD_OK // есть данные
}
enum _:cvars
{
CVAR_SQL_TYPE,
CVAR_SQL_HOST,
CVAR_SQL_USER,
CVAR_SQL_PASS,
CVAR_SQL_DB,
CVAR_SQL_TABLE,
CVAR_SQL_CREATE_DB,
CVAR_SQL_MAXFAIL,
CVAR_RANK,
CVAR_RANKBOTS,
CVAR_PAUSE,
CVAR_LEVELS
}
enum _:player_data_struct
{
PLAYER_ID, // id игрока БД
PLAYER_LOADSTATE, // состояние загрузки статистики игрока
Float:PLAYER_EXP, // тек. опыт игрока
Float:PLAYER_EXPLAST, // последний опыт игрока
PLAYER_BONUS, // бонусы игрока
PLAYER_BONUSLAST, // последнее кол-во бонусов
PLAYER_NAME[MAX_NAME_LENGTH * 3], // ник игрока
PLAYER_STEAMID[30], // steamid игрока
PLAYER_IP[16], // ip игрока
PLAYER_LEVEL, // уровень игрока
Float:PLAYER_LEVELEXP, // опыт для уровня
Float:PLAYER_EXP_TO_NEXT // требуемое кол-во опыта для сл. уровня игроку
}
enum _:aes_stats_struct
{
AES_S_NAME[MAX_NAME_LENGTH],
AES_S_STEAMID[30],
AES_S_IP[16],
Float:AES_S_EXP,
AES_S_LEVEL,
AES_S_BONUS,
AES_S_ID
}
enum _:row_ids // столбцы таблицы
{
ROW_ID,
ROW_NAME,
ROW_STEAMID,
ROW_IP,
ROW_EXP,
ROW_BONUS,
ROW_LASTUPDATE
}
enum _:
{
RT_NO,
RT_OK,
RT_LEVEL_DOWN,
RT_LEVEL_UP
}
new const row_names[row_ids][] = // имена столбцов
{
"id",
"name",
"steamid",
"ip",
"exp",
"bonus_count",
"last_update"
}
const QUERY_LENGTH = 1472 // мой ммр, когда я катаю пати
// -- ПЕРЕМЕННЫЕ --
new player_data[MAX_PLAYERS + 1][player_data_struct]
new cvar[cvars]
new tbl_name[32]
new Handle:sql
new cnt_sqlfail,bool:gg_sql
new Array:levels_list
new levels_count
new Float:max_exp
new FW_LevelUp,FW_LevelDown
new dummy
new flush_que[QUERY_LENGTH * 3],flush_que_len
new const task_flush = 11337
new bool:is_by_stats = false
public plugin_init()
{
register_plugin(PLUGIN,VERSION,AUTHOR)
server_print("")
server_print(" %s Copyright (c) 2016 %s",PLUGIN,AUTHOR)
server_print(" Version %s build on %s", VERSION, LASTUPDATE)
server_print("")
//
// Квары настройки подключения
//
cvar[CVAR_SQL_TYPE] = register_cvar("aes_sql_driver","sqlite")
cvar[CVAR_SQL_HOST] = register_cvar("aes_sql_host","",FCVAR_UNLOGGED|FCVAR_PROTECTED)
cvar[CVAR_SQL_USER] = register_cvar("aes_sql_user","",FCVAR_UNLOGGED|FCVAR_PROTECTED)
cvar[CVAR_SQL_PASS] = register_cvar("aes_sql_pass","",FCVAR_UNLOGGED|FCVAR_PROTECTED)
cvar[CVAR_SQL_DB] = register_cvar("aes_sql_name","amxx",FCVAR_UNLOGGED|FCVAR_PROTECTED)
cvar[CVAR_SQL_TABLE] = register_cvar("aes_sql_table","aes_stats",FCVAR_UNLOGGED|FCVAR_PROTECTED)
cvar[CVAR_SQL_MAXFAIL] = register_cvar("aes_sql_maxfail","10")
cvar[CVAR_SQL_CREATE_DB] = register_cvar("aes_sql_create_db","1")
cvar[CVAR_RANK] = register_cvar("aes_track_mode","1")
cvar[CVAR_RANKBOTS] = register_cvar("aes_track_bots","1")
cvar[CVAR_PAUSE] = register_cvar("aes_track_pause","0",FCVAR_SERVER)
cvar[CVAR_LEVELS] = register_cvar("aes_level","0 20 40 60 100 150 200 300 400 600 1000 1500 2100 2700 3400 4200 5100 5900 7000 10000")
FW_LevelUp = CreateMultiForward("aes_player_levelup",ET_IGNORE,FP_CELL,FP_CELL,FP_CELL)
FW_LevelDown = CreateMultiForward("aes_player_leveldown",ET_IGNORE,FP_CELL,FP_CELL,FP_CELL)
register_srvcmd("aes_import","ImportFromFile")
register_dictionary("aes.txt")
#if AMXX_VERSION_NUM < 183
MaxClients = get_maxplayers()
#endif
register_cvar("aes", VERSION, FCVAR_SERVER | FCVAR_SPONLY | FCVAR_UNLOGGED)
}
#pragma unused max_exp
//
// загрузка конфигурации
//
public plugin_cfg()
{
new cfg_path[256]
get_configsdir(cfg_path,charsmax(cfg_path))
server_cmd("exec %s/aes/aes.cfg",cfg_path)
server_exec()
// парсим уровни
new levels_string[512],level_str[10]
get_pcvar_string(cvar[CVAR_LEVELS],levels_string,charsmax(levels_string))
levels_list = ArrayCreate(1)
#if AMXX_VERSION_NUM < 183
if(levels_string[0])
{
new e_pos,s_pos
do {
e_pos = strfind(levels_string[s_pos]," ")
formatex(level_str,e_pos,levels_string[s_pos])
if(!levels_list)
{
levels_list = ArrayCreate(1)
}
ArrayPushCell(levels_list,floatstr(level_str))
max_exp = floatstr(level_str)
s_pos += e_pos + 1
} while (e_pos != -1)
}
#else
while((argbreak(levels_string,level_str,charsmax(level_str),levels_string,charsmax(levels_string))) != -1)
{
if(!levels_list)
{
levels_list = ArrayCreate(1)
}
ArrayPushCell(levels_list,floatstr(level_str))
max_exp = floatstr(level_str)
}
#endif
if(levels_list)
levels_count = ArraySize(levels_list)
// AES работает в режиме статистики по csx
// выключаем работу с БД
if(get_pcvar_num(cvar[CVAR_RANK]) == -1)
{
is_by_stats = true
return PLUGIN_CONTINUE
}
new db_type[12]
get_pcvar_string(cvar[CVAR_SQL_TYPE],db_type,charsmax(db_type))
new host[128],user[64],pass[64],db[64],type[10]
get_pcvar_string(cvar[CVAR_SQL_HOST],host,charsmax(host))
get_pcvar_string(cvar[CVAR_SQL_USER],user,charsmax(user))
get_pcvar_string(cvar[CVAR_SQL_PASS],pass,charsmax(pass))
get_pcvar_string(cvar[CVAR_SQL_DB],db,charsmax(db))
get_pcvar_string(cvar[CVAR_SQL_TABLE],tbl_name,charsmax(tbl_name))
get_pcvar_string(cvar[CVAR_SQL_TYPE],type,charsmax(type))
new query[QUERY_LENGTH]
if(strcmp(db_type,"mysql") == 0)
{
SQL_SetAffinity(db_type)
formatex(query,charsmax(query),"\
CREATE TABLE IF NOT EXISTS `%s` (\
`%s` int(11) NOT NULL AUTO_INCREMENT,\
`%s` varchar(32) NOT NULL,\
`%s` varchar(30) NOT NULL,\
`%s` varchar(16) NOT NULL,\
`%s` float NOT NULL DEFAULT '0.0',\
`%s` int(11) NOT NULL DEFAULT '0',\
`%s` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\
PRIMARY KEY (%s)\
);",
tbl_name,
row_names[ROW_ID],
row_names[ROW_NAME],
row_names[ROW_STEAMID],
row_names[ROW_IP],
row_names[ROW_EXP],
row_names[ROW_BONUS],
row_names[ROW_LASTUPDATE],
row_names[ROW_ID]
)
}
else if(strcmp(db_type,"sqlite") == 0)
{
SQL_SetAffinity(db_type)
// формируем запрос на создание таблицы
formatex(query,charsmax(query),"\
CREATE TABLE IF NOT EXISTS `%s` (\
`%s` INTEGER PRIMARY KEY AUTOINCREMENT,\
`%s` TEXT,\
`%s` TEXT,\
`%s` TEXT,\
`%s` REAL NOT NULL DEFAULT 0.0,\
`%s` INTEGER NOT NULL DEFAULT 0,\
`%s` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP\
);",
tbl_name,
row_names[ROW_ID],
row_names[ROW_NAME],
row_names[ROW_STEAMID],
row_names[ROW_IP],
row_names[ROW_EXP],
row_names[ROW_BONUS],
row_names[ROW_LASTUPDATE]
)
}
else // привет wopox
{
set_fail_state("invalid ^"aes_sql_driver^" cvar value")
}
sql = SQL_MakeDbTuple(host,user,pass,db,3)
// отправляем запрос на создание таблицы
if(get_pcvar_num(cvar[CVAR_SQL_CREATE_DB]))
{
new sql_data[1]
sql_data[0] = SQL_DUMMY
SQL_ThreadQuery(sql,"SQL_Handler",query,sql_data,sizeof sql_data)
}
return PLUGIN_CONTINUE
}
public plugin_end()
{
DB_FlushQuery()
}
//
// Функция импорта в БД из файла stats.ini
//
public ImportFromFile()
{
if(sql == Empty_Handle)
{
log_amx("db is diabled")
return false
}
new fPath[256],len
len = get_datadir(fPath,charsmax(fPath))
len += formatex(fPath[len],charsmax(fPath) - len,"/aes/stats.ini")
new f = fopen(fPath,"r")
if(!f)
{
log_amx("^"%s^" doesn't exists",
fPath)
return false
}
new query[QUERY_LENGTH],sql_data[2] = SQL_DUMMY
log_amx("import started")
log_amx("clearing ^"%s^" table",
tbl_name)
// очищаем таблицу перед началом импорта
formatex(query,charsmax(query),"DELETE FROM `%s` WHERE 1;",
tbl_name)
SQL_ThreadQuery(sql,"SQL_Handler",query,sql_data,sizeof sql_data)
new track_field
// сверяем track_id
switch(get_pcvar_num(cvar[CVAR_RANK]))
{
case 0: // статистика по нику
{
track_field = ROW_NAME
}
case 1: // статистика по steamid
{
track_field = ROW_STEAMID
}
case 2: // статистика по ip
{
track_field = ROW_IP
}
default:
{
return false
}
}
while(!feof(f))
{
new buffer[512]
fgets(f,buffer,charsmax(buffer))
trim(buffer)
if(!buffer[0] || buffer[0] == ';')
continue
new trackId[MAX_NAME_LENGTH * 3],userName[MAX_NAME_LENGTH * 3],sStats[4][12],import_data[31]
import_data[0] = SQL_IMPORT
parse(buffer,trackId,charsmax(trackId),
userName,charsmax(userName),
sStats[0],charsmax(sStats[]),
sStats[3],charsmax(sStats[]),
sStats[1],charsmax(sStats[]),
sStats[2],charsmax(sStats[])
)
copy(import_data[1],charsmax(import_data) - 1,trackId)
mysql_escape_string(trackId,charsmax(trackId))
mysql_escape_string(userName,charsmax(userName))
new lastdate[40]
format_time(lastdate,charsmax(lastdate),"%Y-%m-%d %H:%M:%S",str_to_num(sStats[2]))
// строим запрос на импорит
if(track_field != ROW_NAME)
{
len = formatex(query,charsmax(query),"INSERT INTO `%s` (`%s`,`%s`,`%s`,`%s`,`%s`)\
VALUES('%s','%s','%.2f','%d','%s');",
tbl_name,
row_names[track_field],
row_names[ROW_NAME],
row_names[ROW_EXP],
row_names[ROW_BONUS],
row_names[ROW_LASTUPDATE],
trackId,
userName,
str_to_float(sStats[0]),
str_to_num(sStats[1]),
lastdate
)
}
else
{
len = formatex(query,charsmax(query),"INSERT INTO `%s` (`%s`,`%s`,`%s`,`%s`)\
VALUES('%s','%.2f','%d','%s');",
tbl_name,
row_names[track_field],
row_names[ROW_EXP],
row_names[ROW_BONUS],
row_names[ROW_LASTUPDATE],
trackId,
str_to_float(sStats[0]),
str_to_num(sStats[1]),
lastdate
)
}
SQL_ThreadQuery(sql,"SQL_Handler",query,import_data,sizeof import_data)
}
sql_data[0] = SQL_IMPORTFINISH
// запрос при окончании импорта
formatex(query,charsmax(query),"SELECT COUNT(*) FROM `%s`",tbl_name)
SQL_ThreadQuery(sql,"SQL_Handler",query,sql_data,sizeof sql_data)
fclose(f)
return true
}
//
// Загружаем статистику из БД при подключении игрока
//
public client_putinserver(id)
{
DB_LoadPlayerData(id)
}
//
// Сохраняем данные на дисконнекте
//
public client_disconnected(id)
{
DB_SavePlayerData(id)
}
//
// Смена ника игрока
//
public client_infochanged(id)
{
new cur_name[MAX_NAME_LENGTH],new_name[MAX_NAME_LENGTH]
get_user_name(id,cur_name,charsmax(cur_name))
get_user_info(id,"name",new_name,charsmax(new_name))
if(strcmp(cur_name,new_name) != 0)
{
copy(player_data[id][PLAYER_NAME],charsmax(player_data[][PLAYER_NAME]),new_name)
mysql_escape_string(player_data[id][PLAYER_NAME],charsmax(player_data[][PLAYER_NAME]))
if(get_pcvar_num(cvar[CVAR_RANK]) == 0)
{
DB_SavePlayerData(id,true)
}
}
}
//
// Задаем опыт игроку
//
Player_SetExp(id,Float:new_exp,bool:no_forward = false,bool:force = false)
{
// статистика на паузе
if(get_pcvar_num(cvar[CVAR_PAUSE]) && !force)
{
return RT_NO
}
// опыт не может быть отрицательным
if(new_exp < 0.0)
new_exp = 0.0
new rt = RT_OK
player_data[id][PLAYER_EXP] = _:new_exp
// понижение по уровню
if(new_exp < player_data[id][PLAYER_EXP_TO_NEXT])
{
rt = RT_LEVEL_DOWN
}
// повышение по уровню
else if(new_exp >= player_data[id][PLAYER_EXP_TO_NEXT])
{
rt = RT_LEVEL_UP
}
// расчитываем новый уровень
if(rt != RT_OK)
{
new old_level = player_data[id][PLAYER_LEVEL]
new level = player_data[id][PLAYER_LEVEL] = Level_GetByExp(new_exp)
player_data[id][PLAYER_LEVELEXP] = _:Level_GetExp(player_data[id][PLAYER_LEVEL])
player_data[id][PLAYER_EXP_TO_NEXT] = _:Level_GetExpToNext(player_data[id][PLAYER_LEVEL])
if(!no_forward)
{
new fw
if(level > old_level)
{
fw = FW_LevelUp
}
else if(level < old_level)
{
fw = FW_LevelDown
}
if(fw)
{
ExecuteForward(fw,dummy,id,level,old_level)
}
}
}
return rt
}
//
// Задаем бонусы игрока
//
Player_SetBonus(id,bonus,bool:force = false)
{
// статистика на паузе
if(get_pcvar_num(cvar[CVAR_PAUSE]) && !force)
{
return false
}
player_data[id][PLAYER_BONUS] = bonus
return true
}
//
// Задаем уровень игроку
//
Player_SetLevel(id,level,bool:force = false)
{
// статистика на паузе
if(get_pcvar_num(cvar[CVAR_PAUSE]) && !force)
{
return false
}
new Float:exp = Level_GetExp(level)
if(exp == -1.0)
{
return false
}
player_data[id][PLAYER_EXP] = _:exp
player_data[id][PLAYER_LEVEL] = level
player_data[id][PLAYER_LEVELEXP] = _:Level_GetExp(player_data[id][PLAYER_LEVEL])
player_data[id][PLAYER_EXP_TO_NEXT] = _:Level_GetExpToNext(player_data[id][PLAYER_LEVEL])
return true
}
//
// Функция возвращается текущий уровень по значению опыта
//
Level_GetByExp(Float:exp)
{
for(new i ; i < levels_count ; i++)
{
// ищем уровень по опыту
if(exp < ArrayGetCell(levels_list,i))
{
return clamp(i - 1,0,levels_count - 1)
}
}
// возвращаем максимальный уровень
return levels_count - 1
}
//
// Функция возвращает необходимый опыт до сл. уровня
//
Float:Level_GetExpToNext(level)
{
level ++
// достигнут максимальный уровень
if(level >= levels_count)
{
return -1.0
}
// TODO: проверки
level = clamp(level,0,levels_count - 1)
return ArrayGetCell(levels_list,level)
}
//
// Функция возвращает опыт для указанного уровня
//
Float:Level_GetExp(level)
{
if(!(0 <= level < levels_count))
return -1.0
return ArrayGetCell(levels_list,level)
}
//
// Загрузка статистики игрока из базы данных
//
DB_LoadPlayerData(id)
{
if(sql == Empty_Handle)
{
return false
}
// проблемы с соединением
if(gg_sql)
{
return false
}
// пропускаем HLTV
if(is_user_hltv(id))
{
return false
}
// пропускаем ботов, если отключена запись статистики ботов
if(!get_pcvar_num(cvar[CVAR_RANKBOTS]) && is_user_bot(id))
{
return false
}
arrayset(player_data[id],0,player_data_struct)
get_user_info(id,"name",player_data[id][PLAYER_NAME],MAX_NAME_LENGTH - 1)
mysql_escape_string(player_data[id][PLAYER_NAME],charsmax(player_data[][PLAYER_NAME]))
get_user_authid(id,player_data[id][PLAYER_STEAMID],charsmax(player_data[][PLAYER_STEAMID]))
get_user_ip(id,player_data[id][PLAYER_IP],charsmax(player_data[][PLAYER_IP]),true)
// формируем SQL запрос
new query[QUERY_LENGTH],len,sql_data[2]
sql_data[0] = SQL_LOAD
sql_data[1] = id
player_data[id][PLAYER_LOADSTATE] = LOAD_WAIT
len += formatex(query[len],charsmax(query)-len,"SELECT *")
switch(get_pcvar_num(cvar[CVAR_RANK]))
{
case 0: // статистика по нику
{
len += formatex(query[len],charsmax(query)-len," FROM `%s` WHERE `name` = '%s'",
tbl_name,player_data[id][PLAYER_NAME]
)
}
case 1: // статистика по steamid
{
len += formatex(query[len],charsmax(query)-len," FROM `%s` WHERE `steamid` = '%s'",
tbl_name,player_data[id][PLAYER_STEAMID]
)
}
case 2: // статистика по ip
{
len += formatex(query[len],charsmax(query)-len," FROM `%s` WHERE `ip` = '%s'",
tbl_name,player_data[id][PLAYER_IP]
)
}
default:
{
return false
}
}
// отправка потокового запроса
SQL_ThreadQuery(sql,"SQL_Handler",query,sql_data,sizeof sql_data)
return true
}
//
// Сохранение статистики игрока
//
DB_SavePlayerData(id,bool:reload = false)
{
if(sql == Empty_Handle)
{
return false
}
// проблемы с соединением
if(gg_sql)
{
return false
}
if(player_data[id][PLAYER_LOADSTATE] < LOAD_OK && player_data[id][PLAYER_LOADSTATE] != LOAD_NEW) // игрок не загрузился
{
return false
}
new query[QUERY_LENGTH],len
new sql_data[2]
sql_data[1] = id
switch(player_data[id][PLAYER_LOADSTATE])
{
case LOAD_OK: // обновление данных
{
if(reload)
{
player_data[id][PLAYER_LOADSTATE] = LOAD_UPDATE
}
sql_data[0] = SQL_UPDATE
new to_save
len += formatex(query[len],charsmax(query) - len,"UPDATE `%s` SET",tbl_name)
new Float:diffexp = player_data[id][PLAYER_EXP] - player_data[id][PLAYER_EXPLAST]
new diffbonus = player_data[id][PLAYER_BONUS] - player_data[id][PLAYER_BONUSLAST]
if(diffexp != 0.0)
{
len += formatex(query[len],charsmax(query) - len,"`%s` = `%s` + '%.2f'",
row_names[ROW_EXP],
row_names[ROW_EXP],
_:diffexp >= 0 ? diffexp + 0.005 : diffexp - 0.005
)
player_data[id][PLAYER_EXPLAST] = _:player_data[id][PLAYER_EXP]
to_save ++
}
if(diffbonus != 0)
{
len += formatex(query[len],charsmax(query) - len,"%s`%s` = `%s` + '%d'",
to_save ? "," : "",
row_names[ROW_BONUS],
row_names[ROW_BONUS],
diffbonus
)
player_data[id][PLAYER_BONUSLAST] = player_data[id][PLAYER_BONUS]
to_save ++
}
// обновляем время последнего подключения, ник, ип и steamid
len += formatex(query[len],charsmax(query) - len,",\
`%s` = CURRENT_TIMESTAMP,\
`%s` = '%s',\
`%s` = '%s'",
row_names[ROW_LASTUPDATE],
row_names[ROW_STEAMID],player_data[id][PLAYER_STEAMID],
row_names[ROW_IP],player_data[id][PLAYER_IP]
)
if(!reload) // не обновляем ник при его смене
{
len += formatex(query[len],charsmax(query) - len,",`%s` = '%s'",
row_names[ROW_NAME],player_data[id][PLAYER_NAME]
)
}
len += formatex(query[len],charsmax(query) - len,"WHERE `%s` = '%d'",row_names[ROW_ID],player_data[id][PLAYER_ID])
if(!to_save) // нечего сохранять
{
// я обманул. азазаза
if(player_data[id][PLAYER_LOADSTATE] == LOAD_UPDATE)
{
player_data[id][PLAYER_LOADSTATE] = LOAD_NO
DB_LoadPlayerData(id)
}
return false
}
}
case LOAD_NEW: // запрос на добавление новой записи
{
sql_data[0] = SQL_INSERT
formatex(query,charsmax(query),"INSERT INTO `%s` \
(`%s`,`%s`,`%s`,`%s`,`%s`)\
VALUES('%s','%s','%s','%.2f','%d')\
",tbl_name,
row_names[ROW_NAME],
row_names[ROW_STEAMID],
row_names[ROW_IP],
row_names[ROW_EXP],
row_names[ROW_BONUS],
player_data[id][PLAYER_NAME],
player_data[id][PLAYER_STEAMID],
player_data[id][PLAYER_IP],
player_data[id][PLAYER_EXP],
player_data[id][PLAYER_BONUS]
)
if(reload)
{
player_data[id][PLAYER_LOADSTATE] = LOAD_UPDATE
}
else
{
player_data[id][PLAYER_LOADSTATE] = LOAD_NEWWAIT
}
}
}
if(query[0])
{
switch(sql_data[0])
{
// накапливаем запросы
case SQL_UPDATE:
{
// запросов достаточно, сбрасываем их
DB_AddQuery(query,len)
return true
}
}
SQL_ThreadQuery(sql,"SQL_Handler",query,sql_data,sizeof sql_data)
}
return true
}
DB_AddQuery(query[],len)
{
if((flush_que_len + len + 1) > charsmax(flush_que))
{
DB_FlushQuery()
}
flush_que_len += formatex(
flush_que[flush_que_len],
charsmax(flush_que) - flush_que_len,
"%s%s",flush_que_len ? ";" : "",
query
)
// задание на сброс накопленных запросов
remove_task(task_flush)
set_task(0.1,"DB_FlushQuery",task_flush)
}
//
// Сброс накопленных запросов
//
public DB_FlushQuery()
{
if(sql == Empty_Handle)
{
return false
}
if(gg_sql)
{
return false
}
if(flush_que_len)
{
new sql_data[1] = SQL_UPDATE
SQL_ThreadQuery(sql,"SQL_Handler",flush_que,sql_data,sizeof sql_data)
flush_que_len = 0
}
return true
}
//
// Хандлер SQL ответа
//
public SQL_Handler(failstate,Handle:sqlQue,err[],errNum,data[],dataSize){
switch(failstate)
{
case TQUERY_CONNECT_FAILED:
{
log_amx("SQL connection failed")
log_amx("[ %d ] %s",errNum,err)
cnt_sqlfail ++
if(cnt_sqlfail >= get_pcvar_num(cvar[CVAR_SQL_MAXFAIL]) && !gg_sql)
{
log_amx("db query is disabled for this map")
gg_sql = true
}
return PLUGIN_HANDLED
}
case TQUERY_QUERY_FAILED:
{
new lastQue[QUERY_LENGTH]
SQL_GetQueryString(sqlQue,lastQue,charsmax(lastQue)) // узнаем запрос
log_amx("SQL query failed")
log_amx("[ %d ] %s",errNum,err)
log_amx("[ SQL ] [%s]",lastQue)
cnt_sqlfail ++
if(cnt_sqlfail >= get_pcvar_num(cvar[CVAR_SQL_MAXFAIL]) && !gg_sql)
{
log_amx("db query is disabled for this map")
gg_sql = true
}
return PLUGIN_HANDLED
}
}
switch(data[0])
{
case SQL_LOAD: // загрзука статистики игрока
{
new id = data[1]
if(!is_user_connected(id))
{
return PLUGIN_HANDLED
}
if(SQL_NumResults(sqlQue)) // считываем статистику
{
player_data[id][PLAYER_LOADSTATE] = LOAD_OK
player_data[id][PLAYER_ID] = SQL_ReadResult(sqlQue,ROW_ID)
new Float:exp
SQL_ReadResult(sqlQue,ROW_EXP,exp)
Player_SetExp(id,exp,true,true)
player_data[id][PLAYER_EXPLAST] = _:player_data[id][PLAYER_EXP]
player_data[id][PLAYER_BONUS] = player_data[id][PLAYER_BONUSLAST] = SQL_ReadResult(sqlQue,ROW_BONUS)
}
else // помечаем как нового игрока
{
player_data[id][PLAYER_LOADSTATE] = LOAD_NEW
DB_SavePlayerData(id) // добавляем запись в базу данных
}
}
case SQL_INSERT: // запись новых данных
{
new id = data[1]
if(is_user_connected(id))
{
if(player_data[id][PLAYER_LOADSTATE] == LOAD_UPDATE)
{
player_data[id][PLAYER_LOADSTATE] = LOAD_NO
DB_LoadPlayerData(id)
return PLUGIN_HANDLED
}
player_data[id][PLAYER_ID] = SQL_GetInsertId(sqlQue) // первичный ключ
player_data[id][PLAYER_LOADSTATE] = LOAD_OK // данные загружены
Player_SetExp(id,player_data[id][PLAYER_EXP],true,true)
player_data[id][PLAYER_EXPLAST] = _:player_data[id][PLAYER_EXP]
player_data[id][PLAYER_BONUS] = player_data[id][PLAYER_BONUSLAST] = 0
// я упрлся 0)0)0
}
}
case SQL_UPDATE: // обновление данных
{
new players[MAX_PLAYERS],pnum
get_players(players,pnum)
for(new i,player ; i < pnum ; i++)
{
player = players[i]
if(player_data[player][PLAYER_LOADSTATE] == LOAD_UPDATE)
{
player_data[player][PLAYER_LOADSTATE] = LOAD_NO
DB_LoadPlayerData(player)
}
}
}
case SQL_IMPORT:
{
log_amx("imported ^"%s^" with new id ^"%d^"",
data[1],
SQL_GetInsertId(sqlQue)
)
}
case SQL_IMPORTFINISH:
{
log_amx("import finished. %d entries imported.",
SQL_ReadResult(sqlQue,0)
)
new players[MAX_PLAYERS],pnum
get_players(players,pnum)
for(new i ; i < pnum ; i++)
{
DB_LoadPlayerData(players[i])
}
}
case SQL_GETSTATS: // aes_find_stats
{
new id = data[1]
new Array:aes_stats_array = ArrayCreate(aes_stats_struct)
new aes_stats[aes_stats_struct]
while(SQL_MoreResults(sqlQue))
{
SQL_ReadResult(sqlQue,ROW_NAME,aes_stats[AES_S_NAME],charsmax(aes_stats[AES_S_NAME]))
SQL_ReadResult(sqlQue,ROW_STEAMID,aes_stats[AES_S_STEAMID],charsmax(aes_stats[AES_S_STEAMID]))
SQL_ReadResult(sqlQue,ROW_IP,aes_stats[AES_S_IP],charsmax(aes_stats[AES_S_IP]))
SQL_ReadResult(sqlQue,ROW_EXP,aes_stats[AES_S_EXP])
aes_stats[AES_S_LEVEL] = Level_GetByExp(aes_stats[AES_S_EXP])
aes_stats[AES_S_ID] = SQL_ReadResult(sqlQue,ROW_ID)
ArrayPushArray(aes_stats_array,aes_stats)
SQL_NextRow(sqlQue)
}
// передаваемые данные
new stats_size = (dataSize - 4) // почему 4? потому что не 3
new stats_data[32]
for(new i ; i < (dataSize - 4) ; i++)
{
stats_data[i] = data[4 + i]
}
// callback
if(callfunc_begin_i(data[3],data[2]))
{
callfunc_push_int(id)
callfunc_push_int(_:aes_stats_array)
callfunc_push_array(stats_data,stats_size)
callfunc_end()
}
}
}
return PLUGIN_HANDLED
}
//
// API
//
#define CHECK_PLAYER(%1) \
if (!(0 < %1 <= MaxClients)) \
{ \
log_error(AMX_ERR_NATIVE, "player out of range (%d)", %1); \
return 0; \
}
public plugin_natives()
{
register_library("aes")
register_native("aes_set_player_exp","_aes_set_player_exp",true)
register_native("aes_get_player_exp","_aes_get_player_exp",true)
register_native("aes_get_player_reqexp","_aes_get_player_reqexp",true)
register_native("aes_set_player_bonus","_aes_set_player_bonus",true)
register_native("aes_get_player_bonus","_aes_get_player_bonus",true)
register_native("aes_set_player_level","_aes_set_player_level",true)
register_native("aes_get_player_level","_aes_get_player_level",true)
register_native("aes_get_max_level","_aes_get_max_level",true)
register_native("aes_get_level_name","_aes_get_level_name")
register_native("aes_get_exp_level","_aes_get_exp_level",true)
register_native("aes_get_level_reqexp","_aes_get_level_reqexp",true)
register_native("aes_find_stats_thread","_aes_find_stats_thread")
// 0.4 DEPRECATED
register_library("aes_main")
register_native("aes_add_player_exp","_aes_add_player_exp",true)
register_native("aes_add_player_bonus","_aes_add_player_bonus",true)
register_native("aes_get_stats","_aes_get_stats")
register_native("aes_get_player_stats","_aes_get_player_stats")
register_native("aes_set_player_stats","_aes_set_player_stats")
register_native("aes_set_level_exp","_aes_set_level_exp")
register_native("aes_get_level_name","_aes_get_level_name")
register_native("aes_get_level_for_exp","_aes_get_level_for_exp",true)
register_native("aes_get_exp_to_next_level","_aes_get_exp_to_next_level",true)
}
public _aes_find_stats_thread(plugin_id,params)
{
if(sql == Empty_Handle)
{
return false
}
if(gg_sql)
{
return false
}
new callback_func[32],func_id
new id = get_param(1)
new Array:track_ids = Array:get_param(2)
get_string(3,callback_func,charsmax(callback_func))
func_id = get_func_id(callback_func,plugin_id)
// неверно указана функция на callback
if(func_id == INVALID_PLUGIN_ID)
{
log_error(AMX_ERR_NATIVE,"invalid callback function ^"%s^"",callback_func)
return false
}
new stats_data[32],stats_size
// передаваемые данные
if(params == 5)
{
stats_size = get_param(5)
// лул
if(stats_size > sizeof stats_data)
{
log_error(AMX_ERR_NATIVE,"maximum data size is %d",sizeof stats_data)
return false
}
get_array(4,stats_data,stats_size)
}
new length = ArraySize(track_ids)
// не обрабатываем пустой массив
if(!length)
{
log_error(AMX_ERR_NATIVE,"passed empty track_ids array")
return false
}
// строим запрос
new query[QUERY_LENGTH],len
len += formatex(query,charsmax(query) - len,"SELECT * FROM `%s` WHERE ",
tbl_name
)
switch(get_pcvar_num(cvar[CVAR_RANK]))
{
case 0: // статистика по нику
{
len += formatex(query[len],charsmax(query)-len,"`%s` IN(",
row_names[ROW_NAME]
)
}
case 1: // статистика по steamid
{
len += formatex(query[len],charsmax(query)-len,"`%s` IN(",
row_names[ROW_STEAMID]
)
}
case 2: // статистика по ip
{
len += formatex(query[len],charsmax(query)-len,"`%s` IN(",
row_names[ROW_IP]
)
}
default:
{
log_error(AMX_ERR_NATIVE,"lol retard admin")
return false
}
}
for(new i,id_str[MAX_NAME_LENGTH * 3] ; i < length ; i++)
{
ArrayGetString(track_ids,i,id_str,charsmax(id_str))
mysql_escape_string(id_str,charsmax(id_str))
len += formatex(query[len],charsmax(query)-len,"%s'%s'",i == 0 ? "" : ",",id_str)
}
len += formatex(query[len],charsmax(query)-len,")")
new sql_data[4 + sizeof stats_data]
sql_data[0] = SQL_GETSTATS
sql_data[1] = id
sql_data[2] = plugin_id
sql_data[3] = func_id
// добавляем передаваемые данные
if(stats_size)
{
for(new i ; i < stats_size ; i++)
{
sql_data[4 + i] = stats_data[i]
}
}
SQL_ThreadQuery(sql,"SQL_Handler",query,sql_data,4 + stats_size)
return true
}
public _aes_set_player_exp(id,Float:exp,bool:no_forward,bool:force)
{
CHECK_PLAYER(id)
if(is_by_stats)
{
player_data[id][PLAYER_LOADSTATE] = LOAD_OK
}
return Player_SetExp(id,exp,no_forward,force)
}
public _aes_get_player_exp(id)
{
CHECK_PLAYER(id)
if(player_data[id][PLAYER_LOADSTATE] != LOAD_OK)
{
return _:-1.0
}
return _:player_data[id][PLAYER_EXP]
}
public _aes_get_player_reqexp(id)
{
CHECK_PLAYER(id)
return _:player_data[id][PLAYER_EXP_TO_NEXT]
}
public _aes_set_player_bonus(id,bonus,bool:force)
{
CHECK_PLAYER(id)
return Player_SetBonus(id,bonus,force)
}
public _aes_get_player_bonus(id)
{
CHECK_PLAYER(id)
return player_data[id][PLAYER_BONUS]
}
public _aes_set_player_level(id,level,bool:force)
{
CHECK_PLAYER(id)
return Player_SetLevel(id,level,force)
}
public _aes_get_player_level(id)
{
CHECK_PLAYER(id)
return player_data[id][PLAYER_LEVEL]
}
public _aes_get_max_level()
{
return levels_count
}
public _aes_get_level_name(plugin,params)
{
new level = get_param(1)
new len = get_param(3)
new idLang = get_param(4)
if(level > levels_count)
level = levels_count - 1
new LangKey[10],levelName[64]
formatex(LangKey,charsmax(LangKey),"LVL_%d",level + 1)
len = formatex(levelName,len,"%L",idLang,LangKey)
set_string(2,levelName,len)
return len
}
public _aes_get_exp_level(Float:exp)
{
return Level_GetByExp(exp)
}
public Float:_aes_get_level_reqexp(level)
{
return Level_GetExpToNext(level)
}
//
// ОБРАТНАЯ СОВМЕСТИМОСТЬ С 0.4
//
public _aes_get_stats()
{
return false
}
public _aes_add_player_exp(id,exp){
CHECK_PLAYER(id)
if(!exp)
return 0
return Player_SetExp(id,player_data[id][PLAYER_EXP] + float(exp))
}
public _aes_add_player_bonus(id,bonus)
{
CHECK_PLAYER(id)
if(!bonus)
return 0
return Player_SetBonus(id,player_data[id][PLAYER_BONUS] +bonus)
}
public _aes_get_player_stats(plugin,params){
new id = get_param(1)
CHECK_PLAYER(id)
if(player_data[id][PLAYER_LOADSTATE] == LOAD_NO)
return 0
new ret[4]
ret[0] = floatround(player_data[id][PLAYER_EXP])
ret[1] = player_data[id][PLAYER_LEVEL]
ret[2] = player_data[id][PLAYER_BONUS]
ret[3] = floatround(player_data[id][PLAYER_EXP_TO_NEXT])
set_array(2,ret,sizeof ret)
return 1
}
public _aes_set_player_stats(plugin,params){
if(params < 2)
{
log_error(AMX_ERR_NATIVE,"bad arguments num, expected 2, passed %d", params)
return 0
}
new id = get_param(1)
CHECK_PLAYER(id)
new st[3]
get_array(2,st,3)
if(st[0] > -1)
Player_SetExp(id,float(st[0]),true,true)
if(st[1] > -1)
Player_SetLevel(id,st[1])
if(st[2] > -1)
Player_SetBonus(id,st[2])
return 1
}
// что это за херня D:
public _aes_set_level_exp()
{
return false
}
public _aes_get_level_for_exp(exp)
{
return Level_GetByExp(float(exp))
}
public _aes_get_exp_to_next_level(lvl)
{
return floatround(Level_GetExpToNext(lvl))
}
public plugin_precache()
{
new amxx_version[10]
get_amxx_verstring(amxx_version,charsmax(amxx_version))
if(contain(amxx_version,"1.8.1") != -1)
{
log_amx("idite nahooy")
server_cmd("quit")
server_exec()
}
}
/********* mysql escape functions ************/
mysql_escape_string(dest[],len)
{
//copy(dest, len, source);
replace_all(dest,len,"\\","\\\\");
replace_all(dest,len,"\0","\\0");
replace_all(dest,len,"\n","\\n");
replace_all(dest,len,"\r","\\r");
replace_all(dest,len,"\x1a","\Z");
replace_all(dest,len,"'","''");
replace_all(dest,len,"^"","^"^"");
}
В общем, проблема такая:
На сервере стоит AES 0.5
Проблема в том, что я хотел добавить по больше рангов - 100 штук, было 20.
Добавил, всё прописал - конкретно в aes_level и aes_stats (прикрепил скрины, п.с звание классные, знаю)
И почему то работают только первые 20 званий, остальные не работают. Поставил себе через sql - 100ый уровень, но выдается 20-ый и пишет что я апнул макс ранг, так же пишет название 20-ого ранга. Хз в общем проблема, вроде всё правильно прописал. Прошу вашей помощи.
На сервере стоит AES 0.5
Проблема в том, что я хотел добавить по больше рангов - 100 штук, было 20.
Добавил, всё прописал - конкретно в aes_level и aes_stats (прикрепил скрины, п.с звание классные, знаю)
И почему то работают только первые 20 званий, остальные не работают. Поставил себе через sql - 100ый уровень, но выдается 20-ый и пишет что я апнул макс ранг, так же пишет название 20-ого ранга. Хз в общем проблема, вроде всё правильно прописал. Прошу вашей помощи.
В этой теме было размещено решение! Перейти к решению.
Download all Attachments
-
132.6 KB Просмотры: 319
-
157.1 KB Просмотры: 343