random dhudmessage plugin

В този раздел можете да подавате всякакви заявки за намиране, изработка или преработка на плъгини/модове.
Аватар
vini2001
Извън линия
Foreigner
Foreigner
Мнения: 45
Регистриран на: 09 Мар 2020, 15:50
Се отблагодари: 4 пъти
Обратна връзка:

random dhudmessage plugin

Мнение от vini2001 » 06 Апр 2020, 17:19

I would like a dhudmessage plugin where it appears in the center and top ...
but I want the messages to be exchanging randomly
where I can add several messages
and I would like you to have the option of players you don't like to disable the hud

welcome to the clan
whatsaap contact
etc

Аватар
OciXCrom
Извън линия
Администратор
Администратор
Мнения: 7206
Регистриран на: 06 Окт 2016, 19:20
Местоположение: /resetscore
Се отблагодари: 117 пъти
Получена благодарност: 1295 пъти
Обратна връзка:

random dhudmessage plugin

Мнение от OciXCrom » 06 Апр 2020, 21:18

Код за потвърждение: Избери целия код

#include <amxmodx>

#if AMXX_VERSION_NUM < 183 || !defined set_dhudmessage
	#tryinclude <dhudmessage>

	#if !defined _dhudmessage_included
		#error "dhudmessage.inc" is missing in your "scripting/include" folder. Download it from: "https://amxx-bg.info/forum/inc/"
	#endif
#endif

#tryinclude <cromchat>

#if !defined _cromchat_included
	#error "cromchat.inc" is missing in your "scripting/include" folder. Download it from: "https://amxx-bg.info/forum/inc/"
#endif

#if !defined MAX_PLAYERS
const MAX_PLAYERS = 32
#endif

new const MESSAGES_LIST[][] =
{
	"random message1",
	"random message2",
	"random message3"
}

#define MSG_COLOR 0, 255, 0
#define MSG_POSITION -1.0, 0.1
#define MSG_CHANGE_INTERVAL 15.0

new bool:g_bMsgEnabled[MAX_PLAYERS + 1]

public plugin_init()
{
	register_plugin("Random DHUD Messages", "1.0", "OciXCrom")
	register_clcmd("say /msg", "ToggleMessages")
	register_clcmd("say_team /msg", "ToggleMessages")
	set_task(MSG_CHANGE_INTERVAL, "DisplayMessage", .flags = "b")
}

public client_putinserver(id)
{
	g_bMsgEnabled[id] = true
}

public DisplayMessage()
{
	new iPlayers[MAX_PLAYERS], iPnum
	get_players(iPlayers, iPnum)

	set_dhudmessage(MSG_COLOR, MSG_POSITION, .holdtime = MSG_CHANGE_INTERVAL)

	for(new i, iPlayer, iMsg = random(sizeof(MESSAGES_LIST)); i < iPnum; i++)
	{
		iPlayer = iPlayers[i]

		if(g_bMsgEnabled[iPlayer])
		{
			show_dhudmessage(iPlayer, MESSAGES_LIST[iMsg])
		}
	}
}

public ToggleMessages(id)
{
	g_bMsgEnabled[id] = !g_bMsgEnabled[id]
	CC_SendMessage(id, "&x04* Info messages have been %s&x01.", g_bMsgEnabled[id] ? "&x06enabled" : "&x07disabled")
	return PLUGIN_HANDLED
}

Аватар
vini2001
Извън линия
Foreigner
Foreigner
Мнения: 45
Регистриран на: 09 Мар 2020, 15:50
Се отблагодари: 4 пъти
Обратна връзка:

random dhudmessage plugin

Мнение от vini2001 » 07 Апр 2020, 05:55

works perfectly friend, thank you very much.

just a doubt ... because in most plugins the #define is all aligned to the right
#
#
#
and in this code there are some
#
          #
                 #

so take this doubt away I'm not learning.

after that thank you very much.
you can close the topic

Аватар
OciXCrom
Извън линия
Администратор
Администратор
Мнения: 7206
Регистриран на: 06 Окт 2016, 19:20
Местоположение: /resetscore
Се отблагодари: 117 пъти
Получена благодарност: 1295 пъти
Обратна връзка:

random dhudmessage plugin

Мнение от OciXCrom » 07 Апр 2020, 14:14

You mean to the left?
It doesn't matter. That's just my coding style, doesn't make any difference for the plugin. Both work the same. I use this style because it's easier to read.

Публикувай отговор
  • Подобни теми
    Отговори
    Преглеждания
     Последно мнение

Обратно към “Заявки за плъгини”

Кой е на линия

Потребители разглеждащи този форум: 0 регистрирани и 10 госта