forked from nukkonyan/Tklib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhalflife.inc
736 lines (671 loc) · 28.1 KB
/
halflife.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod (C)2004-2016 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This file is part of the SourceMod/SourcePawn SDK.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#if defined _halflife_included
#endinput
#endif
#define _halflife_included
#define SOURCE_SDK_UNKNOWN 0 /**< Could not determine the engine version */
#define SOURCE_SDK_ORIGINAL 10 /**< Original Source engine (still used by "The Ship") */
#define SOURCE_SDK_DARKMESSIAH 15 /**< Modified version of original engine used by Dark Messiah (no SDK) */
#define SOURCE_SDK_EPISODE1 20 /**< SDK+Engine released after Episode 1 */
#define SOURCE_SDK_EPISODE2 30 /**< SDK+Engine released after Episode 2/Orange Box */
#define SOURCE_SDK_BLOODYGOODTIME 32 /**< Modified version of ep2 engine used by Bloody Good Time (no SDK) */
#define SOURCE_SDK_EYE 33 /**< Modified version of ep2 engine used by E.Y.E Divine Cybermancy (no SDK) */
#define SOURCE_SDK_CSS 34 /**< Sometime-older version of Source 2009 SDK+Engine, used for Counter-Strike: Source */
#define SOURCE_SDK_EPISODE2VALVE 35 /**< SDK+Engine released after Episode 2/Orange Box, "Source 2009" or "Source MP" */
#define SOURCE_SDK_LEFT4DEAD 40 /**< Engine released after Left 4 Dead (no SDK yet) */
#define SOURCE_SDK_LEFT4DEAD2 50 /**< Engine released after Left 4 Dead 2 (no SDK yet) */
#define SOURCE_SDK_ALIENSWARM 60 /**< SDK+Engine released after Alien Swarm */
#define SOURCE_SDK_CSGO 80 /**< Engine released after CS:GO (no SDK yet) */
#define SOURCE_SDK_DOTA 90 /**< Engine released after Dota 2 (no SDK) */
#define MOTDPANEL_TYPE_TEXT 0 /**< Treat msg as plain text */
#define MOTDPANEL_TYPE_INDEX 1 /**< Msg is auto determined by the engine */
#define MOTDPANEL_TYPE_URL 2 /**< Treat msg as an URL link */
#define MOTDPANEL_TYPE_FILE 3 /**< Treat msg as a filename to be opened */
enum DialogType
{
DialogType_Msg = 0, /**< just an on screen message */
DialogType_Menu, /**< an options menu */
DialogType_Text, /**< a richtext dialog */
DialogType_Entry, /**< an entry box */
DialogType_AskConnect /**< ask the client to connect to a specified IP */
};
enum EngineVersion
{
Engine_Unknown, /**< Could not determine the engine version */
Engine_Original, /**< Original Source Engine (used by The Ship) */
Engine_SourceSDK2006, /**< Episode 1 Source Engine (second major SDK) */
Engine_SourceSDK2007, /**< Orange Box Source Engine (third major SDK) */
Engine_Left4Dead, /**< Left 4 Dead */
Engine_DarkMessiah, /**< Dark Messiah Multiplayer (based on original engine) */
Engine_Left4Dead2 = 7, /**< Left 4 Dead 2 */
Engine_AlienSwarm, /**< Alien Swarm (and Alien Swarm SDK) */
Engine_BloodyGoodTime, /**< Bloody Good Time */
Engine_EYE, /**< E.Y.E Divine Cybermancy */
Engine_Portal2, /**< Portal 2 */
Engine_CSGO, /**< Counter-Strike: Global Offensive */
Engine_CSS, /**< Counter-Strike: Source */
Engine_DOTA, /**< Dota 2 */
Engine_HL2DM, /**< Half-Life 2 Deathmatch */
Engine_DODS, /**< Day of Defeat: Source */
Engine_TF2, /**< Team Fortress 2 */
Engine_NuclearDawn, /**< Nuclear Dawn */
Engine_SDK2013, /**< Source SDK 2013 */
Engine_Blade, /**< Blade Symphony */
Engine_Insurgency, /**< Insurgency (2013 Retail version)*/
Engine_Contagion, /**< Contagion */
Engine_BlackMesa, /**< Black Mesa Multiplayer */
Engine_DOI /**< Day of Infamy */
};
enum FindMapResult
{
// A direct match for this name was found
FindMap_Found,
// No match for this map name could be found.
FindMap_NotFound,
// A fuzzy match for this map name was found.
// Ex: cp_dust -> cp_dustbowl, c1m1 -> c1m1_hotel
// Only supported for maps that the engine knows about. (This excludes workshop maps on Orangebox).
FindMap_FuzzyMatch,
// A non-canonical match for this map name was found.
// Ex: workshop/1234 -> workshop/cp_qualified_name.ugc1234
// Only supported on "Orangebox" games with workshop support.
FindMap_NonCanonical,
// No currently available match for this map name could be found, but it may be possible to load
// Only supported on "Orangebox" games with workshop support.
FindMap_PossiblyAvailable
};
#define INVALID_ENT_REFERENCE 0xFFFFFFFF
/**
* Logs a generic message to the HL2 logs.
*
* @param format String format.
* @param ... Format arguments.
*/
native void LogToGame(const char[] format, any ...);
/**
* Sets the seed value for the global Half-Life 2 Random Stream.
*
* @param seed Seed value.
*/
native void SetRandomSeed(int seed);
/**
* Returns a random floating point number from the Half-Life 2 Random Stream.
*
* @param fMin Minimum random bound.
* @param fMax Maximum random bound.
* @return A random number between (inclusive) fMin and fMax.
*/
native float GetRandomFloat(float fMin=0.0, float fMax=1.0);
/**
* Returns a random number from the Half-Life 2 Random Stream.
*
* @param nmin Minimum random bound.
* @param nmax Maximum random bound.
* @return A random number between (inclusive) nmin and nmax.
*/
native int GetRandomInt(int nmin, int nmax);
/**
* Returns whether a map is valid or not.
*
* @param map Map name, excluding .bsp extension.
* @return True if valid, false otherwise.
*/
native bool IsMapValid(const char[] map);
/**
* Returns whether a full or partial map name is found or can be resolved
*
* @param map Map name (usually same as map path relative to maps/ dir,
* excluding .bsp extension).
* @param foundmap Resolved map name. If the return is FindMap_FuzzyMatch
* or FindMap_NonCanonical the buffer will be the full path.
* @param maxlen Maximum length to write to map var.
* @return Result of the find operation. Not all result types are supported on all games.
*/
native FindMapResult FindMap(const char[] map, char[] foundmap, int maxlen);
/**
* Get the display name of a workshop map.
*
* Note: You do not need to call FindMap first. This native will call FindMap internally.
*
* @param map Map name (usually same as map path relative to maps/ dir,
* excluding .bsp extension).
* @param displayName Map's display name, i.e. cp_mymapname or de_mymapname.
* If FindMap returns FindMap_PossiblyAvailable or FindMap_NotFound,
* the map cannot be resolved and this native will return false,
* but displayName will be a copy of map.
* @param maxlen Maximum length to write to displayName var.
* @return true if FindMap returns FindMap_Found, FindMap_FuzzyMatch, or
* FindMap_NonCanonical.
* false if FindMap returns FindMap_PossiblyAvailable or FindMap_NotFound.
*/
native bool GetMapDisplayName(const char[] map, char[] displayName, int maxlen);
/**
* Returns whether the server is dedicated.
*
* @return True if dedicated, false otherwise.
*/
native bool IsDedicatedServer();
/**
* Returns a high-precision time value for profiling the engine.
*
* @return A floating point time value.
*/
native float GetEngineTime();
/**
* Returns the game time based on the game tick.
*
* @return Game tick time.
*/
native float GetGameTime();
/**
* Returns the game's internal tick count.
*
* @return Game tick count.
*/
native int GetGameTickCount();
/**
* Returns the time the Game took processing the last frame.
*
* @return Game frame time.
*/
native float GetGameFrameTime();
/**
* Returns the game description from the mod.
*
* @param buffer Buffer to store the description.
* @param maxlength Maximum size of the buffer.
* @param original If true, retrieves the original game description,
* ignoring any potential hooks from plugins.
* @return Number of bytes written to the buffer (UTF-8 safe).
*/
native int GetGameDescription(char[] buffer, int maxlength, bool original=false);
/**
* Returns the name of the game's directory.
*
* @param buffer Buffer to store the directory name.
* @param maxlength Maximum size of the buffer.
* @return Number of bytes written to the buffer (UTF-8 safe).
*/
native int GetGameFolderName(char[] buffer, int maxlength);
/**
* Returns the current map name.
*
* @param buffer Buffer to store map name.
* @param maxlength Maximum length of buffer.
* @return Number of bytes written (UTF-8 safe).
*/
native int GetCurrentMap(char[] buffer, int maxlength);
/**
* Precaches a given model.
*
* @param model Name of the model to precache.
* @param preload If preload is true the file will be precached before level startup.
* @return Returns the model index, 0 for error.
*/
native int PrecacheModel(const char[] model, bool preload=false);
/**
* Precaches a given sentence file.
*
* @param file Name of the sentence file to precache.
* @param preload If preload is true the file will be precached before level startup.
* @return Returns a sentence file index.
*/
native int PrecacheSentenceFile(const char[] file, bool preload=false);
/**
* Precaches a given decal.
*
* @param decal Name of the decal to precache.
* @param preload If preload is true the file will be precached before level startup.
* @return Returns a decal index.
*/
native int PrecacheDecal(const char[] decal, bool preload=false);
/**
* Precaches a given generic file.
*
* @param generic Name of the generic file to precache.
* @param preload If preload is true the file will be precached before level startup.
* @return Returns a generic file index.
*/
native int PrecacheGeneric(const char[] generic, bool preload=false);
/**
* Returns if a given model is precached.
*
* @param model Name of the model to check.
* @return True if precached, false otherwise.
*/
native bool IsModelPrecached(const char[] model);
/**
* Returns if a given decal is precached.
*
* @param decal Name of the decal to check.
* @return True if precached, false otherwise.
*/
native bool IsDecalPrecached(const char[] decal);
/**
* Returns if a given generic file is precached.
*
* @param generic Name of the generic file to check.
* @return True if precached, false otherwise.
*/
native bool IsGenericPrecached(const char[] generic);
/**
* Precaches a given sound.
*
* @param sound Name of the sound to precache.
* @param preload If preload is true the file will be precached before level startup.
* @return True if successfully precached, false otherwise.
*/
native bool PrecacheSound(const char[] sound, bool preload=false);
/**
* Returns if a given sound is precached.
*
* @param sound Name of the sound to check.
* @return True if precached, false otherwise.
* @deprecated Doesn't work correctly, always returns true.
*/
#pragma deprecated Doesn't work correctly, always returns true.
native bool IsSoundPrecached(const char[] sound);
/**
* Creates different types of ingame messages.
*
* @param client Index of the client.
* @param kv KeyValues handle to set the menu keys and options. (Check iserverplugin.h for more information).
* @param type Message type to display ingame.
* @error Invalid client index, or client not in game.
*/
native void CreateDialog(int client, Handle kv, DialogType type);
/**
* Guesses the SDK version a mod was compiled against. If nothing
* specific is known about the game, the engine version is used instead.
*
* The return values are guaranteed to increase chronologically (that is,
* a later release will have a higher value).
*
* @return SOURCE_SDK version code.
* @deprecated See GetEngineVersion()
*/
#pragma deprecated See GetEngineVersion()
native int GuessSDKVersion();
/**
* Gets the engine version that the currently-loaded SM core was compiled against.
*
* The engine version values are not guaranteed to be in any particular order,
* and should only be compared by (in)equality.
*
* @return An EngineVersion value.
*/
native EngineVersion GetEngineVersion();
/**
* Prints a message to a specific client in the chat area.
*
* @param client Client index.
* @param format Formatting rules.
* @param ... Variable number of format parameters.
* @error Invalid client index, or client not in game.
*/
native void PrintToChat(int client, const char[] format, any ...);
/**
* Prints a message to all clients in the chat area.
*
* @param format Formatting rules.
* @param ... Variable number of format parameters.
*/
stock void PrintToChatAll(const char[] format, any ...)
{
char buffer[254];
for (int i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i))
{
SetGlobalTransTarget(i);
VFormat(buffer, sizeof(buffer), format, 2);
PrintToChat(i, "%s", buffer);
}
}
}
/**
* Prints a message to a specific client in the center of the screen.
*
* @param client Client index.
* @param format Formatting rules.
* @param ... Variable number of format parameters.
* @error Invalid client index, or client not in game.
*/
native void PrintCenterText(int client, const char[] format, any ...);
/**
* Prints a message to all clients in the center of the screen.
*
* @param format Formatting rules.
* @param ... Variable number of format parameters.
*/
stock void PrintCenterTextAll(const char[] format, any ...)
{
char buffer[254];
for (int i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i))
{
SetGlobalTransTarget(i);
VFormat(buffer, sizeof(buffer), format, 2);
PrintCenterText(i, "%s", buffer);
}
}
}
/**
* Prints a message to a specific client with a hint box.
*
* @param client Client index.
* @param format Formatting rules.
* @param ... Variable number of format parameters.
* @error Invalid client index, or client not in game.
*/
native void PrintHintText(int client, const char[] format, any ...);
/**
* Prints a message to all clients with a hint box.
*
* @param format Formatting rules.
* @param ... Variable number of format parameters.
*/
stock void PrintHintTextToAll(const char[] format, any ...)
{
char buffer[254];
for (int i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i))
{
SetGlobalTransTarget(i);
VFormat(buffer, sizeof(buffer), format, 2);
PrintHintText(i, "%s", buffer);
}
}
}
/**
* Shows a VGUI panel to a specific client.
*
* @param client Client index.
* @param name Panel type name (Check viewport_panel_names.h to see a list of
* some panel names).
* @param Kv KeyValues handle with all the data for the panel setup (Depends
* on the panel type and may be unused).
* @param show True to show the panel, or false to remove it from the client screen.
* @error Invalid client index, or client not in game.
*/
native void ShowVGUIPanel(int client, const char[] name, Handle Kv=INVALID_HANDLE, bool show=true);
/**
* Creates a HUD synchronization object. This object is used to automatically assign and
* re-use channels for a set of messages.
*
* The HUD has a hardcoded number of channels (usually 6) for displaying
* text. You can use any channel for any area of the screen. Text on
* different channels can overlap, but text on the same channel will
* erase the old text first. This overlapping and overwriting gets problematic.
*
* A HUD synchronization object automatically selects channels for you based on
* the following heuristics:
* - If channel X was last used by the object, and hasn't been modified again,
* channel X gets re-used.
* - Otherwise, a new channel is chosen based on the least-recently-used channel.
*
* This ensures that if you display text on a sync object, that the previous text
* displayed on it will always be cleared first. This is because your new text
* will either overwrite the old text on the same channel, or because another
* channel has already erased your text.
*
* Note that messages can still overlap if they are on different synchronization
* objects, or they are displayed to manual channels.
*
* These are particularly useful for displaying repeating or refreshing HUD text, in
* addition to displaying multiple message sets in one area of the screen (for example,
* center-say messages that may pop up randomly that you don't want to overlap each
* other).
*
* @return New HUD synchronization object.
* The Handle can be closed with CloseHandle().
* If HUD text is not supported on this mod, then
* INVALID_HANDLE is returned.
*/
native HudSync CreateHudSynchronizer();
/**
* Sets the HUD parameters for drawing text. These parameters are stored
* globally, although nothing other than this function and SetHudTextParamsEx
* modify them.
*
* You must call this function before drawing text. If you are drawing
* text to multiple clients, you can set the parameters once, since
* they won't be modified. However, as soon as you pass control back
* to other plugins, you must reset the parameters next time you draw.
*
* @param x x coordinate, from 0 to 1. -1.0 is the center.
* @param y y coordinate, from 0 to 1. -1.0 is the center.
* @param holdTime Number of seconds to hold the text.
* @param r Red color value.
* @param g Green color value.
* @param b Blue color value.
* @param a Alpha transparency value.
* @param effect 0/1 causes the text to fade in and fade out.
* 2 causes the text to flash[?].
* @param fxTime Duration of chosen effect (may not apply to all effects).
* @param fadeIn Number of seconds to spend fading in.
* @param fadeOut Number of seconds to spend fading out.
*/
native void SetHudTextParams(float x, float y, float holdTime, int r, int g, int b, int a, int effect = 0,
float fxTime=6.0, float fadeIn=0.1, float fadeOut=0.2);
/**
* Sets the HUD parameters for drawing text. These parameters are stored
* globally, although nothing other than this function and SetHudTextParams
* modify them.
*
* This is the same as SetHudTextParams(), except it lets you set the alternate
* color for when effects require it.
*
* @param x x coordinate, from 0 to 1. -1.0 is the center.
* @param y y coordinate, from 0 to 1. -1.0 is the center.
* @param holdTime Number of seconds to hold the text.
* @param color1 First color set, array values being [red, green, blue, alpha]
* @param color2 Second color set, array values being [red, green, blue, alpha]
* @param effect 0/1 causes the text to fade in and fade out.
* 2 causes the text to flash[?].
* @param fxTime Duration of chosen effect (may not apply to all effects).
* @param fadeIn Number of seconds to spend fading in.
* @param fadeOut Number of seconds to spend fading out.
*/
native void SetHudTextParamsEx(float x, float y, float holdTime, int color1[4],
int color2[4]={255,255,255,0}, int effect = 0, float fxTime=6.0,
float fadeIn=0.1, float fadeOut=0.2);
/**
* Shows a synchronized HUD message to a client.
*
* As of this writing, only TF, HL2MP, and SourceForts support HUD Text.
*
* @param client Client index to send the message to.
* @param sync Synchronization object.
* @param message Message text or formatting rules.
* @param ... Message formatting parameters.
* @return -1 on failure, anything else on success.
* This function fails if the mod does not support it.
* @error Invalid client index, client not in game, or sync object not valid.
*/
native int ShowSyncHudText(int client, HudSync sync, const char[] message, any ...);
/**
* Clears the text on a synchronized HUD channel.
*
* This is not the same as sending "" because it guarantees that it won't
* overwrite text on another channel. For example, consider the scenario:
*
* 1. Your synchronized message goes to channel 3.
* 2. Someone else's non-synchronized message goes to channel 3.
*
* If you were to simply send "" on your synchronized message,
* then someone else's text could be overwritten.
*
* @param client Client index to send the message to.
* @param sync Synchronization object.
* @error Invalid client index, client not in game, or sync object not valid.
*/
native void ClearSyncHud(int client, HudSync sync);
/**
* Shows a HUD message to a client on the given channel.
*
* As of this writing, only TF, HL2MP, and SourceForts support HUD Text.
*
* @param client Client index to send the message to.
* @param channel A channel number.
* If -1, then a channel will automatically be selected
* based on the least-recently-used channel. If the
* channel is any other number, it will be modulo'd with
* the channel count to get a final channel number.
* @param message Message text or formatting rules.
* @param ... Message formatting parameters.
* @return -1 on failure (lack of mod support).
* Any other return value is the channel number that was
* used to render the text.
* @error Invalid client index, or client not in game.
*/
native int ShowHudText(int client, int channel, const char[] message, any ...);
/**
* Shows a MOTD panel to a specific client.
*
* @param client Client index.
* @param title Title of the panel (printed on the top border of the window).
* @param msg Contents of the panel, it can be treated as an url, filename or plain text
* depending on the type parameter (WARNING: msg has to be 192 bytes maximum!)
* @param type Determines the way to treat the message body of the panel.
* @error Invalid client index, or client not in game.
*/
stock void ShowMOTDPanel(int client, const char[] title, const char[] msg, int type=MOTDPANEL_TYPE_INDEX)
{
char num[3];
IntToString(type, num, sizeof(num));
KeyValues kv = new KeyValues("data");
kv.SetString("title", title);
kv.SetString("type", num);
kv.SetString("msg", msg);
ShowVGUIPanel(client, "info", kv);
delete kv;
}
/**
* Displays a panel asking the client to connect to a specified IP.
*
* @param client Client index.
* @param time Duration to hold the panel on the client's screen.
* @param ip Destination IP.
* @param password Password to connect to the destination IP. The client will be able to see this.
* @error Invalid client index, or client not in game.
*/
stock void DisplayAskConnectBox(int client, float time, const char[] ip, const char[] password = "")
{
char destination[288];
FormatEx(destination, sizeof(destination), "%s/%s", ip, password);
KeyValues kv = new KeyValues("data");
kv.SetFloat("time", time);
kv.SetString("title", destination);
CreateDialog(client, kv, DialogType_AskConnect);
delete kv;
}
/**
* Converts an entity index into a serial encoded entity reference.
*
* @param entity Entity index.
* @return Entity reference or -1 on invalid entity.
* @error Entity index >= GetMaxEntities() or < 0
*/
native int EntIndexToEntRef(int entity);
/**
* Retrieves the entity index from a reference.
*
* @param ref Entity reference.
* @return Entity index or -1 on invalid reference.
*/
native int EntRefToEntIndex(int ref);
/**
* Converts a reference into a backwards compatible version.
*
* @param ref Entity reference.
* @return Bcompat reference.
*/
native int MakeCompatEntRef(int ref);
enum ClientRangeType
{
RangeType_Visibility = 0,
RangeType_Audibility
}
/**
* Find clients that are potentially in range of a position.
*
* @param origin Coordinates from which to test range.
* @param rangeType Range type to use for filtering clients.
* @param clients Array to which found client indexes will be written.
* @param size Maximum size of clients array.
* @return Number of client indexes written to clients array.
*/
native int GetClientsInRange(const float origin[3], ClientRangeType rangeType, int[] clients, int size);
/**
* Retrieves the server's authentication string (SteamID).
*
* Note: If called before server is connected to Steam, auth id
* will be invalid ([I:0:1], 1, etc.)
*
* @param authType Auth id type and format to use.
* (Only AuthId_Steam3 and AuthId_SteamID64 are supported)
* @param auth Buffer to store the server's auth id.
* @param maxlen Maximum length of string buffer (includes NULL terminator).
* @error Invalid AuthIdType given.
*/
native void GetServerAuthId(AuthIdType authType, char[] auth, int maxlen);
/**
* Returns the server's Steam account ID.
*
* @return Steam account ID or 0 if not available.
*/
native int GetServerSteamAccountId();
enum HudSync
{
HudSynchronized_Invalid = -1
}
methodmap HudSync < Handle
{
public HudSync()
{
return CreateHudSynchronizer();
}
public void Clear(int client)
{
ClearSyncHud(client, this);
}
public void Show(int client, const char[] message, any ...)
{
char msg[256];
VFormat(msg, sizeof(msg), message, 3);
ShowSyncHudText(client, this, msg);
}
}