/*
Возвращает UNIX TIMESTAMP в соответствии с указанной датой.
ПОДРОБНЕЕ
UNIX TIMESTAMP это кол-во секунд со дня 01.01.1970, 00:00:00 до
указанной в параметрах даты
ВЕРНЕТ
число integer (4 байта)
*/
stock date_to_timestamp
(
year = 1970, month = 1, day = 1,
hour = 0, minute = 0, second = 0
)
{
switch ( month )
{
case 2 : day += 31; case 3 : day += 59; case 4 : day += 90;
case 5 : day += 120; case 6 : day += 151; case 7 : day += 181;
case 8 : day += 212; case 9 : day += 243; case 10 : day += 273;
case 11 : day += 304; case 12 : day += 334;
}
return ( second + minute*60 + hour*3600 + (day - 1)*86400
+ (year - 1970)*31557600 + ( year % 4 == 0 ? 21600 : 0 ) );
}
/*
Возвращает по ссылке дату в соответствии с указанным UNIX TIMESTAMP.
ПОДРОБНЕЕ
UNIX TIMESTAMP это кол-во секунд со дня 01.01.1970, 00:00:00 до
указанной в параметрах даты. Если он правильно указан, то в
year будет помещен год, в month - месяц, в day - день,
в hour - час, в minute - минута, в second - секунда.
ВЕРНЕТ
ничего
*/
stock timestamp_to_date
(
unix_timestamp = 0,
& year = 1970, & month = 1, & day = 1,
& hour = 0, & minute = 0, & second = 0
)
{
year = unix_timestamp / 31557600;
unix_timestamp -= year * 31557600;
year += 1970;
if ( year % 4 == 0 ) unix_timestamp -= 21600;
day = unix_timestamp / 86400;
switch ( day )
{
// в second будет временно хранится число месяца
case 0..30 : { second = day; month = 1; }
case 31..58 : { second = day - 31; month = 2; }
case 59..89 : { second = day - 59; month = 3; }
case 90..119 : { second = day - 90; month = 4; }
case 120..150 : { second = day - 120; month = 5; }
case 151..180 : { second = day - 151; month = 6; }
case 181..211 : { second = day - 181; month = 7; }
case 212..242 : { second = day - 212; month = 8; }
case 243..272 : { second = day - 243; month = 9; }
case 273..303 : { second = day - 273; month = 10; }
case 304..333 : { second = day - 304; month = 11; }
case 334..366 : { second = day - 334; month = 12; }
}
unix_timestamp -= day * 86400;
hour = unix_timestamp / 3600;
unix_timestamp -= hour * 3600;
minute = unix_timestamp / 60;
unix_timestamp -= minute * 60;
day = second + 1;
second = unix_timestamp;
}
stock timestamp_to_date ( unix_timestamp = 0, & year = 1970, & month = 1, & day = 1, & hour = 0, & minute = 0, & second = 0 ) { year = unix_timestamp / 31557600; unix_timestamp -= year * 31557600; year += 1970; if ( year % 4 == 0 ) unix_timestamp -= 21600; day = unix_timestamp / 86400; switch ( day ) { // в second будет временно хранится число месяца case 0..30 : { second = day; month = 1; } case 31..58 : { second = day - 31; month = 2; } case 59..89 : { second = day - 59; month = 3; } case 90..119 : { second = day - 90; month = 4; } case 120..150 : { second = day - 120; month = 5; } case 151..180 : { second = day - 151; month = 6; } case 181..211 : { second = day - 181; month = 7; } case 212..242 : { second = day - 212; month = 8; } case 243..272 : { second = day - 243; month = 9; } case 273..303 : { second = day - 273; month = 10; } case 304..333 : { second = day - 304; month = 11; } case 334..366 : { second = day - 334; month = 12; } } unix_timestamp -= day * 86400; hour = unix_timestamp / 3600; unix_timestamp -= hour * 3600; minute = unix_timestamp / 60; unix_timestamp -= minute * 60; day = second + 1; second = unix_timestamp; }
new unban_date[64] = timestamp_to_date(res[2]); timestamp_to_date(unbantime);
new_serv.pwn(442) : error 035: argument type mismatch (argument 1) new_serv.pwn(442) : error 008: must be a constant expression; assumed zero
new MusicNumber = 15; new LoginMusic[15][64] = { {"http://cs4897.vk.com/u2735926/audio/2e077ffa982f.mp3"}, {"http://cs4865.vk.com/u61450/audio/41cf98d3190b.mp3"}, {"http://cs5278.vk.com/u61450/audio/b9913032bce6.mp3"}, {"http://cs5569.vk.com/u61450/audio/97ad58e7085b.mp3"}, {"http://cs5278.vk.com/u61450/audio/192e99344696.mp3"}, {"http://cs4636.vk.com/u2000847/audio/69a6f745a23f.mp3"}, {"http://cs4604.vk.com/u3171457/audio/30a654f1113f.mp3"}, {"http://cs4838.vk.com/u74442484/audio/55d1959d1745.mp3"}, {"http://cs5572.vk.com/u99217144/audio/16dd24fc149a.mp3"}, {"http://cs5232.vk.com/u125129202/audio/9116d398046e.mp3"}, {"http://cs5232.vk.com/u125129202/audio/34711d546013.mp3"}, {"http://cs5059.vk.com/u5645681/audio/ffbc40e612ab.mp3"}, {"http://cs4614.vk.com/u47452768/audio/ff1c509183f1.mp3"}, {"http://cs4773.vk.com/u61624483/audio/5fabfbc4483d.mp3"}, };
new rand, music[64]; rand = random(MusicNumber); format(music,sizeof(music),"%s",LoginMusic[rand]); PlayAudioStreamForPlayer(playerid, music ,0.0, 0.0, 0.0, 0.0,0);
new_serv.pwn(31) : error 029: invalid expression, assumed zero new_serv.pwn(31) : error 008: must be a constant expression; assumed zero
new year, month, day, hour, minute, second; // Сюда вернется дата
// unix_timestamp - исходный Unixtime
timestamp_to_date( unix_timestamp, year, month, day, hour, minute, second );
PlayAudioStreamForPlayer(playerid, LoginMusic[random(sizeof(LoginMusic))], 0.0, 0.0, 0.0, 0.0,0);
new unixtime, year, month, day, hour, minute, second; unixtime = res[2]; //new_serv.pwn(439) : error 006: must be assigned to an array timestamp_to_date( unixtime, year, month, day, hour, minute, second );
stock CheckIPBanned(playerid) { new query[256]; new string[256]; new ipadress[16]; GetPlayerIp(playerid, ipadress, sizeof(ipadress)); format(query,sizeof(query),"SELECT * FROM `ip_bans` WHERE ip_adress = '%s'",ipadress); mysql_query(query); mysql_store_result(); if(mysql_num_rows()==1) { new tmp[72], res[4][64]; mysql_fetch_row(tmp); split(tmp, res, '|'); if(strval(res[2]) > gettime()) { new unixtime, year, month, day, hour, minute, second; unixtime = res[2]; timestamp_to_date( unixtime, year, month, day, hour, minute, second ); format(string,sizeof(string),"{ffffff}IP с которого вы пытаетесь зайти [ {ff0000}%s{ffffff} ] заблокирован.\nПричина: {ff0000}%s.\n{ffffff}Аккаунт будет разбанен - %d.%d.%d в %d:%d", ipadress, res[1], day, month, year, hour, minute); ShowPlayerDialog(playerid,999,DIALOG_STYLE_MSGBOX,"{ff0000}Ваш IP был заблокирован!",string,"Okay :(",""); Kick(playerid); } else { format(query,sizeof(query),"DELETE FROM `ip_bans` WHERE ip_adress='%s'",ipadress); mysql_query(query); } } }
На всякий случай скажу:
Никогда не используйте ссылки аудиопотоков из Vkontakte Почему? Во 1 ссылка выдается только на 1 IP адрес, во 2 устаревает через 36 часов. |