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

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

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

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

> Правила форума

Этот раздел, как вы могли заметить по названию, предназначен для решения вопросов по поводу уже существующих модов и плагинов.
Пожалуйста, если у вас проблема с написанием плагина, не путайте этот раздел с разделом по скриптингу.
Для поиска плагинов и модов существует соответствующий раздел.

Название темы должно соответствовать содержанию. Темы с названием типа "Помогите", "Вопрос", "парни подскажите..." - будут удалены.
Все темы, не относящиеся к "Вопросам по модам и плагинам", будут удалены или перемещены в соответствующий раздел.

Правила оформления темы:
1. Помимо заголовка не забудьте верно сформулировать свой вопрос.
2. Выложите исходник (в тег кода + ) или ссылку на плагин который вызывает у вас вопросы.
3. Выложите лог с ошибками (если имеется) под спойлер

Виснет компилятор

[РЕШЕНО]
Статус пользователя ToL9N4eG
сообщение 16.11.2015, 11:58
Сообщение #1
Стаж: 13 лет

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

При компиляции плагина компилятор зависает. amx 1.8.2
скрин

исходник
Код:
#include <amxmodx>
#include <fun>
#include <cstrike>
#include <hamsandwich>
#include <dhudmessage>
#include <colorchat>

#define client_print_color ColorChat
#define print_team_green GREEN

#pragma semicolon 1

#define PLUGIN "Steam Bonus"
#define VERSION "1.2"
#define AUTHOR "Stimul"
#define PREFIX "[STEAM Бонус]"

#define get_bit(%1,%2) (%1 & (1 << (%2 & 31)))
#define set_bit(%1,%2) (%1 |= (1 << (%2 & 31)))
#define reset_bit(%1,%2) (%1 &= ~(1 << (%2 & 31)))

// Цвет DHUD сообщения
#define COLOR_RED random(255) // Количество красного цвета
#define COLOR_GREEN random(255) // Количество зелёного цвета
#define COLOR_BLUE random(255) // Количество синего цвета

#define TIME 5.0 // Время показа

#define NUM_MONEY 700 // Количество денег

new g_bIsConnected;
new g_bIsSteam;
new g_bProcedure;

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);

RegisterHam(Ham_CS_RoundRespawn, "player", "fw_CS_RoundRespawn_Post", true);
}

public client_putinserver(id)
{
set_bit(g_bIsConnected, id);

if(is_user_steam(id))
{
set_bit(g_bIsSteam, id);
reset_bit(g_bProcedure, id);
set_task(3.0, "WelcomeMessage", id);
}
else
reset_bit(g_bIsSteam, id);
}

public client_disconnect(id)
reset_bit(g_bIsConnected, id);

public WelcomeMessage(id)
{
if(get_bit(g_bIsConnected, id))
{
static szName[32];
get_user_name(id, szName, charsmax(szName));

set_dhudmessage(COLOR_RED, COLOR_GREEN, COLOR_BLUE, -1.0, 0.3, 0, 0.0, TIME);
show_dhudmessage(id, "Привет, %s!", szName);
set_dhudmessage(COLOR_RED, COLOR_GREEN, COLOR_BLUE, -1.0, 0.34, 0, 0.0, TIME);
show_dhudmessage(id, "У тебя Steam, поэтому каждый раунд ты будешь получать бонусы");
}
}

public fw_CS_RoundRespawn_Post(id)
{
if(get_bit(g_bIsConnected, id) && get_bit(g_bIsSteam, id))
{
if(!get_bit(g_bProcedure, id))
{
cs_set_user_money(id, cs_get_user_money(id) + NUM_MONEY);
client_print_color(id, print_team_green, "^3%s ^1Ты получаешь бонус: ^4'%d$'", PREFIX, NUM_MONEY);
set_bit(g_bProcedure, id);
}
else
{
give_item(id, "weapon_hegrenade");
give_item(id, "weapon_flashbang");
cs_set_user_bpammo(id, CSW_FLASHBANG, 2);
give_item(id, "weapon_smokegrenade");
client_print_color(id, print_team_green, "^3%s ^1Ты получаешь бонус: ^4'все гранаты'", PREFIX);
reset_bit(g_bProcedure, id);
}
}
}

stock bool:is_user_steam(id)
{
static dp_pointer;

if(dp_pointer || (dp_pointer = get_cvar_pointer("dp_r_id_provider")))
{
server_cmd("dp_clientinfo %d", id);
server_exec();
return (get_pcvar_num(dp_pointer) == 2) ? true : false;
}

new szAuthid[34];
get_user_authid(id, szAuthid, charsmax(szAuthid));

return (containi(szAuthid, "LAN") < 0);
}

скомпилился только здесь (без учета кодировки)
http://aghl.ru/webcompiler/


Отредактировал: ToL9N4eG, - 16.11.2015, 12:02
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   Цитировать сообщение
Статус пользователя VenigreT
сообщение 16.11.2015, 12:35
Сообщение #2
Стаж: 10 лет

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

А с другими плагинами как компилятор?
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя ToL9N4eG
сообщение 16.11.2015, 12:36
Сообщение #3
Стаж: 13 лет

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

VenigreT, с другими плагинами все отлично
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
voed
сообщение 16.11.2015, 12:46
Сообщение #4
Стаж: 11 лет

Сообщений: 2593
Благодарностей: 1760
Полезность: 405

Я бы смотрел инклуды для начала. Вообще послледний раз такое видел, если строка в исходнике слишком длинная, но тут на это не похоже
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя ToL9N4eG
сообщение 16.11.2015, 12:48
Сообщение #5
Стаж: 13 лет

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

voed, я тоже подумал, что это из-за них. поэтому скопировал их с сайта, где плагин компилируется. все равно эффекта 0. И да, без колорчата все отлично компилится.
colorchat.inc
Код:
#if defined _colorchat_included
#endinput
#endif
#define _colorchat_included

/* ColorChat Support */
#define NORMAL DontChange
#define GREEN DontChange
#define RED Red
#define BLUE Blue
#define GREY Grey
#define ColorChat client_print_color

#define MAX_TRANSLATION_LENGTH 2048

enum {
DontChange = 0,
Grey = -1,
Red = -2,
Blue = -3
};

#define print_team_default DontChange
#define print_team_grey Grey
#define print_team_red Red
#define print_team_blue Blue

stock client_print_color(id, sender, const fmt[], any:...)
{
// check if id is different from 0
if (id && !is_user_connected(id))
{
return 0;
}

if (sender < Blue || sender > 32)
{
sender = DontChange;
}
else if (sender < DontChange)
{
sender = -sender + 32; // align indexes to the TeamInfo ones
}

static const szTeamName[][] =
{
"",
"TERRORIST",
"CT"
};

new szMessage[191];

new iParams = numargs();

// Specific player code
if (id)
{
if (iParams == 3)
{
copy(szMessage, charsmax(szMessage), fmt); // copy so message length doesn't exceed critical 192 value
}
else
{
vformat(szMessage, charsmax(szMessage), fmt, 4);
}

if (sender > (32 - Grey))
{
if (sender > (32 - Blue))
{
sender = id;
}
else
{
_CC_TeamInfo(id, sender, szTeamName[sender - (32 - Grey)]);
}
}
_CC_SayText(id, sender, szMessage);
}

// Send message to all players
else
{
// Figure out if at least 1 player is connected
// so we don't execute useless useless code if not
new iPlayers[32], iNum;
get_players(iPlayers, iNum, "ch");
if (!iNum)
{
return 0;
}

new iMlNumber, i, j;
new Array:aStoreML = ArrayCreate();
if (iParams >= 5) // ML can be used
{
for (j = 3; j < iParams; j++)
{
// retrieve original param value and check if it's LANG_PLAYER value
if (getarg(j) == LANG_PLAYER)
{
i = 0;
// as LANG_PLAYER == -1, check if next parm string is a registered language translation
while ((szMessage[i] = getarg(j + 1, i++))) {}
if (GetLangTransKey(szMessage) != TransKey_Bad)
{
// Store that arg as LANG_PLAYER so we can alter it later
ArrayPushCell(aStoreML, j++);

// Update ML array saire so we'll know 1st if ML is used,
// 2nd how many args we have to alterate
iMlNumber++;
}
}
}
}

// If arraysize == 0, ML is not used
// we can only send 1 MSG_ALL message if sender != 0
if (!iMlNumber)
{
if (iParams == 3)
{
copy(szMessage, charsmax(szMessage), fmt);
}
else
{
vformat(szMessage, charsmax(szMessage), fmt, 4);
}
if (0 < sender < (32 - Blue)) // if 0 is passed, need to loop
{
if (sender > (32 - Grey))
{
_CC_TeamInfo(0, sender, szTeamName[sender - (32 - Grey)]);
}
_CC_SayText(0, sender, szMessage);
return 1;
}
}

if (sender > (32 - Blue))
{
sender = 0; // use receiver index
}

for (--iNum; iNum >= 0; iNum--)
{
id = iPlayers[iNum];

if (iMlNumber)
{
for (j = 0; j < iMlNumber; j++)
{
// Set all LANG_PLAYER args to player index ( = id )
// so we can format the text for that specific player
setarg(ArrayGetCell(aStoreML, j), _, id);
}

// format string for specific player
vformat(szMessage, charsmax(szMessage), fmt, 4);
}

if (sender > (32 - Grey))
{
_CC_TeamInfo(id, sender, szTeamName[sender - (32 - Grey)]);
}
_CC_SayText(id, sender, szMessage);
}

ArrayDestroy(aStoreML);
}
return 1;
}

stock _CC_TeamInfo(iReceiver, iSender, szTeam[])
{
static iTeamInfo = 0;
if (!iTeamInfo)
{
iTeamInfo = get_user_msgid("TeamInfo");
}
message_begin(iReceiver ? MSG_ONE : MSG_ALL, iTeamInfo, _, iReceiver);
write_byte(iSender);
write_string(szTeam);
message_end();
}

stock _CC_SayText(iReceiver, iSender, szMessage[])
{
static iSayText = 0;
if (!iSayText)
{
iSayText = get_user_msgid("SayText");
}

// Prevent sending format and localization strings via chat
for (new i = 0; i < 192; i++)
{
if (szMessage[i] == 0) break;
if (szMessage[i] == '%' ||
szMessage[i] == '#')
szMessage[i] = ' ';
}

message_begin(iReceiver ? MSG_ONE : MSG_ALL, iSayText, _, iReceiver);
write_byte(iSender ? iSender : iReceiver);
if (szMessage[0] > 4)
{
write_byte(1);
szMessage[192 - 2 - 1] = 0; // Two write_byte + string terminator
write_string(szMessage);
}
else
{
szMessage[192 - 1 - 1] = 0; // One write_byte + string terminator
write_string(szMessage);
}
message_end();
}

new _translation_szBuffer[MAX_TRANSLATION_LENGTH];

stock register_dictionary_colored(const filename[])
{
if (!register_dictionary(filename))
{
return 0;
}

new szFileName[256];
get_localinfo("amxx_datadir", szFileName, charsmax(szFileName));
format(szFileName, charsmax(szFileName), "%s/lang/%s", szFileName, filename);
new fp = fopen(szFileName, "rt");
if (!fp)
{
log_amx("Failed to open %s", szFileName);
return 0;
}

new szLang[3], szKey[64], TransKey:iKey;

while (!feof(fp))
{
fgets(fp, _translation_szBuffer, charsmax(_translation_szBuffer));
trim(_translation_szBuffer);

if (_translation_szBuffer[0] == '[')
{
strtok(_translation_szBuffer[1], szLang, charsmax(szLang), _translation_szBuffer, 1, ']');
}
else if (_translation_szBuffer[0])
{
strbreak(_translation_szBuffer, szKey, charsmax(szKey), _translation_szBuffer, charsmax(_translation_szBuffer));
iKey = GetLangTransKey(szKey);
if (iKey != TransKey_Bad)
{
replace_all(_translation_szBuffer, charsmax(_translation_szBuffer), "!g", "^4");
replace_all(_translation_szBuffer, charsmax(_translation_szBuffer), "!t", "^3");
replace_all(_translation_szBuffer, charsmax(_translation_szBuffer), "!n", "^1");
replace_all(_translation_szBuffer, charsmax(_translation_szBuffer), "^^4", "^4");
replace_all(_translation_szBuffer, charsmax(_translation_szBuffer), "^^3", "^3");
replace_all(_translation_szBuffer, charsmax(_translation_szBuffer), "^^1", "^1");
replace_all(_translation_szBuffer, charsmax(_translation_szBuffer), "^^n", "^n");
replace_all(_translation_szBuffer, charsmax(_translation_szBuffer), "^^t", "^t");
AddTranslation(szLang, iKey, _translation_szBuffer[2]);
}
}
}

fclose(fp);
return 1;
}

/* ML from AMXX 1.8.3 support */
#define register_dictionary register_dictionary_colored


Отредактировал: ToL9N4eG, - 16.11.2015, 13:00
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя ToL9N4eG
сообщение 16.11.2015, 16:31
Сообщение #6
Стаж: 13 лет

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

Никто помочь не может? Из-за colorchat'а виснет компилятор. Но с инклудом все в порядке. В чем может быть проблема?
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя Bloo
сообщение 16.11.2015, 16:53
Сообщение #7


Стаж: 12 лет

Сообщений: 15547
Благодарностей: 6971
Полезность: 1206

ToL9N4eG, вручную замени функции и убери дефайны
Код
#define client_print_color   ColorChat
#define print_team_green   GREEN

Инклуд то хоть тот?
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
Поблагодарили 1 раз
   + Цитировать сообщение
Статус пользователя ToL9N4eG
сообщение 16.11.2015, 18:32
Сообщение #8
Стаж: 13 лет

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

Bloo, вот инклуд, который шел с плагином. сейчас заменю, если все правильно понял.
colorchat.inc
Код:
#if defined _colorchat_included
#endinput
#endif
#define _colorchat_included

/* ColorChat Support */
#define NORMAL DontChange
#define GREEN DontChange
#define TEAM_COLOR DontChange
#define RED Red
#define BLUE Blue
#define GREY Grey
#define ColorChat client_print_color
/* ColorChat Support */

enum _:Colors {
DontChange,
Red,
Blue,
Grey
}

stock const g_szTeamName[Colors][] =
{
"UNASSIGNED",
"TERRORIST",
"CT",
"SPECTATOR"
}

stock client_print_color(id, iColor=DontChange, const szMsg[], any:...)
{
// check if id is different from 0
if( id && !is_user_connected(id) )
{
return 0;
}

if( iColor > Grey )
{
iColor = DontChange;
}

new szMessage[192];
if( iColor == DontChange )
{
szMessage[0] = 0x04;
}
else
{
szMessage[0] = 0x03;
}

new iParams = numargs();
// Specific player code
if(id)
{
if( iParams == 3 )
{
copy(szMessage[1], charsmax(szMessage)-1, szMsg);
}
else
{
vformat(szMessage[1], charsmax(szMessage)-1, szMsg, 4);
}

if( iColor )
{
new szTeam[11]; // store current team so we can restore it
get_user_team(id, szTeam, charsmax(szTeam));

// set id TeamInfo in consequence
// so SayText msg gonna show the right color
Send_TeamInfo(id, id, g_szTeamName[iColor]);

// Send the message
Send_SayText(id, id, szMessage);

// restore TeamInfo
Send_TeamInfo(id, id, szTeam);
}
else
{
Send_SayText(id, id, szMessage);
}
}

// Send message to all players
else
{
// Figure out if at least 1 player is connected
// so we don't send useless message if not
// and we gonna use that player as team reference (aka SayText message sender) for color change
new iPlayers[32], iNum;
get_players(iPlayers, iNum, "ch");
if( !iNum )
{
return 0;
}

new iFool = iPlayers[0];

new iMlNumber, i, j;
new Array:aStoreML = ArrayCreate();
if( iParams >= 5 ) // ML can be used
{
for(j=4; j<iParams; j++)
{
// retrieve original param value and check if it's LANG_PLAYER value
if( getarg(j) == LANG_PLAYER )
{
i=0;
// as LANG_PLAYER == -1, check if next parm string is a registered language translation
while( ( szMessage[ i ] = getarg( j + 1, i++ ) ) ) {}
if( GetLangTransKey(szMessage) != TransKey_Bad )
{
// Store that arg as LANG_PLAYER so we can alter it later
ArrayPushCell(aStoreML, j++);

// Update ML array saire so we'll know 1st if ML is used,
// 2nd how many args we have to alterate
iMlNumber++;
}
}
}
}

// If arraysize == 0, ML is not used
// we can only send 1 MSG_BROADCAST message
if( !iMlNumber )
{
if( iParams == 3 )
{
copy(szMessage[1], charsmax(szMessage)-1, szMsg);
}
else
{
vformat(szMessage[1], charsmax(szMessage)-1, szMsg, 4);
}

if( iColor )
{
new szTeam[11];
get_user_team(iFool, szTeam, charsmax(szTeam));
Send_TeamInfo(0, iFool, g_szTeamName[iColor]);
Send_SayText(0, iFool, szMessage);
Send_TeamInfo(0, iFool, szTeam);
}
else
{
Send_SayText(0, iFool, szMessage);
}
}

// ML is used, we need to loop through all players,
// format text and send a MSG_ONE_UNRELIABLE SayText message
else
{
new szTeam[11], szFakeTeam[10];

if( iColor )
{
get_user_team(iFool, szTeam, charsmax(szTeam));
copy(szFakeTeam, charsmax(szFakeTeam), g_szTeamName[iColor]);
}

for( i = 0; i < iNum; i++ )
{
id = iPlayers[i];

for(j=0; j<iMlNumber; j++)
{
// Set all LANG_PLAYER args to player index ( = id )
// so we can format the text for that specific player
setarg(ArrayGetCell(aStoreML, j), _, id);
}

// format string for specific player
vformat(szMessage[1], charsmax(szMessage)-1, szMsg, 4);

if( iColor )
{
Send_TeamInfo(id, iFool, szFakeTeam);
Send_SayText(id, iFool, szMessage);
Send_TeamInfo(id, iFool, szTeam);
}
else
{
Send_SayText(id, iFool, szMessage);
}
}
ArrayDestroy(aStoreML);
}
}
return 1;
}

stock Send_TeamInfo(iReceiver, iPlayerId, szTeam[])
{
static iTeamInfo = 0;
if( !iTeamInfo )
{
iTeamInfo = get_user_msgid("TeamInfo");
}
message_begin(iReceiver ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, iTeamInfo, .player=iReceiver);
write_byte(iPlayerId);
write_string(szTeam);
message_end();
}

stock Send_SayText(iReceiver, iPlayerId, szMessage[])
{
static iSayText = 0;
if( !iSayText )
{
iSayText = get_user_msgid("SayText");
}
message_begin(iReceiver ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, iSayText, .player=iReceiver);
write_byte(iPlayerId);
write_string(szMessage);
message_end();
}

stock register_dictionary_colored(const filename[])
{
if( !register_dictionary(filename) )
{
return 0;
}

new szFileName[256];
get_localinfo("amxx_datadir", szFileName, charsmax(szFileName));
format(szFileName, charsmax(szFileName), "%s/lang/%s", szFileName, filename);
new fp = fopen(szFileName, "rt");
if( !fp )
{
log_amx("Failed to open %s", szFileName);
return 0;
}

new szBuffer[512], szLang[3], szKey[64], szTranslation[256], TransKey:iKey;

while( !feof(fp) )
{
fgets(fp, szBuffer, charsmax(szBuffer));
trim(szBuffer);

if( szBuffer[0] == '[' )
{
strtok(szBuffer[1], szLang, charsmax(szLang), szBuffer, 1, ']');
}
else if( szBuffer[0] )
{
strbreak(szBuffer, szKey, charsmax(szKey), szTranslation, charsmax(szTranslation));
iKey = GetLangTransKey(szKey);
if( iKey != TransKey_Bad )
{
while( replace(szTranslation, charsmax(szTranslation), "!g", "^4") ){}
while( replace(szTranslation, charsmax(szTranslation), "!t", "^3") ){}
while( replace(szTranslation, charsmax(szTranslation), "!n", "^1") ){}
AddTranslation(szLang, iKey, szTranslation[2]);
}
}
}

fclose(fp);
return 1;
}
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя ToL9N4eG
сообщение 16.11.2015, 18:39
Сообщение #9
Стаж: 13 лет

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

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