Правила форума Гаранты форума
Размещение рекламы AMX-X компилятор

Здравствуйте, гость Вход | Регистрация

Наши новости:

14-дек
24-апр
10-апр
11-апр

Ошибка в плагине info_rank

Статус пользователя carter
сообщение 19.12.2016, 10:18
Сообщение #1
Стаж: 13 лет

Сообщений: 111
Благодарностей: 4
Полезность: 35

Здравствуйте.
После перехода с amxmodx 1.8.2 на ReAmxmodx 1.8.3 появилась ошибка

Displaying debug trace (plugin "info_rank.amxx", version "1.0")
Run time error 4: index out of bounds.
[0] colorinfo.inc::ColorChat (line 74)
[1] info_rank.sma::event_player_spawn (line 86)
[2] info_rank.sma::eResetHUD (line 61)

Cкрытый текст

сам плагин
Код:

//Uncomment line below if you want messages to be disabled by default (aka players have to type /inrorank to enable them)
//#define DISABLED_BY_DEFAULT

#include <amxmodx>
#include <csx>
#include <colorinfo>

#define MAX_PLAYERS 32
new bool:g_RestartAttempt[MAX_PLAYERS+1]

new g_oldrank[MAX_PLAYERS+1]

#if defined DISABLED_BY_DEFAULT
new bool:disabled[MAX_PLAYERS+1] = {true, ...}
#else
new bool:disabled[MAX_PLAYERS+1]
#endif

new inforank

public plugin_init() {
register_plugin("Info Rank", "1.0", "connor")
register_dictionary("inforank.txt")

inforank = register_cvar("amx_inforank", "1")

register_event("TextMsg", "eRestartAttempt", "a", "2=#Game_will_restart_in")
register_event("ResetHUD", "eResetHUD", "be")

register_clcmd("say /inforank","switchCmd", 0, "- enable/disable info rank messages")
register_clcmd("say_team /inforank","switchCmd", 0, "- enable/disable info rank messages")
register_clcmd("fullupdate", "fullupdateCmd")
}

public fullupdateCmd() {
return PLUGIN_HANDLED_MAIN
}

public eRestartAttempt() {
if(!get_pcvar_num(inforank))
return

new players[MAX_PLAYERS], num
get_players(players, num, "a")
for (new i; i < num; ++i)
g_RestartAttempt[players[i]] = true
}

public eResetHUD(id) {
if (g_RestartAttempt[id]) {
g_RestartAttempt[id] = false
return
}

if(!get_pcvar_num(inforank))
return

if(disabled[id])
return

event_player_spawn(id)
}

public event_player_spawn(id) {

new osef[8]
new rank = get_user_stats(id, osef, osef)
new maxrank = get_statsnum()

if(g_oldrank[id] == 0)
g_oldrank[id] = rank

new diff = g_oldrank[id] - rank
g_oldrank[id] = rank

new mess[192]
if(diff > 0) {
formatex(mess, 191, "%L", id, "IR_GOOD", diff)
ColorChat(id, GREEN, mess)
}
else if(diff < 0) {
formatex(mess, 191, "%L", id, "IR_BAD", abs(diff))
ColorChat(id, RED, mess)
}
formatex(mess, 191, "%L", id, "IR_RANK", rank, maxrank)
ColorChat(id, GREY, mess)
}

public switchCmd(id) {
if(!get_pcvar_num(inforank))
return PLUGIN_CONTINUE

if(disabled[id]) {
disabled[id] = false
client_cmd(id, "setinfo _ir 1")
client_print(id, print_chat, "%L", id, "IR_ENABLE")
}
else {
disabled[id] = true
client_cmd(id, "setinfo _ir 0")
client_print(id, print_chat, "%L", id, "IR_DISABLE")
}
return PLUGIN_CONTINUE
}

public client_authorized(id) {
new osef[8]
g_oldrank[id] = get_user_stats(id, osef, osef)

new enable[2]
get_user_info(id, "_ir", enable, 1)
if(!enable[0])
return

if(enable[0]=='1')
disabled[id] = false
else
disabled[id] = true
}

public client_disconnect(id) {
g_oldrank[id] = 0

#if defined DISABLED_BY_DEFAULT
disabled[id] = true
#else
disabled[id] = false
#endif
}


colorinfo.inc

Код:
/* Fun functions
*
* by Numb
*
* This file is provided as is (no warranties).
*/

#if defined _colorchat_included
#endinput
#endif
#define _colorchat_included

enum Color
{
NORMAL = 1, // clients scr_concolor cvar color
GREEN, // Green Color
TEAM_COLOR, // Red, grey, blue
GREY, // grey
RED, // Red
BLUE, // Blue
}

new TeamName[][] =
{
"",
"TERRORIST",
"CT",
"SPECTATOR"
}

ColorChat(id, Color:type, const msg[], {Float,Sql,Result,_}:...)
{
new message[256];

switch(type)
{
case NORMAL: // clients scr_concolor cvar color
{
message[0] = 0x01;
}
case GREEN: // Green
{
message[0] = 0x04;
}
default: // White, Red, Blue
{
message[0] = 0x03;
}
}

vformat(message[1], 251, msg, 4);

// Make sure message is not longer than 192 character. Will crash the server.
message[192] = '^0';

new team, ColorChange, index, MSG_Type;

if(id)
{
MSG_Type = MSG_ONE;
index = id;
} else {
index = FindPlayer();
MSG_Type = MSG_ALL;
}

team = get_user_team(index);
ColorChange = ColorSelection(index, MSG_Type, type);

ShowColorMessage(index, MSG_Type, message);

if(ColorChange)
{
Team_Info(index, MSG_Type, TeamName[team]);
}
}

ShowColorMessage(id, type, message[])
{
static bool:saytext_used;
static get_user_msgid_saytext;
if(!saytext_used)
{
get_user_msgid_saytext = get_user_msgid("SayText");
saytext_used = true;
}
message_begin(type, get_user_msgid_saytext, _, id);
write_byte(id)
write_string(message);
message_end();
}

Team_Info(id, type, team[])
{
static bool:teaminfo_used;
static get_user_msgid_teaminfo;
if(!teaminfo_used)
{
get_user_msgid_teaminfo = get_user_msgid("TeamInfo");
teaminfo_used = true;
}
message_begin(type, get_user_msgid_teaminfo, _, id);
write_byte(id);
write_string(team);
message_end();

return 1;
}

ColorSelection(index, type, Color:Type)
{
switch(Type)
{
case RED:
{
return Team_Info(index, type, TeamName[1]);
}
case BLUE:
{
return Team_Info(index, type, TeamName[2]);
}
case GREY:
{
return Team_Info(index, type, TeamName[0]);
}
}

return 0;
}

FindPlayer()
{
new i = -1;

while(i <= get_maxplayers())
{
if(is_user_connected(++i))
return i;
}

return -1;
}

Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   Цитировать сообщение
Статус пользователя Algalon
сообщение 19.12.2016, 19:57
Сообщение #2
Стаж: 11 лет

Сообщений: 163
Благодарностей: 60
Полезность: 291

carter, удали
Код:
#include <colorinfo>
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя Jelly
сообщение 19.12.2016, 20:28
Сообщение #3


Стаж: 9 лет 6 месяцев
Город: Красноярск

Сообщений: 202
Благодарностей: 42
Полезность: 106

Меценат Меценат

Algalon, и он не сможет скомпилировать , хороший совет! =)
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
Поблагодарили 1 раз
   + Цитировать сообщение
Статус пользователя Algalon
сообщение 19.12.2016, 20:40
Сообщение #4
Стаж: 11 лет

Сообщений: 163
Благодарностей: 60
Полезность: 291

RussianBear, в амхх 1.8.3 присутствует нативный колорчат, инклюд там ненужен.
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
Поблагодарили 1 раз
   + Цитировать сообщение
Статус пользователя Stimul1
сообщение 20.12.2016, 0:42
Сообщение #5


Стаж: 13 лет

Сообщений: 227
Благодарностей: 262
Полезность: 977

Код:
//Uncomment line below if you want messages to be disabled by default (aka players have to type /inrorank to enable them)
//#define DISABLED_BY_DEFAULT

#include <amxmodx>
#include <csx>

#define MAX_PLAYERS 32
new bool:g_RestartAttempt[MAX_PLAYERS+1]

new g_oldrank[MAX_PLAYERS+1]

#if defined DISABLED_BY_DEFAULT
new bool:disabled[MAX_PLAYERS+1] = {true, ...}
#else
new bool:disabled[MAX_PLAYERS+1]
#endif

new inforank

public plugin_init() {
register_plugin("Info Rank", "1.0", "connor")
register_dictionary("inforank.txt")

inforank = register_cvar("amx_inforank", "1")

register_event("TextMsg", "eRestartAttempt", "a", "2=#Game_will_restart_in")
register_event("ResetHUD", "eResetHUD", "be")

register_clcmd("say /inforank","switchCmd", 0, "- enable/disable info rank messages")
register_clcmd("say_team /inforank","switchCmd", 0, "- enable/disable info rank messages")
register_clcmd("fullupdate", "fullupdateCmd")
}

public fullupdateCmd() {
return PLUGIN_HANDLED_MAIN
}

public eRestartAttempt() {
if(!get_pcvar_num(inforank))
return

new players[MAX_PLAYERS], num
get_players(players, num, "a")
for (new i; i < num; ++i)
g_RestartAttempt[players[i]] = true
}

public eResetHUD(id) {
if (g_RestartAttempt[id]) {
g_RestartAttempt[id] = false
return
}

if(!get_pcvar_num(inforank))
return

if(disabled[id])
return

event_player_spawn(id)
}

public event_player_spawn(id) {

new osef[8]
new rank = get_user_stats(id, osef, osef)
new maxrank = get_statsnum()

if(g_oldrank[id] == 0)
g_oldrank[id] = rank

new diff = g_oldrank[id] - rank
g_oldrank[id] = rank

new mess[192]
if(diff > 0) {
formatex(mess, 191, "^4%L", id, "IR_GOOD", diff)
client_print_color(id, print_team_default, mess)
}
else if(diff < 0) {
formatex(mess, 191, "%L", id, "IR_BAD", abs(diff))
client_print_color(id, print_team_red, mess)
}
formatex(mess, 191, "%L", id, "IR_RANK", rank, maxrank)
client_print_color(id, print_team_grey, mess)
}

public switchCmd(id) {
if(!get_pcvar_num(inforank))
return PLUGIN_CONTINUE

if(disabled[id]) {
disabled[id] = false
client_cmd(id, "setinfo _ir 1")
client_print(id, print_chat, "%L", id, "IR_ENABLE")
}
else {
disabled[id] = true
client_cmd(id, "setinfo _ir 0")
client_print(id, print_chat, "%L", id, "IR_DISABLE")
}
return PLUGIN_CONTINUE
}

public client_authorized(id) {
new osef[8]
g_oldrank[id] = get_user_stats(id, osef, osef)

new enable[2]
get_user_info(id, "_ir", enable, 1)
if(!enable[0])
return

if(enable[0]=='1')
disabled[id] = false
else
disabled[id] = true
}

public client_disconnect(id) {
g_oldrank[id] = 0

#if defined DISABLED_BY_DEFAULT
disabled[id] = true
#else
disabled[id] = false
#endif
}
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
Поблагодарили 1 раз
   + Цитировать сообщение
Статус пользователя carter
сообщение 20.12.2016, 15:17
Сообщение #6
Стаж: 13 лет

Сообщений: 111
Благодарностей: 4
Полезность: 35

Stimul1,
Спасибо

Отредактировал: carter, - 20.12.2016, 16:15
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
  Ответить в данную темуНачать новую тему
 
0 пользователей и 1 гостей читают эту тему: