Рандомная замена ников игроков.

Статус
В этой теме нельзя размещать новые ответы.
Сообщения
58
Реакции
12
Помог
1 раз(а)
Основная информация

Проблема: Рандомная замена ников игроков.

Ошибка:
Происходит рандомная замена ников игроков после выхода из игры
Дополнительная информация

Amx Mod X: ReAMXX

Билд:
Код:
ReHLDS version: 3.3.0.606-dev
Build date: 22:17:58 Nov 8 2017 (1306)


ReGamedll:
Код:
ReGameDLL version: 5.3.0.269-dev
Build date: 22:20:07 Nov 12 2017


Список модулей:
PHP:
MySQL                   1.8.3-Re    AMX Mod X Dev Team   running    
ReAimDetector 0.2.0 ReHLDS Team running
Engine 1.8.3-Re AMX Mod X Dev Team running
CStrike 1.8.3-Re AMX Mod X Dev Team running
ReAPI 5.2.0.139- Asmodai & s1lent running
FakeMeta 1.8.3-Re AMX Mod X Dev Team running
Ham Sandwich 1.8.3-Re AMX Mod X Dev Team running
Fun 1.8.3-Re AMX Mod X Dev Team running
nVault 1.8.3-Re AMX Mod X Dev Team running


Список плагинов:
HTML:
Admin Loader       2.9         neygomon          admin_loader.am  running  
Lite Admin ESP 1.0 neygomon admin_esp.amxx running
Lite Bans 1.2 neugomon lite_bans.amxx running
Admin Commands 1.8.3-dev+ AMXX Dev Team admincmd.amxx running
Slots Reservation 1.2 pUzzlik admin_slots.amx running
Players Menu 1.3.2 neugomon players_menu.am running
Maps Menu 1.3.1 neugomon mapsmenu.amxx running
Ultimate Chats Co 2.8.3 neygomon ucc.amxx running
Admin Chat 1.8.3-dev+ AMXX Dev Team adminchat.amxx running
Admin Votes 1.8.3-dev+ AMXX Dev Team adminvote.amxx running
Stats Configurati 1.8.3-dev+ AMXX Dev Team statscfg.amxx running
Pause Plugins 1.8.3-Re AMXX Dev Team pausecfg.amxx running
Mode 2x2 2.5re s1lent mode.amxx running
ReAimDetector API 0.1.9 ReHLDS Team reaimdetector.a running
Lite VoteBan 1.4 neygomon lite_voteban.am running
AFK Control 1.4.1 [Rnd neygomon afk_control.amx running
Lite Recoder 1.0.1 neygomon amx_demorec_3.a running
Advert Messages 1.2.2 neygomon adverts.amxx running
[ReAPI] AWPoff 1.3 PAffAEJIkA :3 awp_off.amxx running
Advanced MapChoos 1.1.0 neygomon map_chooser.amx running
ScreenMaker 1.1 neygomon screen_maker.am running
Ping Control 1.31 neygomon Ping_Control.am running
Menus Front-End 1.4 neugomon menufront_end.a running
Admin_Check 0.1 CepeH9 adminChek.amxx running
Parachute for ALL 3.0 Leo_[BH] parachute_reapi running
DHUD Advert. 2.0 DUKKHAZ0R dhud_advert.amx running
Weapon Restrict 1.7 s1lent weapon_rest.amx running
Steam Bonus 1.3e Gudaus steam_bonus.amx running
KiLL Assist poka_4to_b PRoSToTeM@ kill_assist_rea running
unknown unknown unknown noteamflash.amx running
[ReAPI] Round Bal 1.1 neygomon round_balancer. running
Chat Manager 1.1.1-11 Mistrick chatmanager.amx running
Knife Duel with T 1.2 neygomon knife_duel.amxx running
pvpru ranget t 0.2.143 kekt AntiSoundESP.am running
Win Messages 1.0 neygomon win_messages.am running
Draw VIP Privileg 1.0 neygomon vip_priv.amxx running
TOPx by GameTime 1.0 neugomon top_by_gametime running
Killer ScreenFade 0.0.5 Vaqtincha reapi_killer_sc running
Menu 1.0 WaT_1 menu.amxx running
Christmas hat 0.3 AMXX.Shop christmas_hat.a running
Players MySQL Sta 1.2 neugomon players_mysql_s running
Random Weapons Wa 2.5.untest neugomon random_weapons_ running
Block 'Fire in th 0.1 Safety1st block_granade.a running
[ReVIP] System Co 2.5 full pUzzlik re_vip_core.amx running
[ReVIP] Menu 2.5 full pUzzlik re_vip_menu.amx debug
[ReVIP] Connected 2.5 full pUzzlik re_vip_connect_ paused
[ReVIP] Reset Sco 2.5 full pUzzlik re_vip_reset_sc paused
[ReVIP] Tab Info 2.5 full pUzzlik re_vip_tab_info running
[ReVIP] Damager 2.5 full pUzzlik re_vip_damager. paused
[ReVIP] Custom Sh 2.5 full pUzzlik re_vip_shop.amx running
[ReVIP] Custom De 2.5 full pUzzlik re_vip_custom_d running
[ReVIP] Custom AK 2.5 full pUzzlik re_vip_custom_a running
[ReVIP] Custom M4 2.5 full pUzzlik re_vip_custom_m running
[ReVIP] Custom Fa 2.5 full pUzzlik re_vip_custom_f running
[ReVIP] Custom Sc 2.5 full pUzzlik re_vip_custom_s running
[ReVIP] Custom AW 2.5 full pUzzlik re_vip_custom_a running


Список метамодулей:
PHP:
[ 1] SafeNameAndChat  RUN   -    SafeNameAndChat.so          v1.1            ini  ANY   ANY  
[ 2] Reunion RUN - reunion_mm_i386.so v0.1.75 ini Start Never
[ 3] ReAuthCheck RUN - reauthcheck_mm_i386.so v0.1.6 ini Start Never
[ 4] Rechecker RUN - rechecker_mm_i386.so v2.5 ini Chlvl ANY
[ 5] VoiceTranscoder RUN - vtc.so v2017RC3 ini ANY ANY
[ 6] AMX Mod X RUN - amxmodx_mm_i386.so v1.8.3-Re ini Start ANY
[ 7] WHBlocker RUN - whblocker_mm_i386.so v1.5.692 ini Chlvl ANY
[ 8] ReSRDetector RUN - resrdetector_mm_i386.so v0.1.0 ini Chlvl ANY
[ 9] ReSemiclip RUN - resemiclip_mm_i386.so v2.3.8 ini Chlvl ANY
[10] MySQL RUN - mysql_amxx_i386.so v1.8.3-Re pl6 ANY ANY
[11] ReAimDetector RUN - reaimdetector_amxx_i386.so v0.2.0 pl6 ANY Never
[12] Engine RUN - engine_amxx_i386.so v1.8.3-Re pl6 ANY ANY
[13] CStrike RUN - cstrike_amxx_i386.so v1.8.3-Re pl6 ANY ANY


Исходник:
Код:
// *************************************************************************************//
// Плагин загружен с www.neugomon.ru //
// Автор: Neygomon [ https://neugomon.ru/members/1/ ] //
// Официальная тема поддержки: https://neugomon.ru/threads/91/ //
// При копировании материала ссылка на сайт www.neugomon.ru ОБЯЗАТЕЛЬНА! //
// *************************************************************************************//


#include <amxmodx>
#include <engine>
#include <sqlx>
#include <player_stats>

#define MYSQL_HOST "127.0.0.1"
#define MYSQL_USER ""
#define MYSQL_PASS ""
#define MYSQL_DBDB ""

#define UpdateStatsType 2
// 1 - Обновить статистику игрока(жертвы, убийцы) при убийстве.
// Если Ваша база говно, то используйте этот метод
//
// 2 - Обновлять статистику всех игроков по таймеру, либо при запросе /rank, /top15 и тд
// Как по мне, самый адекватный способ :)
//
// 3 - Обновлять статистику всех игроков при убийстве кого-либо
// Статистика точнее, чем в UpdateStatsType 1 и UpdateStatsType 2, но ТЯЖЕЛЕЕ
// Используйте, если нужны точные данные и Ваша база сможет схавать такие издевательства :D
//
// Конечно же обновление и при дисконнекте!

#define FreqUpdateByTime 20.0
// Частота обновлений для UpdateStatsType 2
// Если не используете WEB или пофиг на актуальность данных - закомментируйте. Тогда обновления будут только при запросах

#define PrunedDays 10
// Через сколько дней удалять игроков из БД с момента последнего подключения

#define AntiFloodSecs 15
// Защита от флуда БД
// Спасает от идиотов, которые долбят стату постоянно, вызывая лаги

#define SendMeAndHpOnDeath
// Отправлять жертве инфу из say /me и say /hp

#define KillAssist 50
// Считать ассисты
// name1 + name2 by max damage
// Число - минимальный урон, начиная с которого игрок может считаться ассистом

new const g_arrViewSkills[][] =
{
"Lm", "L", "Lp", "Mm", "M", "Mp", "Hm", "H", "Hp", "Pm", "P", "Pp", "G"
};
new const g_arrViewRankSkills[][] =
{
"L-", "L", "L+", "M-", "M", "M+", "H-", "H", "H+", "P-", "P", "P+", "G"
};
new const g_arrItemSkills[] =
{
0, 60, 75, 85, 100, 115, 130, 140, 150, 165, 180, 195, 210
};
new const g_arrBodyParts[HIT_RIGHTLEG + 1][] =
{
"В тело", "B гoлoву", "B гpудь", "B живoт", "B лeвую pуку", "B пpaвую pуку", "B лeвую нoгу", "B пpaвую нoгу"
};

enum GetStatsStates
{
StatsNone = 666,
StatsRank,
StatsRankStats,
StatsTop15,
StatsMe,
StatsHp
};
enum _:QueryStates
{
LoadPlayer,
SavePlayer,
ResetStats,
RemoveLols
};
enum _:PlayerData
{
Frags,
Deaths,
HS,
Damage,
Shots,
Hits,
bPlanted,
bDefused,
bExploded,
#if defined KillAssist
aPlayers,
#endif
CLEAR_DATA,
#if defined KillAssist
aDamage[33],
#endif
Damage2,
LastHit,
KillerId,
KillerName[32],
Float:fDistance,
Float:fHpKiller,
Float:fApKiller,

Float:Skill,
hBox[HIT_RIGHTLEG + 1],
GameTime,
LastGetStats, // защита от флуда БД
AuthId[25] // кеш steamid
};
#if !defined MAX_PLAYERS
const MAX_PLAYERS = 32;
#endif
#if AMXX_VERSION_NUM < 183
#include <colorchat>
#define replace_string replace_all
#define client_disconnected client_disconnect
new MaxClients;
#endif
const MAX_QUERY_LENGTH = 1000;

new g_arrPlayerData[MAX_PLAYERS + 1][PlayerData];
new Handle:g_hSqlTuple;
new g_szQuery[MAX_QUERY_LENGTH], data[3];
new g_szAllPlayersUpdateQuery[18000];
new g_iLastUpdate;

new bool:g_bMySqlConnection,
bool:g_bResetStats;

#define IsUserValid(%0) (1 <= %0 <= MaxClients)

RegisterCmds()
{
register_srvcmd("remove_stats", "SrvCMD_RemoveStats");
register_clcmd("say /rank", "clCMD_SayRank");
register_clcmd("say /rankstats", "clCMD_SayRankStats");
register_clcmd("say /top15", "clCMD_SayTop15");
register_clcmd("say /me", "clCMD_SayMe");
register_clcmd("say /hp", "clCMD_SayHp");
}

RegisterEvents()
{
register_event("Damage", "eventDamage", "b", "2!0");
register_event("DeathMsg", "eventDeathMsg", "a", "1>0");
register_event("CurWeapon", "eventCurWeapon", "be", "1=1", "3>-1");
register_event("BarTime", "eventBarTimePlant", "be", "1=3");
register_event("BarTime", "eventBarTimeDefuse", "be", "1!3");
register_event("TextMsg", "eventBombPlanted", "a", "2=#Bomb_Planted");
register_event("TextMsg", "eventBombDefused", "a", "2=#Bomb_Defused");
register_event("TextMsg", "eventBombTargetBombed", "a", "2=#Target_Bombed");

register_event("HLTV", "ResetDamage", "a", "1=0", "2=0");
register_logevent("UpdateAllStats", 2, "1=Round_End");
}

public plugin_natives()
{
register_library("PlayerStats");
register_native("ps_remove_player", "native_ps_remove_player", 1);
register_native("ps_setinfo_player", "native_ps_setinfo_player", 1);
register_native("ps_get_player_damage", "native_ps_get_player_damage", 1);
register_native("ps_get_player_gametime", "native_ps_get_player_gametime", 1);
}

public plugin_init()
{
register_plugin("Players MySQL Stats", "1.2", "neugomon");

RegisterCmds();
RegisterEvents();
#if defined FreqUpdateByTime && UpdateStatsType == 2
set_task(FreqUpdateByTime, "UpdateAllStats", 13333, .flags = "b");
#endif
#if AMXX_VERSION_NUM < 183
MaxClients = get_maxplayers();
#endif
}

public plugin_cfg()
{
SQL_SetAffinity("mysql");
g_hSqlTuple = SQL_MakeDbTuple(MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DBDB, 1);
#if AMXX_VERSION_NUM >= 183
SQL_SetCharset(g_hSqlTuple, "utf8");
#endif
CheckMySQLConnection();
}
/*
public plugin_end()
UpdateAllStats(0, StatsNone);
*/
public client_putinserver(id)
{
if(!g_bMySqlConnection || g_bResetStats)
return;

arrayset(g_arrPlayerData[id], 0, PlayerData);
#if defined KillAssist
arrayset(_:g_arrPlayerData[id][aDamage], 0, sizeof g_arrPlayerData[][aDamage]);
#endif
data[0] = LoadPlayer;
data[1] = id;

get_user_authid(id, g_arrPlayerData[id][AuthId], charsmax(g_arrPlayerData[][AuthId]));
formatex(g_szQuery, charsmax(g_szQuery), "SELECT `skill`, `harray`, `gametime` FROM `players_stats` WHERE `authid` = '%s'", g_arrPlayerData[id][AuthId]);
SQL_ThreadQuery(g_hSqlTuple, "SqlQueryHandler", g_szQuery, data, sizeof(data));
}

public client_disconnected(id)
{
if(g_bMySqlConnection && !g_bResetStats)
{
g_arrPlayerData[id][GameTime] += get_user_time(id, 1);
UpdateStats(id, false);
}
}

public eventCurWeapon(id)
{
static plClips[33], plWeapon[33];
static weapon, clips;
weapon = read_data(2);
clips = read_data(3);

if(plClips[id] > clips && weapon == plWeapon[id])
g_arrPlayerData[id][Shots]++;

plWeapon[id] = weapon;
plClips[id] = clips;
}

public eventDamage(id)
{
if(IsUserValid(id))
{
static hitplace, attacker;
attacker = get_user_attacker(id, 0, hitplace);
if(IsUserValid(attacker) && attacker != id)
{
g_arrPlayerData[attacker][hBox][hitplace]++;
g_arrPlayerData[attacker][Hits]++;

static dmg; dmg = read_data(2);
g_arrPlayerData[attacker][Damage] += dmg;
g_arrPlayerData[attacker][Damage2] += dmg;
g_arrPlayerData[attacker][LastHit] = hitplace;
#if defined KillAssist
g_arrPlayerData[attacker][aDamage][id] += dmg;
#endif
}
}
}

public eventDeathMsg()
{
new killer = read_data(1);
new victim = read_data(2);

if(killer != victim)
{
g_arrPlayerData[killer][Frags]++;

if(read_data(3) == HIT_HEAD)
g_arrPlayerData[killer][HS]++;

new Float:delta = 1.0 / (1.0 + floatpower(10.0, (g_arrPlayerData[killer][Skill] - g_arrPlayerData[victim][Skill]) / 100.0));
g_arrPlayerData[killer][Skill] += (g_arrPlayerData[killer][Frags] < 100) ? (delta * 2.0) : (delta * 1.5);
g_arrPlayerData[victim][Skill] -= (g_arrPlayerData[victim][Frags] < 100) ? (delta * 2.0) : (delta * 1.5);
g_arrPlayerData[victim][fHpKiller] = _:entity_get_float(killer, EV_FL_health);
g_arrPlayerData[victim][fApKiller] = _:entity_get_float(killer, EV_FL_armorvalue);
g_arrPlayerData[victim][fDistance] = is_user_connected(victim) ? (_:(entity_range(killer, victim) / 32.0)) : (_:0.0);
g_arrPlayerData[victim][KillerId] = killer;
get_user_name(killer, g_arrPlayerData[victim][KillerName], charsmax(g_arrPlayerData[][KillerName]));
#if defined SendMeAndHpOnDeath
GetStats(victim, StatsMe);
GetStats(victim, StatsHp);
#endif
#if defined KillAssist
new iBestPlayer;
for(new i = 1, maxDamage = KillAssist; i <= MaxClients; i++)
{
if(g_arrPlayerData[aDamage][victim] > maxDamage)
{
maxDamage = g_arrPlayerData[aDamage][victim];
iBestPlayer = i;
}
}
if(iBestPlayer != killer && is_user_connected(iBestPlayer))
{
g_arrPlayerData[iBestPlayer][aPlayers]++;

new szNameVictim[32];
get_user_name(victim, szNameVictim, charsmax(szNameVictim));
client_print_color(
iBestPlayer,
print_team_default,
"^1[^4Stats^1] Вы помогли ^3%s ^1убить ^3%s ^1нанеся ^3%d^4dmg^1.",
g_arrPlayerData[victim][KillerName],
szNameVictim,
g_arrPlayerData[iBestPlayer][aDamage][victim]
);
}
#endif
}
g_arrPlayerData[victim][Deaths]++;
#if UpdateStatsType == 1
if(g_bMySqlConnection && !g_bResetStats)
{
UpdateStats(killer, false);
if(killer != victim)
UpdateStats(victim, false);
}
#endif
#if UpdateStatsType == 3
UpdateAllStats(0, StatsNone);
#endif
}

new g_planter, g_defuser;
public eventBombPlanted() g_arrPlayerData[g_planter][bPlanted]++;
public eventBombDefused() g_arrPlayerData[g_defuser][bDefused]++;
public eventBombTargetBombed()g_arrPlayerData[g_planter][bExploded]++;
public eventBarTimePlant(id) g_planter = id;
public eventBarTimeDefuse(id) g_defuser = id;

public SrvCMD_RemoveStats()
{
if(!g_bMySqlConnection)
{
log_amx("[Remove Stats] SQL Connection Error! Stats reset FAILED!");
return PLUGIN_HANDLED;
}
if(g_bResetStats)
{
log_amx("[Remove Stats] Stats already removed!");
return PLUGIN_HANDLED;
}

data[0] = ResetStats;
SQL_ThreadQuery(g_hSqlTuple, "SqlQueryHandler", "TRUNCATE `players_stats`", data, sizeof(data));
return PLUGIN_HANDLED;
}

public ResetDamage()
{
for(new i = 1; i <= MaxClients; i++)
{
g_arrPlayerData[Damage2] = 0;
g_arrPlayerData[KillerId] = 0;
#if defined KillAssist
arrayset(_:g_arrPlayerData[aDamage], 0, sizeof g_arrPlayerData[][aDamage]);
#endif
}
}

public UpdateAllStats(index, GetStatsStates:type)
{
if(!g_bMySqlConnection || g_bResetStats)
return;

new systime = get_systime();
if(index == 13333 && systime - g_iLastUpdate < 10)
return;

g_iLastUpdate = systime;
g_szAllPlayersUpdateQuery[0] = EOS;

new players[32], pnum;
get_players(players, pnum);
for(new i; i < pnum; i++)
UpdateStats(players, true);

data[0] = SavePlayer;
data[1] = index;
data[2] = any:type;
if(g_szAllPlayersUpdateQuery[0] == EOS)
SqlQueryHandler(TQUERY_SUCCESS, Empty_Handle, "", 0, data, sizeof(data));
else SQL_ThreadQuery(g_hSqlTuple, "SqlQueryHandler", g_szAllPlayersUpdateQuery, data, sizeof(data));
}

public clCMD_SayRank(id)
return GetStats(id, StatsRank);
public clCMD_SayRankStats(id)
return GetStats(id, StatsRankStats);
public clCMD_SayTop15(id)
return GetStats(id, StatsTop15);
public clCMD_SayMe(id)
return GetStats(id, StatsMe);
public clCMD_SayHp(id)
return GetStats(id, StatsHp);

public SqlQueryHandler(querystate, Handle:query, err[], errcode, dt[], datasize)
{
if(querystate == TQUERY_SUCCESS)
{
new id = dt[1];

switch(QueryStates:dt[0])
{
case LoadPlayer:
{
if(SQL_NumResults(query))
{
SQL_ReadResult(query, 0, g_arrPlayerData[id][Skill]);
new hArray[128]; SQL_ReadResult(query, 1, hArray, charsmax(hArray));
g_arrPlayerData[id][GameTime] = SQL_ReadResult(query, 2);

if(strlen(hArray))
{
new arr[HIT_RIGHTLEG + 1][10];
replace_string(hArray, charsmax(hArray), ":", " ");
if(parse(hArray,
arr[HIT_GENERIC], charsmax(arr[]),
arr[HIT_HEAD], charsmax(arr[]),
arr[HIT_CHEST], charsmax(arr[]),
arr[HIT_STOMACH], charsmax(arr[]),
arr[HIT_LEFTARM], charsmax(arr[]),
arr[HIT_RIGHTARM], charsmax(arr[]),
arr[HIT_LEFTLEG], charsmax(arr[]),
arr[HIT_RIGHTLEG], charsmax(arr[])
) == sizeof arr
)
{
for(new i; i < sizeof arr; i++)
g_arrPlayerData[id][hBox] = str_to_num(arr);
}
}
}
else g_arrPlayerData[id][Skill] = _:100.0;
}
case SavePlayer:
{
if(GetStatsStates:dt[2] > StatsNone)
{
switch(GetStatsStates:dt[2])
{
#if defined KillAssist
case StatsRank, StatsRankStats:
formatex(g_szQuery, charsmax(g_szQuery),
"SELECT (SELECT COUNT(*) FROM `players_stats` WHERE `skill` > (SELECT `skill` FROM `players_stats` WHERE `authid` = '%s')) AS `rank`, \
(SELECT COUNT(*) FROM `players_stats`) AS `statsnum`, `frags`, `deaths`, `hits`, `shots`, `damage`, `hs`, `skill`, `assists` FROM `players_stats` WHERE `authid` = '%s'",
g_arrPlayerData[id][AuthId], g_arrPlayerData[id][AuthId]
);
case StatsTop15:
formatex(g_szQuery, charsmax(g_szQuery), "SELECT `nick`, `frags`, `deaths`, `hs`, `shots`, `hits`, `skill`, `assists`, `gametime` FROM `players_stats` ORDER BY `skill` DESC LIMIT 15");
#else
case StatsRank, StatsRankStats:
formatex(g_szQuery, charsmax(g_szQuery),
"SELECT (SELECT COUNT(*) FROM `players_stats` WHERE `skill` > (SELECT `skill` FROM `players_stats` WHERE `authid` = '%s')) AS `rank`, \
(SELECT COUNT(*) FROM `players_stats`) AS `statsnum`, `frags`, `deaths`, `hits`, `shots`, `damage`, `hs`, `skill` FROM `players_stats` WHERE `authid` = '%s'",
g_arrPlayerData[id][AuthId], g_arrPlayerData[id][AuthId]
);
case StatsTop15:
formatex(g_szQuery, charsmax(g_szQuery), "SELECT `nick`, `frags`, `deaths`, `hs`, `shots`, `hits`, `skill`, `gametime` FROM `players_stats` ORDER BY `skill` DESC LIMIT 15");
#endif
}
data[0] = any:dt[2];
data[1] = id;
SQL_ThreadQuery(g_hSqlTuple, "SqlQueryHandler", g_szQuery, data, sizeof(data));
}
}
case ResetStats:
{
log_amx("[Reset Stats] Stats successfully reset!");
log_amx("[Reset Stats] Restart Map...");

g_bResetStats = true;
server_cmd("restart");
}
case RemoveLols:
{
new prun = SQL_AffectedRows(query);
if(prun)
log_amx("[Pruned Players] Removed %d players!", prun);
}
/*
Тут типа начинаются выводы инфы... :D
*/
case StatsRank:
{
if(!SQL_NumResults(query))
client_print_color(id, 0, "^1[^4Stats^1] Нет данных из MySQL.");
else
{
new iFrags = SQL_ReadResult(query, 2);
new iDeaths = SQL_ReadResult(query, 3);
//new iHits = SQL_ReadResult(query, 4);
new Float:fSkill; SQL_ReadResult(query, 8, fSkill);
// spec symbol '%'
#if defined KillAssist
client_print_color(id, 0, "^1[^4Stats^1] Вы занимаете ^3%d-е ^1место из ^3%d^1, убив ^3%d^1, смертей ^3%d ^1 [^4Эфф ^3%.2f%^1|^4Скилл ^3%s ^1(%.1f)^1|^4Ассистов ^3%d^1]",
SQL_ReadResult(query, 0) + 1, SQL_ReadResult(query, 1), iFrags, iDeaths, effec(iFrags, iDeaths), g_arrViewRankSkills[get_skill(fSkill)], fSkill, SQL_ReadResult(query, 9));
#else
client_print_color(id, 0, "^1[^4Stats^1] Вы занимаете ^3%d-е ^1место из ^3%d^1, убив ^3%d, смертей ^3%d^1, ^1 [^4Эфф ^3%.2f%^1|^4Скилл ^3%s ^1(%.1f)]",
SQL_ReadResult(query, 0) + 1, SQL_ReadResult(query, 1), iFrags, iDeaths, effec(iFrags, iDeaths), g_arrViewRankSkills[get_skill(fSkill)], fSkill);
#endif
}
}
case StatsRankStats:
{
if(!SQL_NumResults(query))
client_print_color(id, 0, "^1[^4Stats^1] Нет данных из MySQL.");
else
{
new iFrags = SQL_ReadResult(query, 2);
new iDeaths = SQL_ReadResult(query, 3);
new iHits = SQL_ReadResult(query, 4);
new iShots = SQL_ReadResult(query, 5);
new iHS = SQL_ReadResult(query, 7);
new Float:fSkill; SQL_ReadResult(query, 8, fSkill);

new buff[1535], len;
len += formatex(buff[len], charsmax(buff) - len, "<META http-equiv=Content-Type content='text/html;charset=UTF-8'><link href='http://neix.ru/aes/aes_v.css' rel=stylesheet type=text/css>");
len += formatex(buff[len], charsmax(buff) - len, "<p>Oбщaя cтaтистикa игpoкa</p><table cellpadding=0><tr><td valign=top width=50%%><table cellspacing=0><tr><th colspan=2> Вы нa %d-oм мecтe из %d", SQL_ReadResult(query, 0) + 1, SQL_ReadResult(query, 1));
#if defined KillAssist
len += formatex(buff[len], charsmax(buff) - len, "<tr><td>Убито<td>%d (в гoлoву: %d)<tr><td>Ассистов<td>%d<tr><td>Cмepтeй<td>%d<tr><td>Пoпaдaний<td>%d<tr><td>Bыcтpeлoв<td>%d<tr><td>Уpoн<td>%d<tr><td>Toчнocть<td>%0.2f%%<tr><td>Эффeктивнocть<td>%0.2f%%<tr><td>Cкилл<td><div id='%s'>%.0f</div></table>",
iFrags, iHS, SQL_ReadResult(query, 9), iDeaths, iHits, iShots, SQL_ReadResult(query, 6), accuracy(iHits, iShots), effec(iFrags, iDeaths), g_arrViewSkills[get_skill(fSkill)], fSkill);
#else
len += formatex(buff[len], charsmax(buff) - len, "<tr><td>Убито<td>%d (в гoлoву: %d)<tr><td>Cмepтeй<td>%d<tr><td>Пoпaдaний<td>%d<tr><td>Bыcтpeлoв<td>%d<tr><td>Уpoн<td>%d<tr><td>Toчнocть<td>%0.2f%%<tr><td>Эффeктивнocть<td>%0.2f%%<tr><td>Cкилл<td><div id='%s'>%.0f</div></table>",
iFrags, iHS, iDeaths, iHits, iShots, SQL_ReadResult(query, 6), accuracy(iHits, iShots), effec(iFrags, iDeaths), g_arrViewSkills[get_skill(fSkill)], fSkill);
#endif
len += formatex(buff[len], charsmax(buff) - len, "<td valign=top width=50%%><table cellspacing=0><tr><th colspan=2>Cтaтиcтикa пoпaдaний");

for(new i; i < sizeof g_arrBodyParts; i++)
len += formatex(buff[len], charsmax(buff) - len, "<tr><td>%s<td>%d", g_arrBodyParts, g_arrPlayerData[id][hBox]);

formatex(buff[len], charsmax(buff) - len, "<tr><td height=15px><td></table>");
show_motd(id, buff, "Your stats");
}
}
case StatsTop15:
{
if(!SQL_NumResults(query))
client_print_color(id, 0, "^1[^4Stats^1] Нет данных из MySQL.");
else
{

new buff[1535], len, i, name[32], iFrags, iDeaths, iGameTime;
new OldLen, bool:IsCut;
len += formatex(buff[len], charsmax(buff) - len, "<META http-equiv=Content-Type content='text/html;charset=UTF-8'><link href='http://neix.ru/aes/aes_v.css' rel=stylesheet type=text/css>");
#if defined KillAssist
len += formatex(buff[len], charsmax(buff) - len, "<table><tr><th>#<th>Ник<th>Убийств<th>В голову<th>Смертей<th>Ассистов<th>Скилл<th>Время в игре</tr>");
#else
len += formatex(buff[len], charsmax(buff) - len, "<table><tr><th>#<th>Ник<th>Убийств<th>В голову<th>Смертей<th>Скилл<th>Время в игре</tr>");
#endif
while(SQL_MoreResults(query))
{
SQL_ReadResult(query, 0, name, charsmax(name));

replace_string(name, charsmax(name), "<", "[");
replace_string(name, charsmax(name), ">", "]");

iFrags = SQL_ReadResult(query, 1);
iDeaths = SQL_ReadResult(query, 2);
iGameTime = SQL_ReadResult(query, 8);
//iShots = SQL_ReadResult(query, 4);
new iHS = SQL_ReadResult(query, 3);
//iHits = SQL_ReadResult(query, 5);
new Float:fSkill; SQL_ReadResult(query, 6, fSkill);
new iDay = (iGameTime / 86400);
new iHour = (iGameTime / 3600);
new iMin = ((iGameTime % 3600) / 60);

OldLen = len;
#if defined KillAssist
len += formatex(buff[len], charsmax(buff) - len, "<tr><td>%d<td>%s<td>%d<td>%d<td>%d<td>%d<td><div id='%s'>%.0f</div><td>%02dд.&nbsp%02dч.%02dм.</tr>", ++i, name,
iFrags, iHS, iDeaths, SQL_ReadResult(query, 7), g_arrViewSkills[get_skill(fSkill)], fSkill, iDay, iHour, iMin);
#else
len += formatex(buff[len], charsmax(buff) - len, "<tr><td>%d<td>%s<td>%d<td>%d<td>%d<td><div id='%s'>%.0f</div><td>%02dд.&nbsp%02dч.%02dм.</tr>", ++i, name,
iFrags, iHS, iDeaths, g_arrViewSkills[get_skill(fSkill)], fSkill, iDay, iHour, iMin);
#endif
if(len + 9 >= charsmax(buff))
{
buff[OldLen] = 0;
IsCut = true;
break;
}
else SQL_NextRow(query);
}
formatex(buff[IsCut ? OldLen : len], charsmax(buff), "</table>");
show_motd(id, buff, "Top players");
}
}
}
}
else log_to_file("ps.log", "[State #%d] Error [#%d] %s", dt[0], errcode, err);
}

public CheckMySQLConnection()
{
static ErrNum;
new errcode, errstr[128];
if(SQL_Connect(g_hSqlTuple, errcode, errstr, charsmax(errstr)) == Empty_Handle)
{
if(++ErrNum == 3)
{
new error[190];
formatex(error, charsmax(error), "SQL Connection ERROR [#%d] %s", errcode, errstr);
set_fail_state(error);
}
else
{
g_bMySqlConnection = false;
set_task(3.0, "CheckMySQLConnection");
}
}
else
{
g_bMySqlConnection = true;

data[0] = RemoveLols;
formatex(
g_szQuery, charsmax(g_szQuery),
"DELETE FROM `players_stats` WHERE `last_connection` < (UNIX_TIMESTAMP(NOW()) - %d)",
(PrunedDays * 86400)
);
SQL_ThreadQuery(g_hSqlTuple, "SqlQueryHandler", g_szQuery, data, sizeof(data));

if(ErrNum)
{
new players[32], pnum;
get_players(players, pnum);
for(new i; i < pnum; i++)
if(!g_arrPlayerData[players][AuthId][0])
client_putinserver(players);
}
}
}
/* Natives */
public native_ps_remove_player(param[25])
{
if(!param[0])
return 0;

new errcode, errstr[128];
new Handle:QueryHandle = SQL_Connect(g_hSqlTuple, errcode, errstr, charsmax(errstr));
if(QueryHandle != Empty_Handle)
{
new id = get_id_by_auth(param);
if(id) arrayset(g_arrPlayerData[id], 0, PlayerData);

SQL_PrepareQuery(QueryHandle, "DELETE FROM `players_stats` WHERE `authid` = '%s'", param);
if(SQL_Execute(QueryHandle))
{ SQL_FreeHandle(QueryHandle); return 1; }
else { SQL_FreeHandle(QueryHandle); return 0; }
}
return 0;
}

public native_ps_setinfo_player(param[], SetParams:setparam, value)
{
if(!param[0] || setparam < FRAGS || value < 0)
return 0;

new errcode, errstr[128];
new Handle:QueryHandle = SQL_Connect(g_hSqlTuple, errcode, errstr, charsmax(errstr));
if(QueryHandle != Empty_Handle)
{
new row[10] = "";
switch(setparam)
{
case FRAGS: row = "frags";
case DEATHS:row = "deaths";
case HSs: row = "hs";
case DMG: row = "damage";
case SHOTS: row = "shots";
case HITS: row = "hits";
case BOMB_PLANTED: row = "bplanted";
case BOMB_DEFUSED: row = "bdefused";
case BOMB_EXPLODED:row = "bexploded";
case SKILL: row = "skill";
case GAME_TIME: row = "gametime";
}
SQL_PrepareQuery(QueryHandle, "UPDATE `players_stats` SET `%s` = '%d' WHERE `authid` = '%s'", row, value, param);
if(SQL_Execute(QueryHandle))
{ SQL_FreeHandle(QueryHandle); return 1; }
else { SQL_FreeHandle(QueryHandle); return 0; }
}
return 0;
}

public native_ps_get_player_damage(id, bool:bCheckConnect)
{
if(bCheckConnect && !is_user_connected(id))
return -1;
return g_arrPlayerData[id][Damage2];
}

public native_ps_get_player_gametime(id, bool:bCheckConnect)
{
if(bCheckConnect && !is_user_connected(id))
return -1;
return g_arrPlayerData[id][GameTime];
}
/* End Natives */

UpdateStats(id, bool:allupdate)
{
if(!g_arrPlayerData[id][Frags] && !g_arrPlayerData[id][Deaths] && allupdate)
return;

new name[64];
get_user_name(id, name, charsmax(name));
mysql_escape_string(name, charsmax(name));

new hArray[128];
for(new i = 1, len = formatex(hArray, charsmax(hArray), "%d", g_arrPlayerData[id][hBox][0]); i < sizeof g_arrPlayerData[][hBox]; i++)
len += formatex(hArray[len], charsmax(hArray) - len, ":%d", g_arrPlayerData[id][hBox]);
#if defined KillAssist
formatex(g_szQuery, charsmax(g_szQuery),
"INSERT INTO `players_stats` \
(`nick`, `authid`, `frags`, `assists`, `deaths`, `hs`, `damage`, `shots`, `hits`, `bplanted`, `bdefused`, `bexploded`, `skill`, `gametime`, `harray`, `last_connection`) \
VALUES ('%s', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%f', '%d', '%s', UNIX_TIMESTAMP(NOW())) \
ON DUPLICATE KEY UPDATE `nick` = '%s', `frags` = `frags` + '%d', `assists` = `assists` + '%d', `deaths` = `deaths` + '%d', `hs` = `hs` + '%d', \
`damage` = `damage` + '%d', `shots` = `shots` + '%d', `hits` = `hits` + '%d', \
`bplanted` = `bplanted` + '%d', `bdefused` = `bdefused` + '%d', `bexploded` = `bexploded` + '%d', \
`skill` = '%f', `gametime` = '%d', `harray` = '%s', `last_connection` = UNIX_TIMESTAMP(NOW()); ",
name, g_arrPlayerData[id][AuthId],
g_arrPlayerData[id][Frags],
g_arrPlayerData[id][aPlayers],
g_arrPlayerData[id][Deaths],
g_arrPlayerData[id][HS],
g_arrPlayerData[id][Damage],
g_arrPlayerData[id][Shots],
g_arrPlayerData[id][Hits],
g_arrPlayerData[id][bPlanted],
g_arrPlayerData[id][bDefused],
g_arrPlayerData[id][bExploded],
g_arrPlayerData[id][Skill],
g_arrPlayerData[id][GameTime],
hArray,
name,
g_arrPlayerData[id][Frags],
g_arrPlayerData[id][aPlayers],
g_arrPlayerData[id][Deaths],
g_arrPlayerData[id][HS],
g_arrPlayerData[id][Damage],
g_arrPlayerData[id][Shots],
g_arrPlayerData[id][Hits],
g_arrPlayerData[id][bPlanted],
g_arrPlayerData[id][bDefused],
g_arrPlayerData[id][bExploded],
g_arrPlayerData[id][Skill],
g_arrPlayerData[id][GameTime],
hArray
);
#else
formatex(g_szQuery, charsmax(g_szQuery),
"INSERT INTO `players_stats` \
(`nick`, `authid`, `frags`, `deaths`, `hs`, `damage`, `shots`, `hits`, `bplanted`, `bdefused`, `bexploded`, `skill`, `gametime`, `harray`, `last_connection`) \
VALUES ('%s', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%f', '%d', '%s', UNIX_TIMESTAMP(NOW())) \
ON DUPLICATE KEY UPDATE `nick` = '%s', `frags` = `frags` + '%d', `deaths` = `deaths` + '%d', `hs` = `hs` + '%d', \
`damage` = `damage` + '%d', `shots` = `shots` + '%d', `hits` = `hits` + '%d', \
`bplanted` = `bplanted` + '%d', `bdefused` = `bdefused` + '%d', `bexploded` = `bexploded` + '%d', \
`skill` = '%f', `gametime` = '%d', `harray` = '%s', `last_connection` = UNIX_TIMESTAMP(NOW()); ",
name, g_arrPlayerData[id][AuthId],
g_arrPlayerData[id][Frags],
g_arrPlayerData[id][Deaths],
g_arrPlayerData[id][HS],
g_arrPlayerData[id][Damage],
g_arrPlayerData[id][Shots],
g_arrPlayerData[id][Hits],
g_arrPlayerData[id][bPlanted],
g_arrPlayerData[id][bDefused],
g_arrPlayerData[id][bExploded],
g_arrPlayerData[id][Skill],
g_arrPlayerData[id][GameTime],
hArray,
name,
g_arrPlayerData[id][Frags],
g_arrPlayerData[id][Deaths],
g_arrPlayerData[id][HS],
g_arrPlayerData[id][Damage],
g_arrPlayerData[id][Shots],
g_arrPlayerData[id][Hits],
g_arrPlayerData[id][bPlanted],
g_arrPlayerData[id][bDefused],
g_arrPlayerData[id][bExploded],
g_arrPlayerData[id][Skill],
g_arrPlayerData[id][GameTime],
hArray
);
#endif
arrayset(g_arrPlayerData[id], 0, CLEAR_DATA);

if(allupdate)
add(g_szAllPlayersUpdateQuery, charsmax(g_szAllPlayersUpdateQuery), g_szQuery);
else
{
data[0] = SavePlayer;
data[1] = id;
data[2] = any:StatsNone;
SQL_ThreadQuery(g_hSqlTuple, "SqlQueryHandler", g_szQuery, data, sizeof(data));
}
}

GetStats(id, GetStatsStates:type)
{
switch(type)
{
case StatsMe:
{
switch(g_arrPlayerData[id][Damage2])
{
case 0: client_print_color(id, 0, "^1[^4SayMe^1] ^1Вы ни в кого ^3не ^1попали.");
default:client_print_color(id, 0, "^1[^4SayMe^1] ^1Вы нанесли ^3%d ^1урона. Последнее попадание в ^3%s^1.", g_arrPlayerData[id][Damage2], g_arrBodyParts[g_arrPlayerData[id][LastHit]][2]);
}
}
case StatsHp:
{
switch(g_arrPlayerData[id][KillerId])
{
case 0: client_print_color(id, 0, "^1[^4SayHp^1] ^1Вас ^3никто ^1не убивал.");
default:client_print_color(id, g_arrPlayerData[id][KillerId], "^1[^4SayHp^1] ^1Вас убил ^3%s ^1с расстояния ^3%.0f ^1метров. У него осталось ^3%.0f^4HP ^1и ^3%.0f^4AP", g_arrPlayerData[id][KillerName], g_arrPlayerData[id][fDistance], g_arrPlayerData[id][fHpKiller], g_arrPlayerData[id][fApKiller]);
}
}
default:
{
new systime = get_systime();
if(systime - g_arrPlayerData[id][LastGetStats] < AntiFloodSecs)
{
client_print_color(id, 0,
"^1[^4Stats^1] Воу-воу, палехчи! Не флуди! Команда будет доступна через ^3%d ^1сек",
g_arrPlayerData[id][LastGetStats] + AntiFloodSecs - systime
);
}
else
{
g_arrPlayerData[id][LastGetStats] = systime;
#if UpdateStatsType == 2
UpdateAllStats(id, type);
#else
data[0] = SavePlayer;
data[1] = index;
data[2] = any:type;
SqlQueryHandler(TQUERY_SUCCESS, Empty_Handle, "", 0, data, sizeof(data));
#endif
}
}
}
return PLUGIN_HANDLED;
}

stock get_id_by_auth(auth[])
{
new players[32], pnum;
get_players(players, pnum, "ch");
for(new i; i < pnum; i++)
if(strcmp(g_arrPlayerData[players][AuthId], auth) == 0)
return players;
return 0;
}

stock get_skill(Float:skill)
{
for(new i, sk = floatround(skill); i < sizeof g_arrViewSkills; i++)
{
if(i && g_arrItemSkills > sk)
return i - 1;
else if((!i && g_arrItemSkills > sk) || i == charsmax(g_arrViewSkills))
return i;
}
return 0;
}

stock Float:effec(kills, deaths)
return !kills ? (0.0) : (100.0 * float(kills) / float(kills + deaths));

stock Float:accuracy(hits, shots)
return !shots ? (0.0) : (100.0 * float(hits) / float(shots));

stock mysql_escape_string(output[], len)
{
static const szReplaceIn[][] = { "\\", "\0", "\n", "\r", "\x1a", "'", "^"" };
static const szReplaceOut[][] = { "\\\\", "\\0", "\\n", "\\r", "\Z", "\'", "\^"" };
for(new i; i < sizeof szReplaceIn; i++)
replace_string(output, len, szReplaceIn, szReplaceOut);
}


Комментарий:
Может кто чем помочь. Я вообще понять не могу в чем дело. Может потому что добавил в условие
Код:
UpdateStats(id, bool:allupdate)
{
if(!g_arrPlayerData[id][Frags] && !g_arrPlayerData[id][Deaths] && allupdate)
return;

&& allupdate?
 

Вложения

Сообщения
2,491
Реакции
2,794
Помог
61 раз(а)
Сделайте запрос напрямую в базе
Код:
SELECT COUNT(*) FROM players_stats WHERE authid = 'тут стим ид игрока у кого замечена смена ника';

После этого сделайте такой запрос
Код:
SHOW INDEX FROM players_stats;

Результаты напишите сюда
 
Сообщения
58
Реакции
12
Помог
1 раз(а)
fantom,
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
players_stats0PRIMARY1idA1104NULLNULL BTREE
players_stats0authid1authidA1104NULLNULL BTREE
[TBODY] [/TBODY]
[TBODY] [/TBODY]
 
Сообщения
2,491
Реакции
2,794
Помог
61 раз(а)
Все ок. тогда скорее всего повлияли ваши изменения
 
Сообщения
58
Реакции
12
Помог
1 раз(а)
Если убрать эту запись && allupdate из условия, время проведенное в игре обновляется через раз.
29 Ноя 2017
Удалил && allupdate из условия. Ники теперь не меняются на рандомные, только игровое время не всегда записывавется. Палка о двух концах ((
 
Статус
В этой теме нельзя размещать новые ответы.

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

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