Обучение Скриптингу [sleedney]

Сообщения
119
Реакции
53
Помог
4 раз(а)
fantom, BlackSignature Спасибо большое за информацию буду дальше бороздить моря )))
 
Сообщения
156
Реакции
205
Помог
5 раз(а)
Здравствуйте. Простите за дилетантский вопрос, но это лучшее известное мне сообщество, где я могу получить подобную информацию.
Сам вопрос таков: где можно получить наиболее полную информацию по скриптингу в кс? Знаю, "погугли", "поиском не учили пользоваться?" и т.д. Но хочется именно получить наиболее точную и правильную информацию от профессионалов, а не первую ссылку с гугла.

Для уточнения могу добавить, что меня интересуют следующие области скриптинга:
1) соотносимость стриптинга и С++(похожесть, различия)
2) какие модули можно инклюдить(связь с OS, Kernel, сторонними dll)
3) документация по стандартным функциям и классам в amxxmod.
 
Сообщения
119
Реакции
53
Помог
4 раз(а)
wopox1337, Привет )
Вычитал на форуме проблему одного человека тема показалась мне интересной т.к тама мой любимый плагин "End Round Music" .

К сути :
Мне не нужно что бы ты за меня что то делал, мне нужно что бы ты проверил правильно ли сделал я маленькую работу )) Во как :smile3:
(Если будет свободное время разумеется)

Цель :
Добавить воспроизведение музыки если на сервере ничья.

Код:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "End Round Music"
#define VERSION "2.0"
#define AUTHOR "Sho0ter"

#define TRACKSNUM 100

new ALLMusic[TRACKSNUM][128]
new CTMusic[TRACKSNUM][128]
new TMusic[TRACKSNUM][128]

new PlaylistSize
new CTNum
new TNum
new ALLNum
new SayText

new Mode[32]
new Configsdir[64]
new CurrentMap[64]
new File[96]
new Playlist[128]
new Play[128]
new PlayCommand[128]
new CheckFile[128]

new bool:Ermon[33]

new PcvarMode
new PcvarVol
new PcvarRadio
new PcvarDelay

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_dictionary("endroundmusic.txt")
    register_event("SendAudio", "t_win", "a", "2&%!MRAD_terwin")
    register_event("SendAudio", "ct_win", "a", "2&%!MRAD_ctwin")
    PcvarMode = register_cvar("erm_mode", "1")
    PcvarVol = register_cvar("erm_autovol", "0.5")
    PcvarRadio = register_cvar("erm_radio", "1")
    PcvarDelay = register_cvar("erm_delay", "20.0")
      register_clcmd("say /ermon", "cmd_ermon", 0, " - turn on end round music")
      register_clcmd("say /ermoff", "cmd_ermoff", 0, " - turn off end round music")
    SayText = get_user_msgid("SayText");
    return PLUGIN_CONTINUE
}

public plugin_precache()
{
    get_configsdir(Configsdir, 63)
    get_mapname(CurrentMap, 63)
    formatex(Playlist, 127, "%s/endroundmusic/%s.ini", Configsdir, CurrentMap)
    new Index = 0
    while(CurrentMap[Index] != '_' && CurrentMap[Index] != '^0')
    {
        Index++
    }
    if(!file_exists(Playlist) && CurrentMap[Index] == '_')
    {
        CurrentMap[Index] = '^0'
        formatex(Playlist, 127, "%s/endroundmusic/%s_.ini", Configsdir, CurrentMap)
    }
    if(!file_exists(Playlist))
    {
        formatex(Playlist, 127, "%s/endroundmusic/default.ini", Configsdir)
    }
    if(!file_exists(Playlist))
    {
        log_amx("Playlist <%s> not found.", Playlist)
        set_fail_state("Playlist not found")
        return PLUGIN_CONTINUE
    }
    PlaylistSize = file_size(Playlist, 1)
    for(new i = 0; i <= PlaylistSize; i++)
    {
        new Buffer[128], len, Result
        Result = read_file(Playlist, i, Buffer, sizeof(Buffer)-1, len)
        if(!Result)
        {
            continue
        }
        parse(Buffer, File, 95, Mode, 31)
        if(File[0] == ';' || File[0] == '/' || File[0] == ' ' || equal(File, ""))
        {
            continue
        }
        formatex(CheckFile, 127, "sound/%s", File)
        if(!file_exists(CheckFile))
        {
            log_amx("File not found <%s>", CheckFile)
            continue
        }
        if(equal(Mode, "CT"))
        {
            formatex(CTMusic[CTNum], 127, "%s", File)
            CTNum++
            precache_sound(File)
        }
        else if(equal(Mode, "TER"))
        {
            formatex(TMusic[TNum], 127, "%s", File)
            TNum++
            precache_sound(File)
        }
        else if(equal(Mode, "ALL"))
        {
            formatex(ALLMusic[ALLNum], 127, "%s", File)
            ALLNum++
            precache_sound(File)
        }
    }
    if(CTNum == 0 && TNum == 0 && ALLNum == 0)
    {
        log_amx("Not found tracks in playlist.")
        set_fail_state("Playlist empty")
        return PLUGIN_CONTINUE
    }
    log_amx("Loaded tracks: CT <%d> TER <%d> ALL <%d>", CTNum, TNum, ALLNum)
    return PLUGIN_CONTINUE
}

public client_disconnect(id)
{
    remove_task(id)
    return PLUGIN_CONTINUE
}

public client_putinserver(id)
{
    set_task(get_pcvar_float(PcvarDelay), "showerminfo", id)
    return PLUGIN_HANDLED
}

public t_win()
{
    if(!get_pcvar_num(PcvarMode))
    {
        return PLUGIN_HANDLED
    }
    if((!CTNum || !TNum) && ALLNum && get_pcvar_num(PcvarMode) != 2)
    {
        set_pcvar_num(PcvarMode, 2)
    }
    switch(get_pcvar_num(PcvarMode))
    {
        case 1:
        {
            formatex(Play, 127, "%s", TMusic[random_num(0, TNum-1)])
        }
        case 2:
        {
            formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
        }
        case 3:
        {
            new Randomizer = random_num(1, 2)
            switch(Randomizer)
            {
                case 1:
                {
                    formatex(Play, 127, "%s", TMusic[random_num(0, TNum-1)])
                }
                case 2:
                {
                    formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
                }
            }
        }
        case 4:
        {
            new Randomizer = random_num(1, 3)
            switch(Randomizer)
            {
                case 1:
                {
                    formatex(Play, 127, "%s", CTMusic[random_num(0, CTNum-1)])
                }
                case 2:
                {
                    formatex(Play, 127, "%s", TMusic[random_num(0, TNum-1)])
                }
                case 3:
                {
                    formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
                }
            }
        }
    }
    if(containi(Play, ".wav") != -1)
    {
        formatex(PlayCommand, 127, "spk %s", Play)
    }
    else if(containi(Play, ".mp3") != -1)
    {
        formatex(PlayCommand, 127, "mp3 play sound/%s", Play)
    }
    else
    {
        log_amx("Unsupported file type <%s>", Play)
        return PLUGIN_HANDLED
    }
    for(new id = 0; id <= get_maxplayers(); id++)
    {
        if(!is_user_connected(id) || !Ermon[id])
        {
            continue
        }
        client_cmd(id, "stopsound")
        client_cmd(id, "%s", PlayCommand)
        if(get_pcvar_num(PcvarRadio))
        {
            client_cmd(id, "spk radio/terwin")
        }
    }
    return PLUGIN_HANDLED
}

public ct_win()
{
    if(!get_pcvar_num(PcvarMode))
    {
        return PLUGIN_HANDLED
    }
    if((!CTNum || !TNum) && ALLNum && get_pcvar_num(PcvarMode) != 2)
    {
        set_pcvar_num(PcvarMode, 2)
    }
    switch(get_pcvar_num(PcvarMode))
    {
        case 1:
        {
            formatex(Play, 127, "%s", CTMusic[random_num(0, CTNum-1)])
        }
        case 2:
        {
            formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
        }
        case 3:
        {
            new Randomizer = random_num(1, 2)
            switch(Randomizer)
            {
                case 1:
                {
                    formatex(Play, 127, "%s", CTMusic[random_num(0, CTNum-1)])
                }
                case 2:
                {
                    formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
                }
            }
        }
        case 4:
        {
            new Randomizer = random_num(1, 3)
            switch(Randomizer)
            {
                case 1:
                {
                    formatex(Play, 127, "%s", CTMusic[random_num(0, CTNum-1)])
                }
                case 2:
                {
                    formatex(Play, 127, "%s", TMusic[random_num(0, TNum-1)])
                }
                case 3:
                {
                    formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
                }
            }
        }
    }
    if(containi(Play, ".wav") != -1)
    {
        formatex(PlayCommand, 127, "spk %s", Play)
    }
    else if(containi(Play, ".mp3") != -1)
    {
        formatex(PlayCommand, 127, "mp3 play sound/%s", Play)
    }
    else
    {
        log_amx("Unsupported file type <%s>", PLUGIN, Play)
        return PLUGIN_HANDLED
    }
    for(new id = 0; id <= get_maxplayers(); id++)
    {
        if(!is_user_connected(id) || !Ermon[id])
        {
            continue
        }
        client_cmd(id, "stopsound")
        client_cmd(id, "%s", PlayCommand)
        if(get_pcvar_num(PcvarRadio))
        {
            client_cmd(id, "spk radio/ctwin")
        }
    }
    return PLUGIN_HANDLED
}

public cmd_ermon(id)
{
    Ermon[id] = true
    client_cmd(id, "mp3volume %f", get_pcvar_float(PcvarVol))
    client_cmd(id, "spk vox/activated")
    green_print(id, "ERMON_MSG")
    return PLUGIN_CONTINUE
}


public cmd_ermoff(id)
{
    Ermon[id] = false
    client_cmd(id, "mp3 stop")
    client_cmd(id, "spk vox/deactivated")
    green_print(id, "ERMOFF_MSG")
    return PLUGIN_CONTINUE
}

public showerminfo(id)
{
    Ermon[id] = true
    client_cmd(id, "mp3volume %f", get_pcvar_float(PcvarVol))
    green_print(id, "ERMINFO_MSG")
}

stock green_print(index, const message[])
{
    new finalmsg[192];
    formatex(finalmsg, 191, "^x04[ERM] ^x01%L", index, message);
    message_begin(MSG_ONE, SayText, _, index);
    write_byte(index);
    write_string(finalmsg);
    message_end();
}

Код:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "End Round Music"
#define VERSION "2.0"
#define AUTHOR "Sho0ter"

#define TRACKSNUM 100

new ALLMusic[TRACKSNUM][128]
new CTMusic[TRACKSNUM][128]
new TMusic[TRACKSNUM][128]
new DRAWMusic[TRACKSNUM][128]

new PlaylistSize
new CTNum
new TNum
new DRAWNum                         
new ALLNum
new SayText

new Mode[32]
new Configsdir[64]
new CurrentMap[64]
new File[96]
new Playlist[128]
new Play[128]
new PlayCommand[128]
new CheckFile[128]

new bool:Ermon[33]

new PcvarMode
new PcvarVol
new PcvarRadio
new PcvarDelay

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_dictionary("endroundmusic.txt")
    register_event("SendAudio", "t_win", "a", "2&%!MRAD_terwin")
    register_event("SendAudio", "ct_win", "a", "2&%!MRAD_ctwin")
    register_event("SendAudio", "draw", "a", "2&%!MRAD_rounddraw")
    PcvarMode = register_cvar("erm_mode", "2")
    PcvarVol = register_cvar("erm_autovol", "1.0")
    PcvarRadio = register_cvar("erm_radio", "1")
    PcvarDelay = register_cvar("erm_delay", "20.0")
      register_clcmd("say /ermon", "cmd_ermon", 0, " - turn on end round music") 
      register_clcmd("say /ermoff", "cmd_ermoff", 0, " - turn off end round music") 
    SayText = get_user_msgid("SayText");
    return PLUGIN_CONTINUE
}

public plugin_precache()
{
    get_configsdir(Configsdir, 63)
    get_mapname(CurrentMap, 63)
    formatex(Playlist, 127, "%s/endroundmusic/%s.ini", Configsdir, CurrentMap)
    new Index = 0
    while(CurrentMap[Index] != '_' && CurrentMap[Index] != '^0')
    {
        Index++
    }
    if(!file_exists(Playlist) && CurrentMap[Index] == '_')
    {
        CurrentMap[Index] = '^0'
        formatex(Playlist, 127, "%s/endroundmusic/%s_.ini", Configsdir, CurrentMap)
    }
    if(!file_exists(Playlist))
    {
        formatex(Playlist, 127, "%s/endroundmusic/default.ini", Configsdir)
    }
    if(!file_exists(Playlist))
    {
        log_amx("Playlist <%s> not found.", Playlist)
        set_fail_state("Playlist not found")
        return PLUGIN_CONTINUE
    }
    PlaylistSize = file_size(Playlist, 1)
    for(new i = 0; i <= PlaylistSize; i++)
    {
        new Buffer[128], len, Result
        Result = read_file(Playlist, i, Buffer, sizeof(Buffer)-1, len)
        if(!Result)
        {
            continue
        }
        parse(Buffer, File, 95, Mode, 31)
        if(File[0] == ';' || File[0] == '/' || File[0] == ' ' || equal(File, ""))
        {
            continue
        }
        formatex(CheckFile, 127, "sound/%s", File)
        if(!file_exists(CheckFile))
        {
            log_amx("File not found <%s>", CheckFile)
            continue
        }
        if(equal(Mode, "CT"))
        {
            formatex(CTMusic[CTNum], 127, "%s", File)
            CTNum++
            precache_sound(File)
        }
        else if(equal(Mode, "TER"))
        {
            formatex(TMusic[TNum], 127, "%s", File)
            TNum++
            precache_sound(File)
        }
        else if(equal(Mode, "ALL"))
        {
            formatex(ALLMusic[ALLNum], 127, "%s", File)
            ALLNum++
            precache_sound(File)
        }
        else if(equal(Mode, "DRAW"))
        {
            formatex(ALLMusic[DRAWNum], 127, "%s", File)
            DRAWNum++
            precache_sound(File)
        }
        
    }
    if(CTNum == 0 && TNum == 0 && DRAWNum == 0 && ALLNum == 0)
    {
        log_amx("Not found tracks in playlist.")
        set_fail_state("Playlist empty")
        return PLUGIN_CONTINUE
    }
    log_amx("Loaded tracks: CT <%d> TER <%d> DRAW <%d> ALL <%d>", CTNum, TNum, DRAWNum, ALLNum)
    return PLUGIN_CONTINUE
}

public client_disconnect(id)
{
    remove_task(id)
    return PLUGIN_CONTINUE
}

public client_putinserver(id)
{
    set_task(get_pcvar_float(PcvarDelay), "showerminfo", id)
    return PLUGIN_HANDLED
}


public t_win()
{
    if(!get_pcvar_num(PcvarMode))
    {
        return PLUGIN_HANDLED
    }
    switch(get_pcvar_num(PcvarMode))
    {
        case 1:
        {
            formatex(Play, 127, "%s", TMusic[random_num(0, TNum-1)])
        }
        case 2:
        {
            formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
        }
        case 3:
        {
            new Randomizer = random_num(1, 2)
            switch(Randomizer)
            {
                case 1:
                {
                    formatex(Play, 127, "%s", TMusic[random_num(0, TNum-1)])
                }
                case 2:
                {
                    formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
                }
            }
        }
        case 4:
        {
            new Randomizer = random_num(1, 4)
            switch(Randomizer)
            {
                case 1:
                {
                    formatex(Play, 127, "%s", CTMusic[random_num(0, CTNum-1)])
                }
                case 2:
                {
                    formatex(Play, 127, "%s", TMusic[random_num(0, TNum-1)])
                }
                case 3:
                {
                    formatex(Play, 127, "%s", DRAWMusic[random_num(0, ALLNum-1)])
                }
                case 4:
                {
                    formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
                }
            }
        }
    }
    if(containi(Play, ".wav") != -1)
    {
        formatex(PlayCommand, 127, "spk %s", Play)
    }
    else if(containi(Play, ".mp3") != -1)
    {
        formatex(PlayCommand, 127, "mp3 play sound/%s", Play)
    }
    else
    {
        log_amx("Unsupported file type <%s>", Play)
        return PLUGIN_HANDLED
    }
    for(new id = 0; id <= get_maxplayers(); id++)
    {
        if(!is_user_connected(id) || !Ermon[id])
        {
            continue
        }
        client_cmd(id, "stopsound")
        client_cmd(id, "%s", PlayCommand)
        if(get_pcvar_num(PcvarRadio))
        {
            client_cmd(id, "spk radio/terwin")
        }
    }
    return PLUGIN_HANDLED
}


public ct_win()
{
    if(!get_pcvar_num(PcvarMode))
    {
        return PLUGIN_HANDLED
    }
    switch(get_pcvar_num(PcvarMode))
    {
        case 1:
        {
            formatex(Play, 127, "%s", CTMusic[random_num(0, CTNum-1)])
        }
        case 2:
        {
            formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
        }
        case 3:
        {
            new Randomizer = random_num(1, 2)
            switch(Randomizer)
            {
                case 1:
                {
                    formatex(Play, 127, "%s", CTMusic[random_num(0, CTNum-1)])
                }
                case 2:
                {
                    formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
                }
            }
        }
        case 4:
        {
            new Randomizer = random_num(1, 4)
            switch(Randomizer)
            {
                case 1:
                {
                    formatex(Play, 127, "%s", CTMusic[random_num(0, CTNum-1)])
                }
                case 2:
                {
                    formatex(Play, 127, "%s", TMusic[random_num(0, TNum-1)])
                }
                case 3:
                {
                    formatex(Play, 127, "%s", DRAWMusic[random_num(0, ALLNum-1)])
                }
                case 4:
                {
                    formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
                }
            }
        }
    }
    if(containi(Play, ".wav") != -1)
    {
        formatex(PlayCommand, 127, "spk %s", Play)
    }
    else if(containi(Play, ".mp3") != -1)
    {
        formatex(PlayCommand, 127, "mp3 play sound/%s", Play)
    }
    else
    {
        log_amx("Unsupported file type <%s>", PLUGIN, Play)
        return PLUGIN_HANDLED
    }
    for(new id = 0; id <= get_maxplayers(); id++)
    {
        if(!is_user_connected(id) || !Ermon[id])
        {
            continue
        }
        client_cmd(id, "stopsound")
        client_cmd(id, "%s", PlayCommand)
        if(get_pcvar_num(PcvarRadio))
        {
            client_cmd(id, "spk radio/ctwin")
        }
    }
    return PLUGIN_HANDLED
}


public draw()
{
    if(!get_pcvar_num(PcvarMode))
    {
        return PLUGIN_HANDLED
    }
    switch(get_pcvar_num(PcvarMode))
    {
        case 1:
        {
            formatex(Play, 127, "%s", DRAWMusic[random_num(0, CTNum-1)])
        }
        case 2:
        {
            formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
        }
        case 3:
        {
            new Randomizer = random_num(1, 2)
            switch(Randomizer)
            {
                case 1:
                {
                    formatex(Play, 127, "%s", DRAWMusic[random_num(0, CTNum-1)])
                }
                case 2:
                {
                    formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
                }
            }
        }
        case 4:
        {
            new Randomizer = random_num(1, 4)
            switch(Randomizer)
            {
                case 1:
                {
                    formatex(Play, 127, "%s", CTMusic[random_num(0, CTNum-1)])
                }
                case 2:
                {
                    formatex(Play, 127, "%s", TMusic[random_num(0, TNum-1)])
                }
                case 3:
                {
                    formatex(Play, 127, "%s", DRAWMusic[random_num(0, ALLNum-1)])
                }
                case 4:
                {
                    formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
                }
            }
        }
    }
    if(containi(Play, ".wav") != -1)
    {
        formatex(PlayCommand, 127, "spk %s", Play)
    }
    else if(containi(Play, ".mp3") != -1)
    {
        formatex(PlayCommand, 127, "mp3 play sound/%s", Play)
    }
    else
    {
        log_amx("Unsupported file type <%s>", PLUGIN, Play)
        return PLUGIN_HANDLED
    }
    for(new id = 0; id <= get_maxplayers(); id++)
    {
        if(!is_user_connected(id) || !Ermon[id])
        {
            continue
        }
        client_cmd(id, "stopsound")
        client_cmd(id, "%s", PlayCommand)
        if(get_pcvar_num(PcvarRadio))
        {
            client_cmd(id, "spk radio/rounddraw")
        }
    }
    return PLUGIN_HANDLED
}



public cmd_ermon(id)
{
    Ermon[id] = true
    client_cmd(id, "mp3volume %f", get_pcvar_float(PcvarVol))
    client_cmd(id, "spk vox/activated")
    green_print(id, "ERMON_MSG")
    return PLUGIN_CONTINUE
}


public cmd_ermoff(id)
{
    Ermon[id] = false
    client_cmd(id, "mp3 stop")
    client_cmd(id, "spk vox/deactivated")
    green_print(id, "ERMOFF_MSG")
    return PLUGIN_CONTINUE
}

public showerminfo(id)
{
    Ermon[id] = true
    client_cmd(id, "mp3volume %f", get_pcvar_float(PcvarVol))
    green_print(id, "ERMINFO_MSG")
}

stock green_print(index, const message[])
{
    new finalmsg[192];
    formatex(finalmsg, 191, "^x04[ERM] ^x01%L", index, message);
    message_begin(MSG_ONE, SayText, _, index);
    write_byte(index);
    write_string(finalmsg);
    message_end();
}
 
Сообщения
119
Реакции
53
Помог
4 раз(а)
wopox1337, Да я думал об этом просто не мог найти как подсветить строки которые изменил я их выделил другим цветом но подсветка синтаксиса всё перекрасила как ей надо.
 
Сообщения
2,750
Реакции
3,013
Помог
61 раз(а)
Sleedney, пара ошибок есть, но в целом, если ты добавил код по подобию имеющегося - и смотреть толком нечего. Априори код старый, из тех времён, когда писали, как могли, а не как лучше ибо инструментов не было.
 
Сообщения
119
Реакции
53
Помог
4 раз(а)
wopox1337, Хорошо , Второе предложение для меня менее информативное.
 
Сообщения
119
Реакции
53
Помог
4 раз(а)
Так вроде бы без ошибок. Осталось проверить на работоспособность и перевести на современный код. Буду обучаться дальше. )

C++:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "End Round Music"
#define VERSION "2.0"
#define AUTHOR "Sho0ter"

#define TRACKSNUM 100

new ALLMusic[TRACKSNUM][128]
new CTMusic[TRACKSNUM][128]
new TMusic[TRACKSNUM][128]
new DRAWMusic[TRACKSNUM][128]

new PlaylistSize
new CTNum
new TNum
new DRAWNum
new ALLNum
new SayText

new Mode[32]
new Configsdir[64]
new CurrentMap[64]
new File[96]
new Playlist[128]
new Play[128]
new PlayCommand[128]
new CheckFile[128]

new bool:Ermon[33]

new PcvarMode
new PcvarVol
new PcvarRadio
new PcvarDelay

public plugin_init() 
{ 
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_dictionary("endroundmusic.txt")
    register_event("SendAudio", "t_win", "a", "2&%!MRAD_terwin")
    register_event("SendAudio", "ct_win", "a", "2&%!MRAD_ctwin")
    register_event("SendAudio", "draw", "a", "2&%!MRAD_rounddraw") 
    PcvarMode = register_cvar("erm_mode", "2")
    PcvarVol = register_cvar("erm_autovol", "1.0")
    PcvarRadio = register_cvar("erm_radio", "1")
    PcvarDelay = register_cvar("erm_delay", "20.0")
    register_clcmd("say /ermon", "cmd_ermon", 0, " - turn on end round music")  
    register_clcmd("say /ermoff", "cmd_ermoff", 0, " - turn off end round music")  
    SayText = get_user_msgid("SayText");
    return PLUGIN_CONTINUE
}

public plugin_precache() 
{
    get_configsdir(Configsdir, 63)
    get_mapname(CurrentMap, 63)
    formatex(Playlist, 127, "%s/endroundmusic/%s.ini", Configsdir, CurrentMap)
    new Index = 0
    while(CurrentMap[Index] != '_' && CurrentMap[Index] != '^0')
    {
        Index++
    }
    if(!file_exists(Playlist) && CurrentMap[Index] == '_')
    {
        CurrentMap[Index] = '^0'
        formatex(Playlist, 127, "%s/endroundmusic/%s_.ini", Configsdir, CurrentMap)
    }
    if(!file_exists(Playlist))
    {
        formatex(Playlist, 127, "%s/endroundmusic/default.ini", Configsdir)
    }
    if(!file_exists(Playlist))
    {
        log_amx("Playlist <%s> not found.", Playlist)
        set_fail_state("Playlist not found")
        return PLUGIN_CONTINUE
    }
    PlaylistSize = file_size(Playlist, 1)
    for(new i = 0; i <= PlaylistSize; i++)
    {
        new Buffer[128], len, Result
        Result = read_file(Playlist, i, Buffer, sizeof(Buffer)-1, len) 
        if(!Result)
        {
            continue
        }
        parse(Buffer, File, 95, Mode, 31)
        if(File[0] == ';' || File[0] == '/' || File[0] == ' ' || equal(File, ""))
        {
            continue
        }
        formatex(CheckFile, 127, "sound/%s", File)
        if(!file_exists(CheckFile))
        {
            log_amx("File not found <%s>", CheckFile)
            continue
        }
        if(equal(Mode, "CT"))
        {
            formatex(CTMusic[CTNum], 127, "%s", File)
            CTNum++
            precache_sound(File)
        }
        else if(equal(Mode, "TER"))
        {
            formatex(TMusic[TNum], 127, "%s", File)
            TNum++
            precache_sound(File)
        }
        else if(equal(Mode, "DRAW"))
        {
            formatex(DRAWMusic[DRAWNum], 127, "%s", File)
            DRAWNum++
            precache_sound(File)
        }
        else if(equal(Mode, "ALL"))
        {
            formatex(ALLMusic[ALLNum], 127, "%s", File)
            ALLNum++
            precache_sound(File)
        }
        
    }
    if(CTNum == 0 && TNum == 0 && DRAWNum == 0 && ALLNum == 0)
    {
        log_amx("Not found tracks in playlist.")
        set_fail_state("Playlist empty")
        return PLUGIN_CONTINUE
    }
    log_amx("Loaded tracks: CT <%d> TER <%d> DRAW <%d> ALL <%d>", CTNum, TNum, DRAWNum, ALLNum)
    return PLUGIN_CONTINUE
}

public client_disconnect(id) 
{
    remove_task(id)
    return PLUGIN_CONTINUE
}

public client_putinserver(id) 
{
    set_task(get_pcvar_float(PcvarDelay), "showerminfo", id)
    return PLUGIN_HANDLED
}


public t_win()
{
    if(!get_pcvar_num(PcvarMode))
    {
        return PLUGIN_HANDLED
    }
    switch(get_pcvar_num(PcvarMode))
    {
        case 1:
        {
            formatex(Play, 127, "%s", TMusic[random_num(0, TNum-1)])
        }
        case 2:
        {
            formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
        }
        case 3:
        {
            new Randomizer = random_num(1, 2)
            switch(Randomizer)
            {
                case 1:
                {
                    formatex(Play, 127, "%s", TMusic[random_num(0, TNum-1)])
                }
                case 2:
                {
                    formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
                }
            }
        }
        case 4:
        {
            new Randomizer = random_num(1, 4)
            switch(Randomizer)
            {
                case 1:
                {
                    formatex(Play, 127, "%s", CTMusic[random_num(0, CTNum-1)])
                }
                case 2:
                {
                    formatex(Play, 127, "%s", TMusic[random_num(0, TNum-1)])
                }
                case 3:
                {
                    formatex(Play, 127, "%s", DRAWMusic[random_num(0, DRAWNum-1)])
                }
                case 4:
                {
                    formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
                }
            }
        }
    }
    if(containi(Play, ".wav") != -1)
    {
        formatex(PlayCommand, 127, "spk %s", Play)
    }
    else if(containi(Play, ".mp3") != -1)
    {
        formatex(PlayCommand, 127, "mp3 play sound/%s", Play)
    }
    else
    {
        log_amx("Unsupported file type <%s>", Play)
        return PLUGIN_HANDLED
    }
    for(new id = 0; id <= get_maxplayers(); id++)
    {
        if(!is_user_connected(id) || !Ermon[id])
        {
            continue
        }
        client_cmd(id, "stopsound")
        client_cmd(id, "%s", PlayCommand)
        if(get_pcvar_num(PcvarRadio))
        {
            client_cmd(id, "spk radio/terwin")
        }
    }
    return PLUGIN_HANDLED
}


public ct_win()
{
    if(!get_pcvar_num(PcvarMode))
    {
        return PLUGIN_HANDLED
    }
    switch(get_pcvar_num(PcvarMode))
    {
        case 1:
        {
            formatex(Play, 127, "%s", CTMusic[random_num(0, CTNum-1)])
        }
        case 2:
        {
            formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
        }
        case 3:
        {
            new Randomizer = random_num(1, 2)
            switch(Randomizer)
            {
                case 1:
                {
                    formatex(Play, 127, "%s", CTMusic[random_num(0, CTNum-1)])
                }
                case 2:
                {
                    formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
                }
            }
        }
        case 4:
        {
            new Randomizer = random_num(1, 4)
            switch(Randomizer)
            {
                case 1:
                {
                    formatex(Play, 127, "%s", CTMusic[random_num(0, CTNum-1)])
                }
                case 2:
                {
                    formatex(Play, 127, "%s", TMusic[random_num(0, TNum-1)])
                }
                case 3:
                {
                    formatex(Play, 127, "%s", DRAWMusic[random_num(0, DRAWNum-1)])
                }
                case 4:
                {
                    formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
                }
            }
        }
    }
    if(containi(Play, ".wav") != -1)
    {
        formatex(PlayCommand, 127, "spk %s", Play)
    }
    else if(containi(Play, ".mp3") != -1)
    {
        formatex(PlayCommand, 127, "mp3 play sound/%s", Play)
    }
    else
    {
        log_amx("Unsupported file type <%s>", PLUGIN, Play)
        return PLUGIN_HANDLED
    }
    for(new id = 0; id <= get_maxplayers(); id++)
    {
        if(!is_user_connected(id) || !Ermon[id])
        {
            continue
        }
        client_cmd(id, "stopsound")
        client_cmd(id, "%s", PlayCommand)
        if(get_pcvar_num(PcvarRadio))
        {
            client_cmd(id, "spk radio/ctwin")
        }
    }
    return PLUGIN_HANDLED
}


public draw()
{
    if(!get_pcvar_num(PcvarMode))
    {
        return PLUGIN_HANDLED
    }
    switch(get_pcvar_num(PcvarMode))
    {
        case 1:
        {
            formatex(Play, 127, "%s", DRAWMusic[random_num(0, DRAWNum-1)])
        }
        case 2:
        {
            formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
        }
        case 3:
        {
            new Randomizer = random_num(1, 2)
            switch(Randomizer)
            {
                case 1:
                {
                    formatex(Play, 127, "%s", DRAWMusic[random_num(0, DRAWNum-1)])
                }
                case 2:
                {
                    formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
                }
            }
        }
        case 4:
        {
            new Randomizer = random_num(1, 4)
            switch(Randomizer)
            {
                case 1:
                {
                    formatex(Play, 127, "%s", CTMusic[random_num(0, CTNum-1)])
                }
                case 2:
                {
                    formatex(Play, 127, "%s", TMusic[random_num(0, TNum-1)])
                }
                case 3:
                {
                    formatex(Play, 127, "%s", DRAWMusic[random_num(0, DRAWNum-1)])
                }
                case 4:
                {
                    formatex(Play, 127, "%s", ALLMusic[random_num(0, ALLNum-1)])
                }
            }
        }
    }
    if(containi(Play, ".wav") != -1)
    {
        formatex(PlayCommand, 127, "spk %s", Play)
    }
    else if(containi(Play, ".mp3") != -1)
    {
        formatex(PlayCommand, 127, "mp3 play sound/%s", Play)
    }
    else
    {
        log_amx("Unsupported file type <%s>", PLUGIN, Play)
        return PLUGIN_HANDLED
    }
    for(new id = 0; id <= get_maxplayers(); id++)
    {
        if(!is_user_connected(id) || !Ermon[id])
        {
            continue
        }
        client_cmd(id, "stopsound")
        client_cmd(id, "%s", PlayCommand)
        if(get_pcvar_num(PcvarRadio))
        {
            client_cmd(id, "spk radio/rounddraw")
        }
    }
    return PLUGIN_HANDLED
}



public cmd_ermon(id)
{
    Ermon[id] = true
    client_cmd(id, "mp3volume %f", get_pcvar_float(PcvarVol))
    client_cmd(id, "spk vox/activated")
    green_print(id, "ERMON_MSG")
    return PLUGIN_CONTINUE
}


public cmd_ermoff(id)
{
    Ermon[id] = false
    client_cmd(id, "mp3 stop")
    client_cmd(id, "spk vox/deactivated")
    green_print(id, "ERMOFF_MSG")
    return PLUGIN_CONTINUE
}

public showerminfo(id)
{
    Ermon[id] = true
    client_cmd(id, "mp3volume %f", get_pcvar_float(PcvarVol))
    green_print(id, "ERMINFO_MSG")
}

stock green_print(index, const message[])
{
    new finalmsg[192];
    formatex(finalmsg, 191, "^x04[ERM] ^x01%L", index, message);
    message_begin(MSG_ONE, SayText, _, index);
    write_byte(index);
    write_string(finalmsg);
    message_end();
}

}
 
Сообщения
1,697
Реакции
1,510
Помог
25 раз(а)
Не знал до чего докапаться, давай хоть до скобки на 441 строке.
 
Сообщения
119
Реакции
53
Помог
4 раз(а)
fl0wer, на больное не дави копипастил одно и то же 2 раза остаток не удалил до конца. Скобка как память о прошлом.
 
Сообщения
1
Реакции
0
У меня вопросик, можно такие условия использовать? if (x>y>z)
 

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу