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

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

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

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

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

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

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

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

[Вопрос] imessage

Статус пользователя firante
сообщение 4.6.2014, 10:51
Сообщение #1


Стаж: 12 лет

Сообщений: 409
Благодарностей: 41
Полезность: < 0

Привет всем пытался сделать так что-бы imessage печатало так что-бы сообщения выходили в 3 строки а не в одно по стандарту!

Вот так:

"Сообщение #1"
"Сообщение #2"
"Сообщение #3"

Сделал так
Код:
/* AMX Mod X
* Info. Messages Plugin
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* This file is part of AMX Mod X.
*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*/

#include <amxmodx>
#include <amxmisc>
#include <dhudmessage>

#define X_POS -1.0
#define Y_POS 0.20
#define HOLD_TIME 12.0

new Array:g_Values
new Array:g_Messages
new g_MessagesNum
new g_Current

#define charsof(%1) (sizeof(%1)-1)

new amx_freq_imessage;

public plugin_init()
{
g_Messages=ArrayCreate(384);
g_Values=ArrayCreate(3);
register_plugin("Info. Messages", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("imessage.txt")
register_dictionary("common.txt")
register_srvcmd("amx_imessage", "setMessage")
amx_freq_imessage=register_cvar("amx_freq_imessage", "10")

new lastinfo[8]
get_localinfo("lastinfomsg", lastinfo, 7)
g_Current = str_to_num(lastinfo)
set_localinfo("lastinfomsg", "")
}

public infoMessage()
{
if (g_Current >= g_MessagesNum)
g_Current = 0

// No messages, just get out of here
if (g_MessagesNum==0)
{
return;
}

new values[3];
new Message[384];

ArrayGetString(g_Messages, g_Current, Message, charsof(Message));
ArrayGetArray(g_Values, g_Current, values);

new hostname[64];

get_cvar_string("hostname", hostname, 63);
replace(Message, 380, "%hostname%", hostname);

set_dhudmessage(0, 255, 0, -1.0, 0.10, 2, 6.0, 3.0, 0.1, 1.5);
show_dhudmessage(0, "%s", Message);
set_dhudmessage(66, 170, 255, -1.0, 0.13, 2, 6.0, 3.0, 0.1, 1.5);
show_dhudmessage(0, "%s", Message);
set_dhudmessage(255, 255, 0, -1.0, 0.16, 2, 6.0, 3.0, 0.1, 1.5);
show_dhudmessage(0, "%s", Message);

client_print(0, print_console, "%s", Message);
++g_Current;

new Float:freq_im = get_pcvar_float(amx_freq_imessage);

if (freq_im > 0.0)
set_task(freq_im, "infoMessage", 12345);
}

public setMessage()
{

new Message[384];

remove_task(12345)
read_argv(1, Message, 380)

while (replace(Message, 380, "\n", "^n")) {}

new mycol[12]
new vals[3];

read_argv(2, mycol, 11) // RRRGGGBBB
vals[2] = str_to_num(mycol[6])

mycol[6] = 0
vals[1] = str_to_num(mycol[3])

mycol[3] = 0
vals[0] = str_to_num(mycol[0])

g_MessagesNum++

new Float:freq_im = get_pcvar_float(amx_freq_imessage)

ArrayPushString(g_Messages, Message);
ArrayPushArray(g_Values, vals);

if (freq_im > 0.0)
set_task(freq_im, "infoMessage", 12345)

return PLUGIN_HANDLED
}

public plugin_end()
{
new lastinfo[8]

num_to_str(g_Current, lastinfo, 7)
set_localinfo("lastinfomsg", lastinfo)
}

amxx.cfg
Код
// Center typed colored messages (last parameter is a color in RRRGGGBBB format)
//
// Default values: "Welcome to %hostname%" "000255100"
//                 "This server is using AMX ModX\nVisit http://www.amxmodx.org" "000100255"
amx_imessage "Сообщение #1"
amx_imessage "Сообщение #2"
amx_imessage "Сообщение #3"


В итоге у меня выходит так: одно и тоже сообщение выводит на 3 строки

Помогите как сделать правильно?

Отредактировал: firante, - 4.6.2014, 10:53
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   Цитировать сообщение
Статус пользователя GOOD FELLOW
сообщение 4.6.2014, 11:01
Сообщение #2


Иконка группы

Стаж: 13 лет

Сообщений: 2294
Благодарностей: 1187
Полезность: 890

у тебя одна переменная message,в которой твой текст
тебе еще нужно создавать, чтобы вывести другое
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя firante
сообщение 4.6.2014, 11:04
Сообщение #3


Стаж: 12 лет

Сообщений: 409
Благодарностей: 41
Полезность: < 0

GOOD FELLOW,
Как это сделать покажи пожалуйста?
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
serfreeman1337
сообщение 4.6.2014, 11:07
Сообщение #4
Стаж: 13 лет

Сообщений: 912
Благодарности: выкл.

Так попробуй:
Код:

for(new i ; i < 3 ; ++i){
if(g_Current ++ > g_MessagesNum)
g_Current = 0

ArrayGetString(g_Messages, g_Current, Message, charsof(Message));
ArrayGetArray(g_Values, g_Current, values);

switch(i){
case 0: set_dhudmessage(0, 255, 0, -1.0, 0.10, 2, 6.0, 3.0, 0.1, 1.5);
case 1: set_dhudmessage(66, 170, 255, -1.0, 0.13, 2, 6.0, 3.0, 0.1, 1.5);
case 2: set_dhudmessage(255, 255, 0, -1.0, 0.16, 2, 6.0, 3.0, 0.1, 1.5);
}

show_dhudmessage(0, "%s", Message);
}


Только ++g_Current; выпили.

Отредактировал: serfreeman1337, - 4.6.2014, 11:13
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя firante
сообщение 4.6.2014, 11:21
Сообщение #5


Стаж: 12 лет

Сообщений: 409
Благодарностей: 41
Полезность: < 0

serfreeman1337,
Сделал вот так:
Код:
/* AMX Mod X
* Info. Messages Plugin
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* This file is part of AMX Mod X.
*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*/

#include <amxmodx>
#include <amxmisc>
#include <dhudmessage>

#define X_POS -1.0
#define Y_POS 0.20
#define HOLD_TIME 12.0

new Array:g_Values
new Array:g_Messages
new g_MessagesNum
new g_Current

#define charsof(%1) (sizeof(%1)-1)

new amx_freq_imessage;

public plugin_init()
{
g_Messages=ArrayCreate(384);
g_Values=ArrayCreate(3);
register_plugin("Info. Messages", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("imessage.txt")
register_dictionary("common.txt")
register_srvcmd("amx_imessage", "setMessage")
amx_freq_imessage=register_cvar("amx_freq_imessage", "10")

new lastinfo[8]
get_localinfo("lastinfomsg", lastinfo, 7)
g_Current = str_to_num(lastinfo)
set_localinfo("lastinfomsg", "")
}

public infoMessage()
{
if (g_Current >= g_MessagesNum)
g_Current = 0

// No messages, just get out of here
if (g_MessagesNum==0)
{
return;
}

new values[3];
new Message[384];

for(new i ; i < 3 ; ++i){
if(g_Current ++ >= g_MessagesNum)
g_Current = 0

ArrayGetString(g_Messages, g_Current, Message, charsof(Message));
ArrayGetArray(g_Values, g_Current, values);

switch(i){
case 0: set_dhudmessage(0, 255, 0, -1.0, 0.10, 2, 6.0, 3.0, 0.1, 1.5);
case 1: set_dhudmessage(66, 170, 255, -1.0, 0.13, 2, 6.0, 3.0, 0.1, 1.5);
case 2: set_dhudmessage(255, 255, 0, -1.0, 0.16, 2, 6.0, 3.0, 0.1, 1.5);
}

show_dhudmessage(0, "%s", Message);
}

new Float:freq_im = get_pcvar_float(amx_freq_imessage);

if (freq_im > 0.0)
set_task(freq_im, "infoMessage", 12345);
}

public setMessage()
{

new Message[384];

remove_task(12345)
read_argv(1, Message, 380)

while (replace(Message, 380, "\n", "^n")) {}

new mycol[12]
new vals[3];

read_argv(2, mycol, 11) // RRRGGGBBB
vals[2] = str_to_num(mycol[6])

mycol[6] = 0
vals[1] = str_to_num(mycol[3])

mycol[3] = 0
vals[0] = str_to_num(mycol[0])

g_MessagesNum++

new Float:freq_im = get_pcvar_float(amx_freq_imessage)

ArrayPushString(g_Messages, Message);
ArrayPushArray(g_Values, vals);

if (freq_im > 0.0)
set_task(freq_im, "infoMessage", 12345)

return PLUGIN_HANDLED
}

public plugin_end()
{
new lastinfo[8]

num_to_str(g_Current, lastinfo, 7)
set_localinfo("lastinfomsg", lastinfo)
}

В логах ошибки пошли
Код
L 06/04/2014 - 14:17:27: Invalid cellvector handle provided (49:3:3)
L 06/04/2014 - 14:17:27: [AMXX] Displaying debug trace (plugin "imessage.amxx")
L 06/04/2014 - 14:17:27: [AMXX] Run time error 10: native error (native "ArrayGetString")
L 06/04/2014 - 14:17:27: [AMXX]    [0] imessage.sma::infoMessage (line 86)


Отредактировал: firante, - 4.6.2014, 11:25
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя firante
сообщение 4.6.2014, 17:29
Сообщение #6


Стаж: 12 лет

Сообщений: 409
Благодарностей: 41
Полезность: < 0

Пацаны тема в силе проблема не решена (
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя Andrei
сообщение 4.6.2014, 18:57
Сообщение #7


Стаж: 15 лет

Сообщений: 1335
Благодарностей: 693
Полезность: 740

В плагине зеленого текста больше, чем самого плагина.

amx_imessage "Сообщение #1"
amx_imessage "Сообщение #2"
amx_imessage "Сообщение #3"

Так не выйдет. Оно не определиться, какое сообщение брать из трех. Ведь у тебя нет ни какого поиска строки, а конкретно заданная.

Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
serfreeman1337
сообщение 4.6.2014, 20:00
Сообщение #8
Стаж: 13 лет

Сообщений: 912
Благодарности: выкл.

Код:
for(new i ; i < 3 ; ++i){
if(g_Current >= g_MessagesNum)
g_Current = 0

ArrayGetString(g_Messages, g_Current, Message, charsof(Message));
ArrayGetArray(g_Values, g_Current, values);

switch(i){
case 0: set_dhudmessage(0, 255, 0, -1.0, 0.10, 2, 6.0, 3.0, 0.1, 1.5);
case 1: set_dhudmessage(66, 170, 255, -1.0, 0.13, 2, 6.0, 3.0, 0.1, 1.5);
case 2: set_dhudmessage(255, 255, 0, -1.0, 0.16, 2, 6.0, 3.0, 0.1, 1.5);
}

show_dhudmessage(0, "%s", Message);

g_Current ++
}
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя proff_q
сообщение 4.6.2014, 20:58
Сообщение #9
Стаж: 14 лет

Сообщений: 357
Благодарностей: 263
Полезность: 804

Юзай hud message, делай перенос строки \n и не парься.
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя firante
сообщение 4.6.2014, 21:02
Сообщение #10


Стаж: 12 лет

Сообщений: 409
Благодарностей: 41
Полезность: < 0

serfreeman1337,
Спасибо все получилось RESPECT )
Цитата
P.S: Единственный чел, которому не в падлу помогать доброжелательный, отзывчивый! По больше бы таких добрых людей, а то просишь о помощи некоторых, они даже не отвечают, а если ответят то через не хочу, и с таким тоном как будто я тебе обязан!? :D


proff_q,
Проверял не получалось через ^n переносить текст

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