- Ошибка
-
//// csx_easy_stats.sma
//
// G:\1.9.0_5263_scripting\csx_easy_stats.sma(105) : error 047: array sizes do not match, or destination array is too small
// G:\1.9.0_5263_scripting\csx_easy_stats.sma(182) : error 047: array sizes do not match, or destination array is too small
// G:\1.9.0_5263_scripting\csx_easy_stats.sma(194) : error 047: array sizes do not match, or destination array is too small
// G:\1.9.0_5263_scripting\csx_easy_stats.sma(212) : error 047: array sizes do not match, or destination array is too small
// G:\1.9.0_5263_scripting\csx_easy_stats.sma(213) : error 047: array sizes do not match, or destination array is too small
// G:\1.9.0_5263_scripting\csx_easy_stats.sma(267) : error 047: array sizes do not match, or destination array is too small
// G:\1.9.0_5263_scripting\csx_easy_stats.sma(318) : error 047: array sizes do not match, or destination array is too small
// G:\1.9.0_5263_scripting\csx_easy_stats.sma(333) : error 047: array sizes do not match, or destination array is too small
// G:\1.9.0_5263_scripting\csx_easy_stats.sma(348) : error 047: array sizes do not match, or destination array is too small
// G:\1.9.0_5263_scripting\csx_easy_stats.sma(364) : error 047: array sizes do not match, or destination array is too small
// G:\1.9.0_5263_scripting\csx_easy_stats.sma(379) : error 047: array sizes do not match, or destination array is too small
// G:\1.9.0_5263_scripting\csx_easy_stats.sma(454) : error 047: array sizes do not match, or destination array is too small
// G:\1.9.0_5263_scripting\csx_easy_stats.sma(489) : error 047: array sizes do not match, or destination array is too small
// G:\1.9.0_5263_scripting\csx_easy_stats.sma(512) : error 047: array sizes do not match, or destination array is too small
//
// 14 Errors.
// Could not locate output file compiled\csx_easy_stats.amx (compile failed).
//
// Compilation Time: 0,5 sec
// ----------------------------------------
- Компилятор
- Локальный
- Amx Mod X
- 1.9.0
- Исходный код
-
native get_statsnum_sql()
native get_user_stats_sql(index, stats[8], bodyhits[8])
native get_stats_sql(index, stats[8], bodyhits[8], name[], len, authid[] = "", authidlen = 0)
#include <amxmodx>
#include <csx>
#if AMXX_VERSION_NUM < 183
#include <colorchat>
#endif
#define CSS_STYLE "http://neygomon.ru/stats.css"// ссылка на шаблон
#define SORTING_BY_DMG_TOP // показывать топ 10 игроков по урону за раунд
#define PRUNE_OLD_CONNECTION_PLRS 10 // если игрок не появлялся на сервере N дней - удалить из статистики. Так же удаляются игроки без смертей и фрагов
const MinDamageForAssist = 50; // минимальный урон для получения ассиста
const MaxUsersInTopByDmg = 10; // количество игроков в топе SORTING_BY_DMG_TOP
#define FRAGS 0
#define DEATHS 1
#define HS 2
#define TK 3
#define SHOTS 4
#define HITS 5
#define DAMAGE 6
#define RANK 7
#define ASSIST HIT_RIGHTLEG + 1
#define SKILL ASSIST + 1
#define GAMETIME SKILL + 1
#define LASTCON GAMETIME + 1
#define ARRSIZE_STATS RANK + 1
#define ARRSIZE_BODY LASTCON + 1
#define MAX_TOP_POS 15
#if defined SORTING_BY_DMG_TOP
#tryinclude <reapi>
enum player_damage { p_index = 0, p_damage };
#endif
enum _:SayMeData
{
HpKiller,
ApKiller,
Distance,
KillerId,
KillerName[MAX_NAME_LENGTH]
};
enum GetStatsFunctions
{
StatsRank,
StatsRankStats,
StatsTopX,
StatsMe,
StatsHp,
StatsRs
};
new const g_arrViewSkills[][] =
{
"L-", "LS", "L+", "M-", "MS", "M+", "H-", "HS", "H+", "P-", "PS", "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гу"
};
new const g_arrBodyMeParts[HIT_RIGHTLEG + 1][] =
{
"Тушка", "Башня", "Сиськи", "Брюхо", "Л. клешня", "П. клешня", "Л. костыль", "П. костыль"
};
new g_arrMeData[MAX_PLAYERS + 1][SayMeData];
public plugin_natives()
{
register_native("csx_get_user_rank", "native_csx_get_user_rank", false);
register_native("csx_get_user_assist", "native_csx_get_user_assist", false);
register_native("csx_get_user_skill", "native_csx_get_user_skill", false);
register_native("csx_get_user_gametime", "native_csx_get_user_gametime", false);
register_native("csx_get_user_last_connection", "native_csx_get_user_last_conn", false);
}
public plugin_init()
{
// 1.6: Add plugin API
// 1.7: Add topX
register_plugin("CSX Easy Stats", "1.7", "neugomon");
register_clcmd("say", "clcmd_Say");
register_clcmd("say_team", "clcmd_Say");
#if defined SORTING_BY_DMG_TOP
#if defined _reapi_included
RegisterHookChain(RG_RoundEnd, "RoundEnd_Post", true);
#else
register_logevent("RoundEnd_Post", 2, "1=Round_End");
#endif
#endif
#if defined PRUNE_OLD_CONNECTION_PLRS
new rank, removed, st[ARRSIZE_STATS], bh[ARRSIZE_BODY];
new minTime = get_systime() - PRUNE_OLD_CONNECTION_PLRS * 86400;
while((rank = get_stats_sql(rank, st, bh, "", 0)))
{
if(bh[LASTCON] < minTime || (!st[FRAGS] && !st[DEATHS]))
{
if(remove_stats(rank-1))
removed++;
}
}
if(removed)
{
log_amx("Pruned %i players of csstats.dat", removed);
ForceSaveStats();
}
#endif
register_event("HLTV", "eventHLTV", "a", "1=0", "2=0");
set_task(60.0, "ForceSaveStats", .flags = "b");
}
public ForceSaveStats()
force_save_stats();
#if defined SORTING_BY_DMG_TOP
public RoundEnd_Post()
set_task(0.3, "ShowTopDamage");
public ShowTopDamage()
{
new arrPlayers[MAX_PLAYERS + 1][player_damage];
new players[MAX_PLAYERS], pnum;
get_players(players, pnum);
for(new i, st[ARRSIZE_STATS], bh[ARRSIZE_BODY]; i < pnum; ++i)
{
if(get_user_wrstats(players[i], 0, st, bh))
{
arrPlayers[i][p_index] = players[i];
arrPlayers[i][p_damage] = st[DAMAGE];
}
}
SortCustom2D(arrPlayers, sizeof(arrPlayers), "SortDamage");
new bool:bAllowShow,
szPlayers[512],
len = formatex(szPlayers, charsmax(szPlayers), "\d[\rTOP 10\d] Топ по урону за раунд^n^n"),
iMaxNum = (MaxUsersInTopByDmg > pnum) ? pnum : MaxUsersInTopByDmg;
for(new i, name[MAX_NAME_LENGTH]; i < iMaxNum; ++i)
{
if(arrPlayers[i][p_damage])
{
get_user_name(arrPlayers[i][p_index], name, charsmax(name));
len += formatex(szPlayers[len], charsmax(szPlayers) - len, "\r%d \w- \d[%d] \w - \y%s^n", i+1, arrPlayers[i][p_damage], name);
bAllowShow = true;
}
}
if(bAllowShow)
{
for(new i, m, nm; i < pnum; ++i)
if(!player_menu_info(players[i], m, nm))
show_menu(players[i], MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9, szPlayers, 5);
}
}
public SortDamage(const elem1[], const elem2[])
return (elem1[p_damage] < elem2[p_damage]) ? 1 : (elem1[p_damage] > elem2[p_damage]) ? -1 : 0;
#endif
public eventHLTV()
{
for(new i = 1; i <= MaxClients; ++i)
arrayset(g_arrMeData[i], 0, SayMeData);
}
public client_putinserver(id)
{
new st[ARRSIZE_STATS], bh[ARRSIZE_BODY];
get_user_stats_sql(id, st, bh);
if(!bh[SKILL]) bh[SKILL] = 100;
set_user_stats(id, st, bh);
arrayset(g_arrMeData[id], 0, SayMeData);
}
public client_disconnected(id)
{
if(is_user_connected(id))
{
new st[ARRSIZE_STATS], bh[ARRSIZE_BODY];
if(get_user_stats_sql(id, st, bh))
{
bh[GAMETIME] += get_user_time(id, true);
bh[LASTCON] = get_systime();
set_user_stats(id, st, bh);
}
}
}
public client_death(killer, victim, wpnindex, hitplace, tk)
{
if(!killer || killer == victim)
return;
static Float:delta;
static st[ARRSIZE_STATS], bh[ARRSIZE_BODY];
static st2[ARRSIZE_STATS], bh2[ARRSIZE_BODY];
get_user_stats_sql(killer, st, bh);
get_user_stats_sql(victim, st2, bh2);
delta = 1.0 / (1.0 + floatpower(10.0, (bh[SKILL] - bh2[SKILL]) / 100.0));
bh[SKILL] += (st[FRAGS] < 100) ? floatround(delta * 2.0) : floatround(delta * 1.5);
bh2[SKILL] -= (st2[FRAGS] < 100) ? floatround(delta * 2.0) : floatround(delta * 1.5);
set_user_stats(killer, st, bh);
set_user_stats(victim, st2, bh2);
/* #### */
static fOriginK[3], fOriginV[3];
get_user_origin(killer, fOriginK);
get_user_origin(victim, fOriginV);
g_arrMeData[victim][HpKiller] = get_user_health(killer);
g_arrMeData[victim][ApKiller] = get_user_armor(killer);
g_arrMeData[victim][Distance] = floatround(get_distance(fOriginK, fOriginV) * 0.0254);
g_arrMeData[victim][KillerId] = killer;
get_user_name(killer, g_arrMeData[victim][KillerName], charsmax(g_arrMeData[][KillerName]));
GetStats(victim, StatsMe);
GetStats(victim, StatsHp);
/* #### */
new iBestPlayer, maxDamage = MinDamageForAssist;
for(new i = 1, st[ARRSIZE_STATS], bh[ARRSIZE_BODY]; i <= MaxClients; ++i)
{
if(i == killer) continue;
if(!is_user_connected(i)) continue;
#if defined _reapi_included
if(!(TEAM_TERRORIST <= get_member(i, m_iTeam) <= TEAM_CT)) continue;
#else
if(!(1 <= get_user_team(i) <= 2)) continue;
#endif
if(get_user_vstats(i, victim, st, bh))
{
if(st[DAMAGE] > maxDamage)
{
maxDamage = st[DAMAGE];
iBestPlayer = i;
}
}
}
if(iBestPlayer != killer && is_user_connected(iBestPlayer))
{
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_arrMeData[victim][KillerName],
szNameVictim,
maxDamage
);
get_user_stats_sql(iBestPlayer, st, bh);
bh[ASSIST]++;
set_user_stats(iBestPlayer, st, bh);
}
}
public clcmd_Say(id)
{
new szMessage[64];
read_args(szMessage, charsmax(szMessage));
remove_quotes(szMessage);
if(szMessage[0] != '/')
return PLUGIN_CONTINUE;
else
{
if(strcmp(szMessage, "/rank") == 0)
return GetStats(id, StatsRank);
if(strcmp(szMessage, "/rankstats") == 0)
return GetStats(id, StatsRankStats);
if(strcmp(szMessage, "/me") == 0)
return GetStats(id, StatsMe);
if(strcmp(szMessage, "/hp") == 0)
return GetStats(id, StatsHp);
if(strcmp(szMessage, "/rs") == 0)
return GetStats(id, StatsRs);
if(equal(szMessage, "/top", 4))
{
new szGetPos[11];
copy(szGetPos, charsmax(szGetPos), szMessage[4]);
return GetStats(id, StatsTopX, str_to_num(szGetPos));
}
client_print(id, print_chat, "-> %s", szMessage);
}
return PLUGIN_CONTINUE;
}
public native_csx_get_user_rank(plugin, params)
{
enum { index = 1 };
new id = get_param(index);
if(!is_user_connected(id))
{
log_error(AMX_ERR_NATIVE, "Client %d not connected or index out of range!", id);
return 0;
}
new st[ARRSIZE_STATS], bh[ARRSIZE_BODY];
return get_user_stats_sql(id, st, bh);
}
public native_csx_get_user_assist(plugin, params)
{
enum { index = 1 };
new id = get_param(index);
if(!is_user_connected(id))
{
log_error(AMX_ERR_NATIVE, "Client %d not connected or index out of range!", id);
return 0;
}
new st[ARRSIZE_STATS], bh[ARRSIZE_BODY];
return get_user_stats_sql(id, st, bh) ? bh[ASSIST] : 0;
}
public native_csx_get_user_skill(plugin, params)
{
enum { index = 1 };
new id = get_param(index);
if(!is_user_connected(id))
{
log_error(AMX_ERR_NATIVE, "Client %d not connected or index out of range!", id);
return 0;
}
new st[ARRSIZE_STATS], bh[ARRSIZE_BODY];
return get_user_stats_sql(id, st, bh) ? bh[SKILL] : 0;
}
public native_csx_get_user_gametime(plugin, params)
{
enum { index = 1 };
new id = get_param(index);
if(!is_user_connected(id))
{
log_error(AMX_ERR_NATIVE, "Client %d not connected or index out of range!", id);
return 0;
}
new st[ARRSIZE_STATS], bh[ARRSIZE_BODY];
return get_user_stats_sql(id, st, bh) ? bh[GAMETIME] : 0;
}
public native_csx_get_user_last_conn(plugin, params)
{
enum { index = 1 };
new id = get_param(index);
if(!is_user_connected(id))
{
log_error(AMX_ERR_NATIVE, "Client %d not connected or index out of range!", id);
return 0;
}
new st[ARRSIZE_STATS], bh[ARRSIZE_BODY];
return get_user_stats_sql(id, st, bh) ? bh[LASTCON] : 0;
}
GetStats(id, GetStatsFunctions:type, place = 0)
{
if(!is_user_connected(id))
return PLUGIN_HANDLED;
switch(type)
{
case StatsMe:
{
new st[ARRSIZE_STATS], bh[ARRSIZE_BODY];
if(get_user_rstats(id, st, bh) && st[DAMAGE])
{
new szFormat[190], len = formatex(szFormat, charsmax(szFormat), "^1[^4SayMe^1] ^1Вы нанесли ^3%d ^1урона ^4>> ", st[DAMAGE]);
for(new i; i < sizeof g_arrBodyMeParts; ++i)
{
if(bh[i])
{
len += formatex(szFormat[len], charsmax(szFormat) - len, "^3%s^1: ^4%d^1, ", g_arrBodyMeParts[i], bh[i]);
}
}
szFormat[strlen(szFormat) - 2] = EOS;
client_print_color(id, print_team_default, szFormat);
}
else client_print_color(id, print_team_default, "^1[^4SayMe^1] ^1Вы ни в кого ^3не ^1попали!");
}
case StatsHp:
{
if(g_arrMeData[id][KillerId])
{
new st[ARRSIZE_STATS], bh[ARRSIZE_BODY];
if(get_user_vstats(g_arrMeData[id][KillerId], id, st, bh))
{
new szFormat[190], len = formatex(szFormat, charsmax(szFormat), "^1[^4SayHp^1] ^1Вас убил ^3%s ^1[^3%d^4HP^1/^3%d^4AP^1] с ^3%d ^1метров ^4>> ", g_arrMeData[id][KillerName], g_arrMeData[id][HpKiller], g_arrMeData[id][ApKiller], g_arrMeData[id][Distance]);
for(new i; i < sizeof g_arrBodyMeParts; ++i)
{
if(bh[i])
{
len += formatex(szFormat[len], charsmax(szFormat) - len, "^3%s^1: ^4%d^1, ", g_arrBodyMeParts[i], bh[i]);
}
}
szFormat[strlen(szFormat) - 2] = EOS;
client_print_color(id, print_team_default, szFormat);
}
else client_print_color(id, g_arrMeData[id][KillerId], "^1[^4SayHp^1] ^1Вас убил ^3%s ^1с расстояния ^3%d ^1метров. У него осталось ^3%d^4HP ^1и ^3%d^4AP", g_arrMeData[id][KillerName], g_arrMeData[id][Distance], g_arrMeData[id][HpKiller], g_arrMeData[id][ApKiller]);
}
else client_print_color(id, print_team_default, "^1[^4SayHp^1] ^1Вас ^3никто ^1не убивал!");
}
case StatsTopX:
{
new statsNum = get_statsnum_sql();
if(place < MAX_TOP_POS) place = MAX_TOP_POS;
if(!statsNum)
client_print_color(id, print_team_default, "^1[^4Stats^1] Нет данных!");
else if(place != MAX_TOP_POS && place > statsNum)
client_print_color(id, print_team_default, "^1[^4Stats^1] В статистике нет позиции #%d и ниже!", place);
else
{
new statsMax = place + MAX_TOP_POS;
if(statsMax > statsNum)
statsMax = statsNum;
new OldLen, bool:IsCut, buff[1535], len = formatex(buff, charsmax(buff), "<META http-equiv=Content-Type content='text/html;charset=UTF-8'><link href='%s' rel=stylesheet type=text/css>", CSS_STYLE);
len += formatex(buff[len], charsmax(buff) - len, "<table><tr><th>#<th>Nick<th>Frags<th>HS<th>Assists<th>Deaths<th>Shots<th>Hits<th>Eff<th>Acc<th>Skill</tr>");
for(new i = place, st[ARRSIZE_STATS], bh[ARRSIZE_BODY], szName[32]; i < statsMax; ++i)
{
get_stats_sql(i, st, bh, szName, charsmax(szName));
OldLen = len;
len += formatex(
buff[len],
charsmax(buff) - len,
"<tr><td>%d<td>%s<td>%d<td>%d<td>%d<td>%d<td>%d<td>%d<td>%.2f%%<td>%.2f%%<td>%s</tr>",
i+1,
szName,
st[FRAGS],
st[HS],
bh[ASSIST],
st[DEATHS],
st[SHOTS],
st[HITS],
effec(st[FRAGS], st[DEATHS]),
accuracy(st[HITS], st[SHOTS]),
g_arrViewSkills[get_skill(bh[SKILL])]
);
if(len + 9 >= charsmax(buff))
{
buff[OldLen] = 0;
IsCut = true;
break;
}
}
formatex(buff[IsCut ? OldLen : len], charsmax(buff), "</table>");
show_motd(id, buff, "Top players");
}
}
case StatsRank:
{
new st[ARRSIZE_STATS], bh[ARRSIZE_BODY];
new plRank = get_user_stats_sql(id, st, bh);
if(!plRank)
client_print_color(id, print_team_default, "^1[^4Stats^1] Нет данных!");
else
{
client_print_color(
id,
print_team_default,
"^1[^4Stats^1] Вы занимаете ^3%d-е ^1место из ^3%d^1, убив ^3%d^1, попав ^3%d ^1раз [^4Эфф ^3%.2f%^1|^4АКК ^3%.2f%^1|^4Скилл ^3%s^1|^4Ассистов ^3%d^1]",
plRank,
get_statsnum_sql(),
st[FRAGS],
st[HITS],
effec(st[FRAGS], st[DEATHS]),
accuracy(st[HITS], st[SHOTS]),
g_arrViewSkills[get_skill(bh[SKILL])],
bh[ASSIST]
);
}
}
case StatsRankStats:
{
new st[ARRSIZE_STATS], bh[ARRSIZE_BODY];
new plRank = get_user_stats_sql(id, st, bh);
if(!plRank)
client_print_color(id, print_team_default, "^1[^4Stats^1] Нет данных!");
else
{
new buff[1535], len;
len += formatex(buff[len], charsmax(buff) - len, "<META http-equiv=Content-Type content='text/html;charset=UTF-8'><link href='%s' rel=stylesheet type=text/css>", CSS_STYLE);
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", plRank, get_statsnum_sql());
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>%s</table>",
st[FRAGS], st[HS], bh[ASSIST], st[DEATHS], st[HITS], st[SHOTS], st[DAMAGE], accuracy(st[HITS], st[SHOTS]), effec(st[FRAGS], st[DEATHS]), g_arrViewSkills[get_skill(bh[SKILL])]);
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[i], bh[i]);
formatex(buff[len], charsmax(buff) - len, "<tr><td height=15px><td></table>");
show_motd(id, buff, "Your stats");
}
}
case StatsRs:
{
set_user_score(id, 0, 0);
client_cmd(id, "spk buttons/blip1.wav");
client_print_color(id, print_team_default, "^1[^4SayRs^1] ^1Ваш счет ^3успешно ^1обнулен!");
}
}
return PLUGIN_HANDLED;
}
stock get_skill(skill)
{
for(new i; i < sizeof g_arrViewSkills; ++i)
{
if(i && g_arrItemSkills[i] > skill)
return i - 1;
else if((!i && g_arrItemSkills[i] > skill) || 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));
Привет знатоки.
Не получается скомпилировать: CSX Easy Stats
Имею желание поставить CSstatasX SQL вместе с CSX Easy Stats
Вариант установки без замены модуля CSX
Не получается скомпилировать: CSX Easy Stats
Имею желание поставить CSstatasX SQL вместе с CSX Easy Stats
Вариант установки без замены модуля CSX
В этой теме было размещено решение! Перейти к решению.