]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/net_notice.qc
un-ignorable sv_notices system. set sv_notice important info 1| imprtant info 2 in...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / net_notice.qc
1 #ifdef SVQC\r
2 \r
3 void sv_notice_to(entity _to, string _notice, float _howlong, float _modal)\r
4 {\r
5         msg_entity = _to;
6         WriteByte(MSG_ONE, SVC_TEMPENTITY);
7         WriteByte(MSG_ONE, TE_CSQC_SVNOTICE);
8         WriteString(MSG_ONE, _notice);\r
9         WriteLong(MSG_ONE, _howlong);\r
10         WriteByte(MSG_ONE, _modal);\r
11 }\r
12 \r
13 void sv_notice_toall(string _notice, float _howlong, float _modal)\r
14 {\r
15     entity _head;\r
16     FOR_EACH_REALCLIENT(_head)\r
17         sv_notice_to(_head, _notice, _howlong, _modal);\r
18     \r
19 }\r
20 \r
21 #endif // SVQC\r
22 \r
23 #ifdef CSQC\r
24 void SUB_Remove()
25 { remove(self); }
26 \r
27 void cl_notice_read()\r
28 {\r
29     entity _notice;\r
30     float _done;\r
31     float _modal;\r
32     _notice = spawn();\r
33     _notice.classname = "sv_notice";\r
34     _notice.netname = strzone(ReadString());\r
35     _notice.alpha = ReadLong() + time;\r
36     _notice.skin = ReadByte();\r
37 }\r
38 \r
39 float cl_notice_run()\r
40 {\r
41     entity _notes;\r
42     string _notice;\r
43     float c, m = FALSE;\r
44     \r
45     _notes = findchain(classname, "sv_notice");\r
46     if(!_notes)\r
47         return FALSE;\r
48     #define M1 30\r
49     #define M2 10\r
50     \r
51     vector v1, v2, v3;\r
52     v1 = '1 1 0' * M1;\r
53     v2_x = vid_conwidth - (2 * M1);\r
54     v2_y = vid_conheight - (2 * M1);\r
55     \r
56     drawfill(v1, v2, '0 0 0', 0.5, DRAWFLAG_NORMAL);\r
57     v1 = '1 1 0' * (M1 + M2);\r
58     v2_x = vid_conwidth - (2 * (M1 + M2));\r
59     v2_y = vid_conheight - (2 * (M1 + M2));\r
60     drawfill(v1, v2, '0.5 0.5 0.5', 0.5, DRAWFLAG_NORMAL);\r
61     v3 = v1 + '10 10 0';\r
62     \r
63     #define OUT(s,z) drawcolorcodedstring(v3, s, '1 1 0' * z, 1, DRAWFLAG_NORMAL); v3_y += z + 4\r
64     \r
65     OUT("^1Server notices:", 32);\r
66     \r
67     //drawcolorcodedstring(v1 + '5 5 0', "^1Server notices:", '32 32 0', 1, DRAWFLAG_NORMAL);\r
68     while(_notes)\r
69     {\r
70    \r
71         _notice = sprintf("^7%s (^3%d sec left)", _notes.netname , rint(_notes.alpha - time));\r
72         OUT(_notice, 16);\r
73 \r
74         if(_notes.skin) \r
75             m = TRUE;\r
76         \r
77         if(_notes.alpha <= time)\r
78         {\r
79             _notes.think = SUB_Remove;\r
80             _notes.nextthink = time;\r
81         }\r
82         \r
83         _notes = _notes.chain;        \r
84     }\r
85     \r
86     #undef OUT\r
87     #undef M1\r
88     #undef M2\r
89     \r
90     return m;\r
91 }\r
92 \r
93 #endif // CSQC\r