1+ script_name (" SetTimeAndWeather" )
2+ script_description (" /set_weather(/sw) - change weather, /set_time(/st) - change time" )
3+ script_version (" v1.0" )
4+ script_authors (" Tim4ukys" )
5+ script_dependencies (" SA-MP v0.3.7 R1" , " SA-MP v0.3.7 R3-1" , " SA-MP v0.3.DL R1" )
6+
7+ local dl = require " SA-MP API.init"
8+ local ffi = require ( ' ffi' )
9+
10+ local encoding = require ' encoding'
11+ encoding .default = ' UTF-8'
12+ cp1251 = encoding .CP1251
13+
14+ function cmdSetTime (param )
15+ local hour = tonumber (ffi .string (param ))
16+ if hour ~= nil and hour >= 0 and hour <= 23 then
17+
18+ local this = dl .Get ().pBase .pSettings
19+
20+ this .byteWorldTime_Hour = ffi .cast (" unsigned char" , hour )
21+
22+ local textbuff = string.format (cp1251 " [{FF9900}SetTime{990000}] {FF9900}Новое время {990000}- {FF9900}%02d:00{990000}!" , hour )
23+ -- print(textbuff)
24+ dl .AddMessageToChat (8 , ffi .new (" char[" .. string.len ( textbuff ) .. " ]" , textbuff ), nullptr , 0x990000 , 0 )
25+ else
26+ dl .AddMessageToChat (8 , cp1251 " [{FF9900}SetTime{990000}] {FF9900}/set_time {606060}[0 - 23]" , nullptr , 0x990000 , 0 )
27+ end
28+ end
29+
30+ function cmdSetWeather (param )
31+ local weather = tonumber (ffi .string (param ))
32+ if weather ~= nil and weather >= 0 and weather <= 45 then
33+
34+ local this = dl .Get ().pBase .pSettings
35+
36+ this .byteWeather = ffi .cast (" unsigned char" , weather )
37+ forceWeatherNow (weather )
38+
39+ local textbuff = string.format (cp1251 " [{FF9900}SetWeather{990000}] {FF9900}Новая погода {990000}- {FF9900}%d{990000}!" , weather )
40+ -- print(textbuff)
41+ dl .AddMessageToChat (8 , ffi .new (" char[" .. string.len ( textbuff ) .. " ]" , textbuff ), nullptr , 0x990000 , 0 )
42+ else
43+ dl .AddMessageToChat (8 , cp1251 " [{FF9900}SetWeather{990000}] {FF9900}/set_weather {606060}[0 - 45]" , nullptr , 0x990000 , 0 )
44+ end
45+ end
46+
47+ function main ()
48+ while not dl .GetIsAvailable () do
49+ wait (0 )
50+ end
51+ dl .AddMessageToChat (8 , cp1251 " [{FF9900}SetTime&Weather{990000}] {FF9900}Lua скрипт инициализирован{990000}!" , nullptr , 0x990000 , 0 )
52+ dl .AddMessageToChat (8 , cp1251 " Команды: {FF9900}/set_time{606060}(/st) {606060}| {FF9900}/set_weather{606060}(/sw)" , nullptr , 0x990000 , 0 )
53+ dl .AddMessageToChat (8 , cp1251 " Автор: {FF9900}Tim4ukys {606060}| {990000}Ссылка: {FF9900}vk.com/petrov_team" , nullptr , 0x990000 , 0 )
54+
55+
56+ dl .RegisterClientCommand (" st" , cmdSetTime , true )
57+ dl .RegisterClientCommand (" set_time" , cmdSetTime , true )
58+ dl .RegisterClientCommand (" sw" , cmdSetWeather , true )
59+ dl .RegisterClientCommand (" set_weather" , cmdSetWeather , true )
60+
61+ wait (- 1 )
62+ end
0 commit comments