1 string W_Name(float weaponid);
2 float(float index) weapon_translateindextoflag;
7 void(string s, float check_dangerous) ServerConsoleEcho =
15 ch = substring(s, 0, 1);
16 if(ch != "\"" && ch != "\r" && ch != "\n")
18 s = substring(s, 1, strlen(s) - 1);
28 void(string s, float check_dangerous) GameLogEcho =
33 if(cvar("sv_eventlog_files"))
38 matches = cvar("sv_eventlog_files_counter") + 1;
39 cvar_set("sv_eventlog_files_counter", ftos(matches));
42 fn = strcat(substring("00000000", 0, 8 - strlen(fn)), fn);
43 fn = strcat(cvar_string("sv_eventlog_files_nameprefix"), fn, cvar_string("sv_eventlog_files_namesuffix"));
44 logfile = fopen(fn, FILE_APPEND);
47 fputs(logfile, strcat(s, "\n"));
49 if(cvar("sv_eventlog_console"))
51 ServerConsoleEcho(s, check_dangerous);
58 // will be opened later
63 if(logfile_open && logfile >= 0)
70 float math_mod(float a, float b)
72 return a - (floor(a / b) * b);
75 string linewrap(string s, float l)
82 t = strcat(t, substring(s, 0, l), "\n");
83 s = substring(s, l+1, strlen(s));
88 vector find_floor(vector org)
90 traceline(org + '0 0 5', org - '0 0 255', TRUE, self);
91 if (trace_fraction < 1)
97 void relocate_spawnpoint()
102 setorigin(self, find_floor(self.origin) + '0 0 30');
105 // NOTE: DO NOT USE THIS FUNCTION TOO OFTEN.
106 // IT WILL MOST PROBABLY DESTROY _ALL_ OTHER TEMP
107 // STRINGS AND TAKE QUITE LONG. haystack and needle MUST
108 // BE CONSTANT OR strzoneD!
109 float(string haystack, string needle, float offset) strstr =
113 len = strlen(needle);
114 endpos = strlen(haystack) - len;
115 while(offset < endpos)
117 found = substring(haystack, offset, len);
125 entity(vector point, .string field, string value, vector axismod) findnearest =
136 localhead = find(world, field, value);
139 if((localhead.items == IT_KEY1 || localhead.items == IT_KEY2) && localhead.target = "###item###")
140 dist = localhead.oldorigin;
142 dist = localhead.origin;
144 dist = dist_x * axismod_x * '1 0 0' + dist_y * axismod_y * '0 1 0' + dist_z * axismod_z * '0 0 1';
151 localhead = find(localhead, field, value);
156 string(string msg) formatmessage =
162 msg_save = strzone(msg);
166 p = strstr(msg_save, "%", p);
169 replacement = substring(msg_save, p, 2);
170 escape = substring(msg_save, p + 1, 1);
172 replacement = ftos(floor(self.armorvalue));
173 else if(escape == "h")
174 replacement = ftos(floor(self.health));
175 else if(escape == "l")
178 loc = findnearest(self.origin, classname, "info_location", '1 1 1');
180 loc = findnearest(self.origin, target, "###item###", '1 1 4');
182 replacement = loc.netname;
184 replacement = "someplace";
186 else if(escape == "x")
188 if(self.cursor_trace_ent)
189 replacement = self.cursor_trace_ent.netname;
191 replacement = "nothing";
193 dprint(strcat(ftos(p), "<", msg, "\n"));
194 msg = strcat(substring(msg_save, 0, p), replacement);
195 msg = strcat(msg, substring(msg_save, p+2, strlen(msg_save) - (p+2)));
196 dprint(strcat(ftos(p), ">", msg, "\n"));
198 msg_save = strzone(msg);