Каква грешка?
Таска си е един, id-то на играчите ще го вземеш през цикъл (1 до maxplayers, примерно), не е нужно да правиш таск за всеки играч поотделно, това ще товари сървъра повече.
Server Commands v1.2
Правила на форума
ИНФОРМАЦИЯ: В този раздел най-вероятно няма да намерите много теми (възможно е и да е напълно празен), тъй като новите теми се местят в https://amxx-bg.info/viewforum.php?f=21 или https://amxx-bg.info/viewforum.php?f=22, зависимо от качеството им.
ИНФОРМАЦИЯ: В този раздел най-вероятно няма да намерите много теми (възможно е и да е напълно празен), тъй като новите теми се местят в https://amxx-bg.info/viewforum.php?f=21 или https://amxx-bg.info/viewforum.php?f=22, зависимо от качеството им.
-
illusion
Извън линия - Developer
- Мнения: 1796
- Регистриран на: 27 Ное 2016, 17:47
- Местоположение: CraftVision
- Се отблагодари: 151 пъти
- Получена благодарност: 358 пъти
- Обратна връзка:
Server Commands v1.2
Засега това:
g_AdvertMessage = !g_AdvertMessage
->
g_AdvertMessage[id] = !g_AdvertMessage[id]
предполагам
Код за потвърждение: Избери целия код
#include <amxmodx>
#include <formatin>
#include <cromchat>
#if AMXX_VERSION_NUM < 183
#include <dhudmessage>
#endif
// Defines
#define AUTHOR "summertime vibes"
#define VERSION "1.2"
#define HudPrefix "[HUD Prefix]"
#define DHUDPrefix "[DHUD PREFIX]"
#define firstcommand "/command1"
#define secondcommand "/command2"
// New
new pCvar, pCvar2, cvar_time
new bool:g_AdvertMessage[33] = true
// New Const
new const g_iCommand[] = { "/command1" }
new const g_iCommandTwo[] = { "/command2" }
new const g_iCommandAdvert[] = { "/scadvert" }
public plugin_init()
{
register_plugin("Server Commands", VERSION, AUTHOR)
for(new i; i<sizeof(g_iCommand); i++)
{
register_clcmd(formatin("say %s", g_iCommand[i]), "cmd1")
register_clcmd(formatin("say_team %s", g_iCommand[i]), "cmd1")
}
for(new i; i<sizeof(g_iCommandTwo); i++)
{
register_clcmd(formatin("say %s", g_iCommandTwo[i]), "cmd2")
register_clcmd(formatin("say_team %s", g_iCommandTwo[i]), "cmd2")
}
for(new i; i<sizeof(g_iCommandAdvert); i++)
{
register_clcmd(formatin("say %s", g_iCommandAdvert[i]), "advertcmd")
register_clcmd(formatin("say_team %s", g_iCommandAdvert[i]), "advertcmd")
}
pCvar = register_cvar("amx_sc_message", "0") // 0 - chat ; 1 - hud ; 2 - dhud
pCvar2 = register_cvar("amx_sc_message2", "0") // 0 - chat ; 1 - hud ; 2 - dhud
cvar_time = register_cvar("amx_sc_advert_time", "300.0")
CC_SetPrefix("&x04[Server Commands]")
}
public plugin_cfg()
{
set_task(get_pcvar_float(cvar_time), "Advert", _,_,_, "b");
}
public Advert(id)
if(g_AdvertMessage[id])
{
CC_SendMessage(0, "^x03Write in the chat &x01%s &x03or &x01%s &x03to view the commands information&x01.",firstcommand, secondcommand);
return
}
public advertcmd(id)
{
g_AdvertMessage = !g_AdvertMessage
CC_SendMessage(id, "&x01Advert Messages have been &x03%s&x01.", g_AdvertMessage ? "enabled" : "disabled" );
}
public cmd(id)
{
switch(get_pcvar_num(pCvar))
{
case 0: CC_SendMessage(id, "^x04The text when you write the command.")
case 1:
{
set_hudmessage(random(256), random(256), random(256), -1.0, 0.26, 2, 6.0, 12.0)
show_hudmessage(id, "%s The text when you write the command.",HudPrefix)
}
case 2:
{
set_dhudmessage(random(256), random(256), random(256), -1.0, 0.26, 2, 6.0, 12.0)
show_dhudmessage(id, "%s The text when you write the command.",DHUDPrefix)
}
}
}
public cmd2(id)
{
switch(get_pcvar_num(pCvar2))
{
case 0: CC_SendMessage(id, "^x04The text when you write the command.")
case 1:
{
set_hudmessage(random(256), random(256), random(256), -1.0, 0.26, 2, 6.0, 12.0)
show_hudmessage(id, "%s The text when you write the command.",HudPrefix)
}
case 2:
{
set_dhudmessage(random(256), random(256), random(256), -1.0, 0.26, 2, 6.0, 12.0)
show_dhudmessage(id, "%s The text when you write the command.",DHUDPrefix)
}
}
}
->
g_AdvertMessage[id] = !g_AdvertMessage[id]
предполагам
-
<VeCo>
Извън линия - AMXX Скриптър
- Мнения: 145
- Регистриран на: 28 Яну 2019, 19:01
- Се отблагодари: 11 пъти
- Получена благодарност: 80 пъти
- Обратна връзка:
Server Commands v1.2
Код за потвърждение: Избери целия код
set_task(get_pcvar_float(cvar_time), "Advert", /*това тук->*/_/*<-*/,_,_, "b");
Код за потвърждение: Избери целия код
public Advert(id)/*<-е това тук*/
Тоя "return" няма нужда да го има.
А, и в АМХХ 1.9 има вградена fmt() със същата функционалност. Може да направиш така:
Код за потвърждение: Избери целия код
#if AMXX_VERSION_NUM < 183
#include <formatin>
#include <dhudmessage>
#else
#define formatin fmt
#endif
-
- Подобни теми
- Отговори
- Преглеждания
- Последно мнение
-
- 2 Отговори
- 1601 Преглеждания
-
Последно мнение от antonstoqnovv
-
- 1 Отговори
- 1576 Преглеждания
-
Последно мнение от OciXCrom
-
- 4 Отговори
- 505 Преглеждания
-
Последно мнение от Siska
-
- 2 Отговори
- 1809 Преглеждания
-
Последно мнение от illusion
-
- 2 Отговори
- 1702 Преглеждания
-
Последно мнение от tom1k
-
- 3 Отговори
- 1277 Преглеждания
-
Последно мнение от antonstoqnovv
-
- 4 Отговори
- 1662 Преглеждания
-
Последно мнение от OciXCrom
Кой е на линия
Потребители разглеждащи този форум: 0 регистрирани и 7 госта