#include <amxmodx>
#define PLUGIN "New Year Task" // átírva húsvétra ~mforce
#define VERSION "0.4"
#define AUTHOR "Safety1st"
/*---------------EDIT ME------------------*/
const giTZ = 1 // 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 /husvet", "CheckCmd" )
register_clcmd( "say_team /husvet", "CheckCmd" )
set_task(1000.0, "CheckCmd", .flags="b");
}
public plugin_cfg() {
const iNewYearUTC = 1459036800 // 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, "^4[ProKillers]^1 Kellemes húsvétot te fijú!" )
}
public CheckCmd(id) {
new iDelay = giNewYear - get_systime()
if( iDelay < 0 ) {
// New Year is passed
color_print( 0, "^4[ProKillers]^1 Kellemes húsvétot te fijú!" )
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[ProKillers]^1 A húsvétig még: ^3%s!", szBuffer )
}
CreateWord( type, value ) {
enum { alone, afew, many }
static const szWords[][][] = {
{ "nap", "nap", "nap" },
{ "óra", "óra", "óra" },
{ "perc", "perc", "perc" },
{ "másodperc", "másodperc", "másodperc" }
}
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 )
szMessage[128] = 0 // terminate string for safety
if ( receiver )
iPlayers[0] = receiver
else
get_players( iPlayers, iPlayersNum, "ch" )
for ( new i = 0 ; i < iPlayersNum ; i++ ) {
iPlayer = iPlayers[i]
message_begin( MSG_ONE_UNRELIABLE, iMsgSayText, _, iPlayer )
write_byte(iPlayer)
write_string(szMessage)
message_end()
}
}