Parent Directory | Revision Log
Revision 1 - (view) (download)
1 : | ian | 1 | /* Fun functions |
2 : | * | ||
3 : | * by Numb | ||
4 : | * | ||
5 : | * This file is provided as is (no warranties). | ||
6 : | */ | ||
7 : | |||
8 : | |||
9 : | enum Color | ||
10 : | { | ||
11 : | NORMAL = 1, // clients scr_concolor cvar color | ||
12 : | GREEN, // Green Color | ||
13 : | TEAM_COLOR, // Red, grey, blue | ||
14 : | GREY, // grey | ||
15 : | RED, // Red | ||
16 : | BLUE, // Blue | ||
17 : | } | ||
18 : | |||
19 : | new TeamName[][] = | ||
20 : | { | ||
21 : | "", | ||
22 : | "TERRORIST", | ||
23 : | "CT", | ||
24 : | "SPECTATOR" | ||
25 : | } | ||
26 : | |||
27 : | ColorChat(id, Color:type, const msg[], {Float,Sql,Result,_}:...) | ||
28 : | { | ||
29 : | static message[256]; | ||
30 : | |||
31 : | switch(type) | ||
32 : | { | ||
33 : | case NORMAL: // clients scr_concolor cvar color | ||
34 : | { | ||
35 : | message[0] = 0x01; | ||
36 : | } | ||
37 : | case GREEN: // Green | ||
38 : | { | ||
39 : | message[0] = 0x04; | ||
40 : | } | ||
41 : | default: // White, Red, Blue | ||
42 : | { | ||
43 : | message[0] = 0x03; | ||
44 : | } | ||
45 : | } | ||
46 : | |||
47 : | vformat(message[1], 251, msg, 4); | ||
48 : | |||
49 : | // Make sure message is not longer than 192 character. Will crash the server. | ||
50 : | message[192] = '^0'; | ||
51 : | |||
52 : | static team, ColorChange, index, MSG_Type; | ||
53 : | |||
54 : | if(id) | ||
55 : | { | ||
56 : | MSG_Type = MSG_ONE; | ||
57 : | index = id; | ||
58 : | } else { | ||
59 : | index = FindPlayer(); | ||
60 : | MSG_Type = MSG_ALL; | ||
61 : | } | ||
62 : | |||
63 : | team = get_user_team(index); | ||
64 : | ColorChange = ColorSelection(index, MSG_Type, type); | ||
65 : | |||
66 : | ShowColorMessage(index, MSG_Type, message); | ||
67 : | |||
68 : | if(ColorChange) | ||
69 : | { | ||
70 : | Team_Info(index, MSG_Type, TeamName[team]); | ||
71 : | } | ||
72 : | } | ||
73 : | |||
74 : | ShowColorMessage(id, type, message[]) | ||
75 : | { | ||
76 : | message_begin(type, get_user_msgid("SayText"), _, id); | ||
77 : | write_byte(id) | ||
78 : | write_string(message); | ||
79 : | message_end(); | ||
80 : | } | ||
81 : | |||
82 : | Team_Info(id, type, team[]) | ||
83 : | { | ||
84 : | message_begin(type, get_user_msgid("TeamInfo"), _, id); | ||
85 : | write_byte(id); | ||
86 : | write_string(team); | ||
87 : | message_end(); | ||
88 : | |||
89 : | return 1; | ||
90 : | } | ||
91 : | |||
92 : | ColorSelection(index, type, Color:Type) | ||
93 : | { | ||
94 : | switch(Type) | ||
95 : | { | ||
96 : | case RED: | ||
97 : | { | ||
98 : | return Team_Info(index, type, TeamName[1]); | ||
99 : | } | ||
100 : | case BLUE: | ||
101 : | { | ||
102 : | return Team_Info(index, type, TeamName[2]); | ||
103 : | } | ||
104 : | case GREY: | ||
105 : | { | ||
106 : | return Team_Info(index, type, TeamName[0]); | ||
107 : | } | ||
108 : | } | ||
109 : | |||
110 : | return 0; | ||
111 : | } | ||
112 : | |||
113 : | FindPlayer() | ||
114 : | { | ||
115 : | static i; | ||
116 : | i = -1; | ||
117 : | |||
118 : | while(i <= get_maxplayers()) | ||
119 : | { | ||
120 : | if(is_user_connected(++i)) | ||
121 : | { | ||
122 : | return i; | ||
123 : | } | ||
124 : | } | ||
125 : | |||
126 : | return -1; | ||
127 : | } |
Contact | ViewVC Help |
Powered by ViewVC 1.0.4 |