1. Andrey777 Пользователь

    Регистрация:
    30.03.15
    Сообщения:
    262
    Симпатии:
    36
    Пол:
    Мужской
    Skype:
    Andrey777best
    Всем привет кто может переделать этот плагин так что бы сообщения выводились рандомно, и по команде newyear?
    Код:
    /**
    *    Simple plugin to inform about remaining time before New Year and automatically run something when it comes.
    *
    *
    *    Last update:
    *      12/10/2015
    */
    
    /*    Copyright 2015  Safety1st
    
        New Year 2016 Task 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
    */
    
    #include <amxmodx>
    
    #define PLUGIN "New Year 2016 Task"
    #define VERSION "0.4"
    #define AUTHOR "Safety1st"
    
    /*---------------EDIT ME------------------*/
    const giTZ = 3    // set your timezone, negative value is allowed; for MSK (RTZ 2, UTC+3) it is 3
    /*----------------------------------------*/
    
    #define TASKID 1337     // arbitrary value
    
    new giNewYear
    new iLen, szBuffer[128]
    enum { DAYS, HOURS, MINUTES, SECONDS }
    
    public plugin_init() {
        register_plugin( PLUGIN, VERSION, AUTHOR )
    
        register_clcmd( "say /newyear", "CheckCmd" )
        register_clcmd( "say_team /newyear", "CheckCmd" )
    }
    
    public plugin_cfg() {
        const iNewYearUTC = 1451606400     // DO NOT CHANGE, see http://onlineconversion.com/unix_time.htm
    
        giNewYear = iNewYearUTC - giTZ * 3600
    
        new iDelay = giNewYear - get_systime()
        if( iDelay < 0 )
            // New Year is passed
            return
    
        set_task( float(iDelay), "NewYear", TASKID )
    }
    
    public NewYear() {
        // set here as you wish
        color_print( 0, "Happy New Year, блеать!" )
    }
    
    public CheckCmd(id) {
        new iDelay = giNewYear - get_systime()
        if( iDelay < 0 ) {
            // New Year is passed
            color_print( 0, "Happy New Year, блеать!" )
            return
        }
    
        szBuffer[0] = 0     // erase string
        iLen = 0    // set starting position
    
        new iDays = iDelay / 86400
        if( iDays ) {
            iDelay -= iDays * 86400
            CreateWord( DAYS, iDays )
        }
        new iHours = iDelay / 3600
        if( iHours ) {
            iDelay -= iHours * 3600
            CreateWord( HOURS, iHours )
        }
        new iMinutes = iDelay / 60
        if( iMinutes ) {
            iDelay -= iMinutes * 60
            CreateWord( MINUTES, iMinutes )
        }
        if( iDelay )
            CreateWord( SECONDS, iDelay )
    
        color_print( 0, "До ^4Нового Года%s!", szBuffer )
    }
    
    CreateWord( type, value ) {
        enum { alone, afew, many }
        static const szWords[][][] = {
            {    "день",     "дня",   "дней" },
            {     "час",    "часа",  "часов" },
            {  "минута",  "минуты",  "минут" },
            { "секунда", "секунды", "секунд" }
        }
    
        iLen += formatex( szBuffer[iLen], charsmax(szBuffer) - iLen, " ^3%d^1 ", value )
        switch( value ) {
            case 1, 21, 31, 41, 51 :
                iLen += formatex( szBuffer[iLen], charsmax(szBuffer) - iLen, "%s", szWords[type][alone] )
            case 2..4, 22..24, 32..34, 42..44, 52..54 :
                iLen += formatex( szBuffer[iLen], charsmax(szBuffer) - iLen, "%s", szWords[type][afew] )
            default :
                iLen += formatex( szBuffer[iLen], charsmax(szBuffer) - iLen, "%s", szWords[type][many] )
        }
    }
    
    public  plugin_end() {
        remove_task(TASKID)
    }
    
    public color_print( receiver, const rawmsg[ ], any:... ) {
        /* colors  : sma
            normal : ^1
            team   : ^3
            green  : ^4 */
    
        static iMsgSayText = 0
        if( !iMsgSayText )
            iMsgSayText = get_user_msgid( "SayText" )
    
        new szMessage[192], iPlayers[32], iPlayersNum = 1, iPlayer
        vformat( szMessage, charsmax(szMessage), rawmsg, 3 )
        if ( szMessage[0] != '^1' || szMessage[0] != '^3' || szMessage[0] != '^4' )
            format( szMessage, charsmax(szMessage) - 1, "^1%s", szMessage )    // we must set initial default color if it is not provided explicitly
    
        szMessage[128] = 0    // terminate string for safety
    
        if ( receiver )
            iPlayers[0] = receiver
        else
            get_players( iPlayers, iPlayersNum, "ch" )    // skip bots and HLTV
    
        for ( new i = 0 ; i < iPlayersNum ; i++ ) {
            iPlayer = iPlayers[i]
            message_begin( MSG_ONE_UNRELIABLE, iMsgSayText, _, iPlayer )
            write_byte(iPlayer)    // use target player as sender to see colors at all (and his own team color for ^3)
            write_string(szMessage)
            message_end()
        }
    }
     
  2. neygomon Его Темнейшество :j Команда форума

    Регистрация:
    26.02.15
    Сообщения:
    7.600
    Симпатии:
    4.173
    Пол:
    Мужской
    говнокод сафетиста.
    азазаззазазаза
    он так и не научился писать...
     
  3. Andrey777 Пользователь

    Регистрация:
    30.03.15
    Сообщения:
    262
    Симпатии:
    36
    Пол:
    Мужской
    Skype:
    Andrey777best
    neygomon, А у тебя нет случайно в наличие примерно такого плагина, отсчет до нового года?
     
  4. neygomon Его Темнейшество :j Команда форума

    Регистрация:
    26.02.15
    Сообщения:
    7.600
    Симпатии:
    4.173
    Пол:
    Мужской
    Andrey777, дак этот юзай.
    тут говнокод только в стоке, да и то, если только сильно прикопаться)
     
    HannibaL нравится это.