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

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

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

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

7 страниц V  « 5 6 7

Ограничить покупку модов ( Zombie Plague Advanced )

, Во времени ( ночное ) / через 1 раунд / через 1 карту
Статус пользователя Slackerok
сообщение 11.4.2013, 0:03
Сообщение #101
Стаж: 16 лет

Сообщений: 187
Благодарностей: 20
Полезность: 12

mazdan, Здравствуйте! Сегодня протестил плагин) Результат хороший) Только можно покупать сколько угодно модов ( мне нужно только 1 ) а на следующей карте уже запрещает как и надо было...

Надеюсь я правельно понял то что нужно изменить:

lastmap_purchase
Код
#include <amxmodx>
#include <amxmisc>
#include <zombie_plague_advance>

new Trie:g_t_purchase_map;

public plugin_init()
{
    register_plugin("Lastmap Purchase","1","mazdan & Nickk & Slackerok")
    
    g_t_purchase_map = TrieCreate()
    
    set_task(0.3,"read_purchase_file",128)
}

public plugin_natives()
{
    register_native("zp_user_buy_item", "native_buy", 1)
    register_native("zp_user_buy_on_lastmap", "native_lastmap", 1)
}

public native_buy(id)
{
    new ip[16]
    get_user_ip(id,ip,15,1)
    write_file("lastmap_purchases.TXT",ip,-1)
    log_amx("%s added to file",ip)
}

public native_lastmap(id)
{
    static ip[16]
    get_user_ip(id,ip,15,1)
    return TrieKeyExists(g_t_purchase_map,ip)
}

public read_purchase_file()
{
    new i_file=fopen("lastmap_purchases.TXT","rt")
    
    if(!i_file)
    {
        return PLUGIN_CONTINUE
    }
    
    new s_buffer[64]

    while(!feof(i_file))
    {
        fgets(i_file,s_buffer,127)

        trim(s_buffer)

        TrieSetCell(g_t_purchase_map,s_buffer,1)
    }
    fclose(i_file)
    delete_file("lastmap_purchases.TXT")

    return PLUGIN_CONTINUE
}
zp_buy_sniper
Код
#include <amxmodx>
#include <zombieplaguenew1.3>

#define PLUGIN "[ZP] Extra Item: Become Sniper"
#define VERSION "0.0.1"
#define AUTHOR "none"

new g_sniper
new g_msgSayText
new g_maxplayers

new pcvar_enabled, pcvar_cost, pcvar_hudtime
new restricted
native zp_is_restricted()
native zp_user_buy_item(id)
native zp_user_buy_on_lastmap(id)

public plugin_init()
{
    register_plugin( PLUGIN, VERSION, AUTHOR )
    
    pcvar_enabled = register_cvar( "zp_sniper_buy", "1" )
    pcvar_cost = register_cvar( "zp_sniper_cost", "170" )
    pcvar_hudtime = register_cvar( "zp_sniper_hudtime", "2.0" )
    
    g_sniper = zp_register_extra_item( "Sniper", get_pcvar_num( pcvar_cost ) , ZP_TEAM_HUMAN )

    g_maxplayers = get_maxplayers()
    g_msgSayText = get_user_msgid( "SayText" )

    register_cvar( "zp_extra_sniper", VERSION, FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY )
}

public zp_extra_item_selected( id, item )
{
    if( !get_pcvar_num( pcvar_enabled ) )
        return PLUGIN_HANDLED
    
    if( item == g_sniper )
    {
        if( zp_has_round_started() )
        {
            colored_print( id, "^x04[ZP]^x01 You must buy a Sniper before the round start!" )
            return ZP_PLUGIN_HANDLED
        }

        restricted = zp_is_restricted()

                if(restricted == 1 )    
                {
                           colored_print( id, "^x04[ZP]^x01 This mod allowed to buy only from ^x04[10.00]^x01 to ^x04[22.00]^x01 PM!" )
                    return ZP_PLUGIN_HANDLED
                }
        if(restricted == 2 )
        {
                   colored_print( id, "^x04[ZP]^x01 You can buy this mod after clean ( ^x04Infection^x01 ) Round!" )
                    return ZP_PLUGIN_HANDLED
        }
                
                if(zp_user_buy_on_lastmap(id))    
                {
                           colored_print( id, "^x04[ZP]^x01 You allowed to buy 1 mod per 2 maps." )
                    return ZP_PLUGIN_HANDLED
                }

        zp_user_buy_item(id)

        zp_make_user_sniper( id )

        colored_print( id, "^x04[ZP]^x01 became a Sniper!" )

        set_task( get_pcvar_float( pcvar_hudtime ), "sniper_message", id )
    }
    return PLUGIN_HANDLED
}

public sniper_message( id )
{
    new szName[ 32 ]
    get_user_name( id, szName, 31 )
    set_hudmessage( 255, 0, 0, 0.05, 0.45, 1, 0.0, 5.0, 1.0, 1.0, -1 )
    show_hudmessage( 0, "%s buy Sniper!", szName )
}

stock colored_print( target, const message[],  any:... )
{
    static buffer[ 512 ]

    if( !target )
    {
        static player
        for( player = 1; player <= g_maxplayers; player++ )
        {
            if ( !is_user_connected( player ) )
                continue;
            
            vformat( buffer, charsmax( buffer ), message, 3 )
            
            message_begin( MSG_ONE_UNRELIABLE, g_msgSayText, _, player )
            write_byte( player )
            write_string( buffer )
            message_end()
        }
    }

    else
    {
        vformat( buffer, charsmax( buffer ), message, 3 )
        
        message_begin( MSG_ONE, g_msgSayText, _, target )
        write_byte( target )
        write_string( buffer )
        message_end()
    }
}

Доброй ночи)

Отредактировал: Slackerok, - 11.4.2013, 0:47
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя Slackerok
сообщение 12.4.2013, 12:11
Сообщение #102
Стаж: 16 лет

Сообщений: 187
Благодарностей: 20
Полезность: 12

mazdan, Здравствуйте! Помогите еще раз с задачей а то никак не получается занести ИП сразу после покупки в TrieSetCell

Цитата(mazda)
Тогда там где пишем в файл этот же айпи нужно положить в Trie массив - TrieSetCell


Чтобы работал только 1 мод на 2 карты, я думаю нужно сделать именно так) Пробовал:

Код
public native_buy(id)
{
    new ip[16]
    get_user_ip(id,ip,15,1)
    write_file("lastmap_purchases.txt",ip,-1)
    TrieSetCell(id,ip,15,1)
    log_amx("%s added to file",ip)
}


Но это неправильно pardon.gif
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя mazdan
сообщение 12.4.2013, 13:14
Сообщение #103


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

Стаж: 15 лет

Сообщений: 7566
Благодарностей: 5437
Полезность: 1305

TrieSetCell(id,ip,1) надо. 15 лишняя
ну и лог можно убрать


Не пишите мне в ЛС. Пишите на почту. В ЛС я пропускаю сообщения.
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
Поблагодарили 1 раз
   + Цитировать сообщение
Статус пользователя Slackerok
сообщение 12.4.2013, 14:17
Сообщение #104
Стаж: 16 лет

Сообщений: 187
Благодарностей: 20
Полезность: 12

mazdan, Спасибо, теперь компилится, однако результат тот же, могу купить больше чем один мод на первой карте. На следующей карте запрещает как и надо, но вот на предыдущей мне надо сразу после одной покупки, при повторном действии плагин среагировал этим:
Код
if(zp_user_buy_on_lastmap(id))    
                {
                           colored_print( id, "^x04[ZP]^x01 You allowed to buy 1 mod per 2 maps." )
                    return ZP_PLUGIN_HANDLED
                }


Может добавить действие в буфер?
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя mazdan
сообщение 12.4.2013, 16:55
Сообщение #105


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

Стаж: 15 лет

Сообщений: 7566
Благодарностей: 5437
Полезность: 1305

Slackerok, так и должно работать.


UPD: а, вижу
Код
TrieSetCell(g_t_purchase_map,ip,1)


Не пишите мне в ЛС. Пишите на почту. В ЛС я пропускаю сообщения.
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
Поблагодарили 1 раз
   + Цитировать сообщение
Статус пользователя Slackerok
сообщение 12.4.2013, 17:42
Сообщение #106
Стаж: 16 лет

Сообщений: 187
Благодарностей: 20
Полезность: 12

mazdan, win.gif Все работает как надо !!! win.gif Хотел отблагодарить вас за оказанную помощь, хорошую работу проделали =) ! С меня горячая сауна, холодное пиво, таранка и пару девок :D
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя mazdan
сообщение 12.4.2013, 18:45
Сообщение #107


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

Стаж: 15 лет

Сообщений: 7566
Благодарностей: 5437
Полезность: 1305

ну вы и сами начали вникать, что к чему про TrieSetCell догадались же.
Если писать в редакторе нормальном то он синтаксис вам бы подсказал. Notepad++ можно этому обучить, например. Очень удобно.
Я просто на id сначала внимания не обратил =) Там всё просто 1- указатель на Trie массив - какой использовать. Второй - адрес ячейки (у нас это айпи) и третий это значение, которое в ячейку положить. Так как нам не важно то 1. В дальнейшем это расширить можно будет и класть, например, туда идентификатор купленного мода или что там покупается :D


Не пишите мне в ЛС. Пишите на почту. В ЛС я пропускаю сообщения.
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
Поблагодарили 1 раз
   + Цитировать сообщение
Статус пользователя Slackerok
сообщение 12.4.2013, 20:06
Сообщение #108
Стаж: 16 лет

Сообщений: 187
Благодарностей: 20
Полезность: 12

mazdan, Ну я думаю для покупок будет лишнее записывать идентификаторы или названия, простое решение: купил->записал->запретил устраивает вполне) Однако для расширения своих знании, можно попробовать расширить)

У вас еще будет время чуток помочь с остальными плагинами? :D Остались недоделанным запрет 3 модов, для них нету переменных в:

g_notcleanround = (g_nemround || g_survround || g_swarmround || g_plagueround || g_sniperround ||g_assassinround || g_lnjround)

Моды: Multi Infection, Nightmare Mod, Assassins vs Snipers Mod

Не подскажете что можно сделать в этом случае?

Еще от главного плагина долбит почти каждый день этот error. Мне 2-3 года назад пофиксили плагин от какой-то критичной ошибки, сервер от нее помню падал. Но остался error этот... Посмотрите пожалуйста:

Ошибка
L 04/07/2013 - 13:01:57: [AMXX] [0] zombie_plague_advance_v1-6-1.sma::fm_cs_get_current_weapon_ent (line 13054)
L 04/07/2013 - 13:01:57: [AMXX] [1] zombie_plague_advance_v1-6-1.sma::message_cur_weapon (line 5718)
L 04/07/2013 - 13:02:04: [CSTRIKE] Non-player entity -1 out of range
L 04/07/2013 - 13:02:04: [AMXX] Displaying debug trace (plugin "zombie_plague_advance_v1-6-1.amxx")
L 04/07/2013 - 13:02:04: [AMXX] Run time error 10: native error (native "cs_set_weapon_ammo")
L 04/07/2013 - 13:02:04: [AMXX] [0] zombie_plague_advance_v1-6-1.sma::fm_cs_get_current_weapon_ent (line 13054)
L 04/07/2013 - 13:02:04: [AMXX] [1] zombie_plague_advance_v1-6-1.sma::message_cur_weapon (line 5718)
L 04/07/2013 - 13:02:13: [CSTRIKE] Non-player entity -1 out of range
L 04/07/2013 - 13:02:13: [AMXX] Displaying debug trace (plugin "zombie_plague_advance_v1-6-1.amxx")
L 04/07/2013 - 13:02:13: [AMXX] Run time error 10: native error (native "cs_set_weapon_ammo")


Отредактировал: Slackerok, - 12.4.2013, 20:14
Прикрепленные файлы:
Прикрепленный файл  zombie_plague_advance_v1_6_1.sma ( 411,04 килобайт ) Кол-во скачиваний: 6
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя mazdan
сообщение 13.4.2013, 5:50
Сообщение #109


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

Стаж: 15 лет

Сообщений: 7566
Благодарностей: 5437
Полезность: 1305

ну из того что я увидел там как минимум попробуйте заменить
Код
if (pev_valid(weapon)) cs_set_weapon_ammo(fm_cs_get_current_weapon_ent(msg_entity), MAXCLIP[weapon])

Код
if (pev_valid(weapon))
{
  static pl_id
  pl_id = fm_cs_get_current_weapon_ent(msg_entity)
  if(pl_id > 0) cs_set_weapon_ammo(id, MAXCLIP[weapon])
}


Не пишите мне в ЛС. Пишите на почту. В ЛС я пропускаю сообщения.
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
Поблагодарили 1 раз
   + Цитировать сообщение
Статус пользователя Slackerok
сообщение 13.4.2013, 19:35
Сообщение #110
Стаж: 16 лет

Сообщений: 187
Благодарностей: 20
Полезность: 12

mazdan, Здравствуйте! Сейчас попробовал скомпилировать, но выдает ошибку:
Error
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя mazdan
сообщение 13.4.2013, 20:49
Сообщение #111


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

Стаж: 15 лет

Сообщений: 7566
Благодарностей: 5437
Полезность: 1305

вместо id надо pl_id видимо =)


Не пишите мне в ЛС. Пишите на почту. В ЛС я пропускаю сообщения.
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
Поблагодарили 1 раз
   + Цитировать сообщение
Статус пользователя Slackerok
сообщение 13.4.2013, 20:52
Сообщение #112
Стаж: 16 лет

Сообщений: 187
Благодарностей: 20
Полезность: 12

Вы имеете в виду здесь?

if(pl_id > 0) cs_set_weapon_ammo(pl_id, MAXCLIP[weapon])

Отредактировал: Slackerok, - 13.4.2013, 20:52
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя Slackerok
сообщение 13.4.2013, 21:38
Сообщение #113
Стаж: 16 лет

Сообщений: 187
Благодарностей: 20
Полезность: 12

Скомпилировался! Поставил на основной, будем ждать результатов) Спасибо вам огромное!
Теперь осталось доделать плагин с запретами этих 3 модов... Переменные для ихнего определения я не знаю как создавать pardon.gif
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя mazdan
сообщение 13.4.2013, 21:46
Сообщение #114


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

Стаж: 15 лет

Сообщений: 7566
Благодарностей: 5437
Полезность: 1305

new :) чего тут знать :D так же как и остальные - по образу и подобию =)


Не пишите мне в ЛС. Пишите на почту. В ЛС я пропускаю сообщения.
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
Поблагодарили 1 раз
   + Цитировать сообщение
Статус пользователя Slackerok
сообщение 13.4.2013, 22:38
Сообщение #115
Стаж: 16 лет

Сообщений: 187
Благодарностей: 20
Полезность: 12

mazdan, начинаются мучения? :D

Добавить просто new g_assvssnip и new g_nightmare в плагинов не даст результатов =) Need some impulse :D
mod_assassins_vs_snipers
Код
#include < amxmodx >
#include < fun >
#include < zombie_plague_advance >

/******************************
******************************\
|                  Customizations Section                    |
|         You can edit here according to your liking         |
\*************************
******************************
*
****/

// This is the chance value according to which this game mode will be called
// The higher the value the lesser the chance of calling this game mode
new const g_chance = 30

// This is the access flag required to start the game mode
// through the admin menu. Look in users.ini for more details
new const g_access_flag[] = "r"

// This is the sound which is played when the game mode is triggered
// Add as many as you want [Randomly chosen if more than one]
new const g_play_sounds[][] =
{
    "zombie_plague/armaged_2012_1.wav"
}

// Comment the following line to disable ambience sounds
// Just add two slashes ( // )
#define AMBIENCE_SOUNDS

#if defined AMBIENCE_SOUNDS
// Ambience Sounds (only .wav and .mp3 formats supported)
// Add as many as you want [Randomly chosen if more than one]
new const g_sound_ambience[][] =
{
    "zombie_plague/aq13_official_soundtrack.wav"
}

// Duration in seconds of each sound
new const Float:g_sound_ambience_duration[] = { 28.0 , 267.0 }
#endif

/******************************
******************************\
|                  Customizations Ends Here..!!              |
|         You can edit the cvars in the plugin init          |
\*************************
******************************
*
****/

// Variables
new g_gameid, g_maxplayers, cvar_minplayers, cvar_ratio, cvar_sniperhp, cvar_assahp, g_msg_sync

new g_assvssnip // Переменная для определения раунда

// Ambience sounds task
#define TASK_AMB 3256

public plugin_init( )
{
    // Plugin registeration.
    register_plugin( "[ZP] Assassin vs Snipers Mode","1.0", "@bdul!" )
    
    // Register some cvars
    // Edit these according to your liking
    cvar_minplayers = register_cvar("zp_avsm_minplayers", "16")
    cvar_sniperhp =      register_cvar("zp_avsm_sniper_hp", "1")
    cvar_assahp =      register_cvar("zp_avsm_assassin_hp", "2")
    cvar_ratio =       register_cvar("zp_avsm_inf_ratio", "0.5")
    
    // Get maxplayers
    g_maxplayers = get_maxplayers( )
    
    // Hud stuff
    g_msg_sync = CreateHudSyncObj()
}

// Game modes MUST be registered in plugin precache ONLY
public plugin_precache( )
{
    // Read the access flag
    new access_flag = read_flags( g_access_flag )
    new i
    
    // Precache the play sounds
    for (i = 0; i < sizeof g_play_sounds; i++)
        precache_sound( g_play_sounds[i] )
    
    // Precache the ambience sounds
    #if defined AMBIENCE_SOUNDS
    new sound[100]
    for (i = 0; i < sizeof g_sound_ambience; i++)
    {
        if (equal(g_sound_ambience[i][strlen(g_sound_ambience[i])-4], ".mp3"))
        {
            formatex(sound, sizeof sound - 1, "sound/%s", g_sound_ambience[i])
            precache_generic( sound )
        }
        else
        {
            precache_sound( g_sound_ambience[i] )
        }
    }
    #endif
    
    // Register our game mode
    g_gameid = zp_register_game_mode( "Assassin vs Snipers Mode", access_flag, g_chance, 0, ZP_DM_BALANCE )
}

// Player spawn post
public zp_player_spawn_post( id )
{
    // Check for current mode
    if( zp_get_current_mode() == g_gameid )
    {
        // Check if the player is a zombie
        if( zp_get_user_zombie( id ))
        {
            // Make him an assassin instead
            zp_make_user_sniper( id )
            
            // Set his health
            set_user_health( id, floatround(get_user_health(id) * get_pcvar_float(cvar_sniperhp)) )
        }
        else
        {
            // Make him a sniper
            zp_make_user_sniper( id )
            
            // Set his health
            set_user_health( id, floatround(get_user_health(id) * get_pcvar_float(cvar_sniperhp)) )
        }
    }
}

public zp_round_started_pre( game )
{
    // Check if it is our game mode
    if( game == g_gameid )
    {
        // Check for min players
        if( fn_get_alive_players() < get_pcvar_num(cvar_minplayers) )
        {
            /**
             * Note:
             * This very necessary, you should return ZP_PLUGIN_HANDLED if
             * some conditions required by your game mode are not met
             * This will inform the main plugin that you have rejected
             * the offer and so the main plugin will allow other game modes
             * to be given a chance
             */
            return ZP_PLUGIN_HANDLED
        }
        // Start our new mode
        start_avs_mode( )
    }
    // Make the compiler happy =)
    return PLUGIN_CONTINUE
}

public zp_round_started( game, id )
{
    // Check if it is our game mode
    if( game == g_gameid )
    {
        // Show HUD notice
        set_hudmessage(221, 156, 21, -1.0, 0.17, 1, 0.0, 5.0, 1.0, 1.0, -1)
        ShowSyncHudMsg(0, g_msg_sync, "Assassins vs Snipers Mode !!!")
        
        // Play the starting sound
        client_cmd(0, "spk ^"%s^"", g_play_sounds[ random_num(0, sizeof g_play_sounds -1) ] )
        
        // Remove ambience task affects
        remove_task( TASK_AMB )
        
        // Set task to start ambience sounds
        #if defined AMBIENCE_SOUNDS
        set_task( 2.0, "start_ambience_sounds", TASK_AMB )
        #endif
    }
}

public zp_game_mode_selected( gameid, id )
{
    // Check if our game mode was called
    if( gameid == g_gameid )
        start_avs_mode( )
    
    // Make the compiler happy again =)
    return PLUGIN_CONTINUE
}

// This function contains the whole code behind this game mode
start_avs_mode( )
{
    // Create and initialize some important vars
    static i_assassins, i_max_assassins, id, i_alive
    i_alive = fn_get_alive_players()
    id = 0
    
    // Get the no of players we have to turn into assassins
    i_max_assassins = floatround( ( i_alive * get_pcvar_float( cvar_ratio ) ), floatround_ceil )
    i_assassins = 0
    
    // Randomly turn players into Assassins
    while (i_assassins < i_max_assassins)
    {
        // Keep looping through all players
        if ( (++id) > g_maxplayers) id = 1
        
        // Dead
        if ( !is_user_alive(id) )
            continue;
        
        // Random chance
        if (random_num(1, 5) == 1)
        {
            // Make user assassin
            zp_make_user_assassin(id)
            
            // Set his health
            set_user_health( id, floatround(get_user_health(id) * get_pcvar_float(cvar_assahp)) )
            
            // Increase counter
            i_assassins++
        }
    }
    
    // Turn the remaining players into snipers
    for (id = 1; id <= g_maxplayers; id++)
    {
        // Only those of them who are alive and are not assassins
        if ( !is_user_alive(id) || zp_get_user_assassin(id) )
            continue;
            
        // Turn into a sniper
        zp_make_user_sniper(id)
        
        // Set his health
        set_user_health( id, floatround(get_user_health(id) * get_pcvar_float(cvar_sniperhp)) )
    }
}

#if defined AMBIENCE_SOUNDS
public start_ambience_sounds( )
{
    // Variables
    static amb_sound[64], sound, Float:duration
    
    // Select our ambience sound
    sound = random_num( 0, sizeof g_sound_ambience - 1 )
    copy( amb_sound, sizeof amb_sound - 1 , g_sound_ambience[ sound ] )
    duration = g_sound_ambience_duration[ sound ]
    
    // Check whether it's a wav or mp3, then play it on clients
    if ( equal( amb_sound[ strlen( amb_sound ) - 4 ], ".mp3" ) )
        client_cmd( 0, "mp3 play ^"sound/%s^"", amb_sound )
    else
        client_cmd( 0, "spk ^"%s^"", sound )
    
    // Start the ambience sounds
    set_task( duration, "start_ambience_sounds", TASK_AMB )
}
public zp_round_ended( winteam )
{
    // Stop ambience sounds on round end
    remove_task( TASK_AMB )
}
#endif

// This function returns the no. of alive players
// Feel free to use this in your plugin when you
// are making your own game modes.
fn_get_alive_players( )
{
    static i_alive, id
    i_alive = 0
    
    for ( id = 1; id <= g_maxplayers; id++ )
    {
        if( is_user_alive( id ) )
            i_alive++
    }
    return i_alive;
}
mod_nightmare
Код
#include < amxmodx >
#include < fun >
#include < zombie_plague_advance >

/******************************
******************************\
|                  Customizations Section                    |
|         You can edit here according to your liking         |
\*************************
******************************
*
****/

// This is the chance value according to which this game mode will be called
// The higher the value the lesser the chance of calling this game mode
new const g_chance = 25

// This is the access flag required to start the game mode
// through the admin menu. Look in users.ini for more details
new const g_access_flag[] = "r"

// This is the sound which is played when the game mode is triggered
// Add as many as you want [Randomly chosen if more than one]
new const g_play_sounds[][] =
{
    "zombie_plague/armaged_2012_1.wav"
}

// Comment the following line to disable ambience sounds
// Just add two slashes ( // )
#define AMBIENCE_SOUNDS

#if defined AMBIENCE_SOUNDS
// Ambience Sounds (only .wav and .mp3 formats supported)
// Add as many as you want [Randomly chosen if more than one]
new const g_sound_ambience[][] =
{
    "zombie_plague/anarqia13_official_soundtrack.
wav"
}

// Duration in seconds of each sound
new const Float:g_sound_ambience_duration[] = { 28.0 , 267.0 }
#endif

/******************************
******************************\
|                  Customizations Ends Here..!!              |
|         You can edit the cvars in the plugin init          |
\*************************
******************************
*
****/

// Variables
new g_gameid, g_maxplayers, cvar_minplayers, g_msg_sync

new g_nightmare // Переменная для определения раунда

// Ambience sounds task
#define TASK_AMB 3256

public plugin_init( )
{
    // Plugin registeration.
    register_plugin( "[ZP] New Game Mode","1.0", "@bdul!" )
    
    // Register some cvars
    // Edit these according to your liking
    cvar_minplayers = register_cvar("zp_avsm_minplayers", "20")
    
    // Get maxplayers
    g_maxplayers = get_maxplayers( )
    
    // Hud stuff
    g_msg_sync = CreateHudSyncObj()
}

// Game modes MUST be registered in plugin precache ONLY
public plugin_precache( )
{
    // Read the access flag
    new access_flag = read_flags( g_access_flag )
    new i
    
    // Precache the play sounds
    for (i = 0; i < sizeof g_play_sounds; i++)
        precache_sound( g_play_sounds[i] )
    
    // Precache the ambience sounds
    #if defined AMBIENCE_SOUNDS
    new sound[100]
    for (i = 0; i < sizeof g_sound_ambience; i++)
    {
        if (equal(g_sound_ambience[i][strlen(g_sound_ambience[i])-4], ".mp3"))
        {
            formatex(sound, sizeof sound - 1, "sound/%s", g_sound_ambience[i])
            precache_generic( sound )
        }
        else
        {
            precache_sound( g_sound_ambience[i] )
        }
    }
    #endif
    
    // Register our game mode
    g_gameid = zp_register_game_mode( "Night-Mare Mode", access_flag, g_chance, 0, ZP_DM_BALANCE )
}

// Player spawn post
public zp_player_spawn_post( id, should_be_zombie )
{
    // Check for current mode
    if( zp_get_current_mode() == g_gameid )
    {
        // Check if the player was to be made a zombie
        if(should_be_zombie == 1 )
        {
            if( zp_get_assassin_count() > zp_get_nemesis_count() )
                zp_make_user_nemesis( id ) // make him an assassin instead
            else
                zp_make_user_assassin( id )
        }
        else
        {
            if( zp_get_sniper_count() > zp_get_survivor_count() )
                zp_make_user_survivor( id )
            else
                zp_make_user_sniper( id )
        }
        
        /**
        * Note:
        * This very necessary, you should return ZP_PLUGIN_HANDLED, if
        * you have used this forward and/or have performed an action
        * while using it, so that the main plugin will be informed about
        * this forward's usage.
        */
        return ZP_PLUGIN_HANDLED
    }
    return PLUGIN_CONTINUE
}

public zp_round_started_pre( game )
{
    // Check if it is our game mode
    if( game == g_gameid )
    {
        // Check for min players
        if( fn_get_alive_players() < get_pcvar_num(cvar_minplayers) )
        {
            /**
            * Note:
            * This very necessary, you should return ZP_PLUGIN_HANDLED if
            * some conditions required by your game mode are not met
            * This will inform the main plugin that you have rejected
            * the offer and so the main plugin will allow other game modes
            * to be given a chance
            */
            return ZP_PLUGIN_HANDLED
        }
        // Start our new mode
        start_avs_mode( )
    }
    // Make the compiler happy =)
    return PLUGIN_CONTINUE
}

public zp_round_started( game, id )
{
    // Check if it is our game mode
    if( game == g_gameid )
    {
        // Show HUD notice
        set_hudmessage(221, 156, 21, -1.0, 0.17, 1, 0.0, 5.0, 1.0, 1.0, -1)
        ShowSyncHudMsg(0, g_msg_sync, "Night-Mare Mode !!!")
        
        // Play the starting sound
        client_cmd(0, "spk ^"%s^"", g_play_sounds[ random_num(0, sizeof g_play_sounds -1) ] )
        
        // Remove ambience task affects
        remove_task( TASK_AMB )
        
        // Set task to start ambience sounds
        #if defined AMBIENCE_SOUNDS
        set_task( 2.0, "start_ambience_sounds", TASK_AMB )
        #endif
    }
}

public zp_game_mode_selected( gameid, id )
{
    // Check if our game mode was called
    if( gameid == g_gameid )
        start_avs_mode( )
    
    // Make the compiler happy again =)
    return PLUGIN_CONTINUE
}

// This function contains the whole code behind this game mode
start_avs_mode( )
{
    // Create and initialize some important vars
    static i_assassins, i_max_assassins, id, i_alive
    i_alive = fn_get_alive_players()
    id = 0
    
    // Get the no of players we have to turn into assassins
    i_max_assassins = floatround( ( i_alive * 0.25), floatround_ceil )
    i_assassins = 0
    
    // Randomly turn players into Assassins
    while (i_assassins < i_max_assassins)
    {
        // Keep looping through all players
        if ( (++id) > g_maxplayers) id = 1
        
        // Dead
        if ( !is_user_alive(id) )
            continue;
        
        // Random chance
        if (random_num(1, 5) == 1)
        {
            // Make user assassin
            zp_make_user_assassin(id)
            
            // Increase counter
            i_assassins++
        }
    }
    
    i_assassins = 0
    
    // Randomly turn players into Assassins
    while (i_assassins < i_max_assassins)
    {
        // Keep looping through all players
        if ( (++id) > g_maxplayers) id = 1
        
        // Dead
        if ( !is_user_alive(id) || zp_get_user_assassin(id))
            continue;
        
        // Random chance
        if (random_num(1, 5) == 1)
        {
            // Make user assassin
            zp_make_user_nemesis(id)
            
            // Increase counter
            i_assassins++
        }
    }
    
    i_assassins = 0
    
    // Randomly turn players into Assassins
    while (i_assassins < i_max_assassins)
    {
        // Keep looping through all players
        if ( (++id) > g_maxplayers) id = 1
        
        // Dead
        if ( !is_user_alive(id) || zp_get_user_assassin(id) || zp_get_user_nemesis(id) )
            continue;
        
        // Random chance
        if (random_num(1, 5) == 1)
        {
            // Make user assassin
            zp_make_user_survivor(id)
            
            // Increase counter
            i_assassins++
        }
    }
    
    // Turn the remaining players into snipers
    for (id = 1; id <= g_maxplayers; id++)
    {
        // Only those of them who are alive and are not assassins
        if ( !is_user_alive(id) || zp_get_user_assassin(id) || zp_get_user_nemesis(id) || zp_get_user_survivor(id) )
            continue;
        
        // Turn into a sniper
        zp_make_user_sniper(id)
    }
}

#if defined AMBIENCE_SOUNDS
public start_ambience_sounds( )
{
    // Variables
    static amb_sound[64], sound, Float:duration
    
    // Select our ambience sound
    sound = random_num( 0, sizeof g_sound_ambience - 1 )
    copy( amb_sound, sizeof amb_sound - 1 , g_sound_ambience[ sound ] )
    duration = g_sound_ambience_duration[ sound ]
    
    // Check whether it's a wav or mp3, then play it on clients
    if ( equal( amb_sound[ strlen( amb_sound ) - 4 ], ".mp3" ) )
        client_cmd( 0, "mp3 play ^"sound/%s^"", amb_sound )
    else
        client_cmd( 0, "spk ^"%s^"", sound )
    
    // Start the ambience sounds
    set_task( duration, "start_ambience_sounds", TASK_AMB )
}
public zp_round_ended( winteam )
{
    // Stop ambience sounds on round end
    remove_task( TASK_AMB )
}
#endif

// This function returns the no. of alive players
// Feel free to use this in your plugin when you
// are making your own game modes.
fn_get_alive_players( )
{
    static i_alive, id
    i_alive = 0
    
    for ( id = 1; id <= g_maxplayers; id++ )
    {
        if( is_user_alive( id ) )
            i_alive++
    }
    return i_alive;
}


Отредактировал: Slackerok, - 13.4.2013, 22:43
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя Slackerok
сообщение 14.4.2013, 10:49
Сообщение #116
Стаж: 16 лет

Сообщений: 187
Благодарностей: 20
Полезность: 12

mazdan, Я заметил в плагинах есть уже переменная new g_gameid

// Register our game mode
g_gameid = zp_register_game_mode( "Assassin vs Snipers Mode", access_flag, g_chance, 0, ZP_DM_BALANCE )

// Check for current mode
if( zp_get_current_mode() == g_gameid )

// Check if it is our game mode
if( game == g_gameid )

// Check if our game mode was called
if( gameid == g_gameid )

==============================
===
Если заменить g_gameid на g_assvssnip или g_nightmare получится определить раунд на этой переменной??

Отредактировал: Slackerok, - 14.4.2013, 10:49
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя mazdan
сообщение 14.4.2013, 12:09
Сообщение #117


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

Стаж: 15 лет

Сообщений: 7566
Благодарностей: 5437
Полезность: 1305

Да вникать нужно, лень.
Строите где и как работают другие переменные отвечающие за моды, соответственно делайте и новую. Всего то нужно ее в нужный момент делать 1 и 0 :)


Не пишите мне в ЛС. Пишите на почту. В ЛС я пропускаю сообщения.
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя Slackerok
сообщение 14.4.2013, 12:46
Сообщение #118
Стаж: 16 лет

Сообщений: 187
Благодарностей: 20
Полезность: 12

Нашел часть кода по Армагедону в исходнике ZPA:

Код
<!--shcode--><pre><code class='no-highlight'>// Start LNJ mode
start_lnj_mode(id, mode)
{
// Get alive players count
static iPlayersnum
iPlayersnum = fnGetAlive()

static sound[64], iZombies, iMaxZombies

if ((mode == MODE_NONE && (!get_pcvar_num(cvar_prevent
consecutive) || g_lastmode != MODE_LNJ) && random_num(1, get_pcvar_num(cvar_lnjchance)) == get_pcvar_num(cvar_lnj) &&
iPlayersnum >= get_pcvar_num(cvar_lnjminplaye
rs) && floatround(iPlayersnum*get_pcv
ar_floa
t(cvar_lnjratio), floatround_ceil) >= 1 && floatround(iPlayersnum*get_pcv
ar_floa
t(cvar_multiratio), floatround_ceil) < iPlayersnum )
|| mode == MODE_SET)
{
// Armageddon Mode
g_lnjround = true
g_currentmode = MODE_LNJ
g_lastmode = MODE_LNJ

// Prevent Infection
g_allowinfection = false

// iMaxZombies is rounded up, in case there aren't enough players
iMaxZombies = floatround((iPlayersnum * get_pcvar_float(cvar_lnjratio)
), floatround_ceil)
iZombies = 0

// Randomly turn iMaxZombies players into Nemesis
while (iZombies < iMaxZombies)
{
// Keep looping through all players
if (++id > g_maxplayers) id = 1

// Dead or already a zombie or survivor
if (!g_isalive[id] || g_zombie[id] || g_survivor[id])
continue;

// Random chance
if (random_num(0, 1))
{
// Turn into a Nemesis
zombieme(id, 0, 1, 0, 0, 0)
fm_set_user_health(id, floatround(float(pev(id, pev_health)) * get_pcvar_float(cvar_lnjnemhpm
ulti)))
iZombies++
}
}

// Turn the remaining players into survivors
for (id = 1; id <= g_maxplayers; id++)
{
// Only those of them who arent zombies or survivor
if (!g_isalive[id] || g_zombie[id] || g_survivor[id])
continue;

// Turn into a Survivor
humanme(id, 1, 0, 0)
fm_set_user_health(id, floatround(float(pev(id, pev_health)) * get_pcvar_float(cvar_lnjsurvhp
multi)))
}

// Play armageddon sound
ArrayGetString(sound_lnj, random_num(0, ArraySize(sound_lnj) - 1), sound, charsmax(sound))
PlaySound(sound);

// Show Armageddon HUD notice
set_hudmessage(181 , 62, 244, -1.0, 0.17, 1, 0.0, 5.0, 1.0, 1.0, -1)
ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_LNJ")

// Start ambience sounds
if (g_ambience_sounds[AMBIENCE_SO
UNDS_LNJ])
{
remove_task(TASK_AMBIENCESOUND
S)
set_task(2.0, "ambience_sound_effects", TASK_AMBIENCESOUNDS)
}

// Mode fully started!
g_modestarted = true

// No more a new round
g_newround = false

// Round start forward
ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_LNJ, 0);

// Stop Here
return;
}

// Give chance to other game modes
start_sniper_mode(0, MODE_NONE)</code></pre><!--ehcode-->


Непонятно как определяется мод...

Отредактировал: Slackerok, - 14.4.2013, 13:28
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя mazdan
сообщение 14.4.2013, 16:39
Сообщение #119


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

Стаж: 15 лет

Сообщений: 7566
Благодарностей: 5437
Полезность: 1305

Цитата
g_lnjround = true
g_currentmode = MODE_LNJ

g_lastmode = MODE_LNJ

Наверное


Не пишите мне в ЛС. Пишите на почту. В ЛС я пропускаю сообщения.
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
Поблагодарили 1 раз
   + Цитировать сообщение
Статус пользователя Slackerok
сообщение 16.4.2013, 15:54
Сообщение #120
Стаж: 16 лет

Сообщений: 187
Благодарностей: 20
Полезность: 12

mazdan, Здравствуйте! В общем так и не дошло как сделать эти переменные sad.gif Пролистал код ZPA чтобы найти сходства между модами, но все безрезультатно... Несколько подсказок не дадите? )
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
7 страниц V  « 5 6 7
 
Тема закрытаНачать новую тему
 
0 пользователей и 2 гостей читают эту тему: