This is an interface to IVEngineServer. It has most of the functions (probably about 75%), the ones I didn’t add were either too complex for me to want to do, or completely useless.
I realize that there are a lot of functions that already have lua counterparts, however I added them in anyway for completeness. Also there are some functions that I have no idea what they do. Some of the descriptions in the source files are ambiguous so I actually don’t even know how some are used, and may have guessed the arguments wrong. I have not tested them all either, so some may not work. This is just for people to experiment with.
Please report any crashes or bugs you find.
Download (source + binary):
All the functions are stored in the global table eiface.
format: <returntype> FunctionName(<paramtype> param, ...) AllowImmediateEdictReuse() Tells the engine we can immdiately re-use all edict indices even though we may not have waited enough time AddOriginToPVS(<Vector> origin) Merge the pvs bits into the current accumulated pvs based on the specified origin ( not that each pvs origin has an 8 world unit fudge factor ) <int> CheckAreasConnected(<int> area1, <int> area2) Using area bits, cheeck whether area1 flows into area2 and vice versa (depends on area portal state) ChangeLevel(<string> s1, <string> s2) Tell engine to change level ( "changelevel s1 " or "changelevel2 s1 s2 " ) ChangeTeam(string) I have no idea what this does, it was suggested that it may change the default team. <bool> CheckOriginInPVS(<Vector> origin, <string> checkpvs, <int> checkpvssize) Check whether the specified origin is inside the specified PVS <bool> CheckBoxInPVS(<Vector> mins, <Vector> maxs, <string> checkpvs, <int> checkpvssize) Check whether the specified worldspace bounding box is inside the specified PVS ClearSaveDir() Not sure, probably deletes all save games. ClientCommand(<Player> player, <string> cmd) Issue the specified command to the specified client (mimics that client typing the command at the console). ClientPrintf(<Player> player, <string> msg) Print a message to the client console. <int> <int> CompareFileTime(<string> filename1, <string> filename2) Probably compares the 'last modified' times of two files <bool> CopyFile(<string> source, <string> dest) Copies a file to another file with a different name CreateFakeClient(string) Creates a fake client (like a bot but dumber) by the name of the argument CrosshairAngle(Player, float, float) Claims to 'Set the player's crosshair angle' EmitAmbientSound(<int> entity index, <Vector> position, <string> samp, <float> volume, <Soundlevel> soundlevel, <int> flag, <int> pitch, <float> delay) Emit an ambient sound associated with the specified entity FadeClientVolume(<Player> player, <float> percent, <float> fadeOutSeconds, <float> holdTime, <float> fadeInSeconds) Fade out the client's volume level toward silence (or fadePercent) ForceExactFile(<string> filename) Marks the filename for consistency checking. This should be called after precaching the file. ForceSimpleMaterial(<string> filename?) Marks the material (vmt file) for consistency checking. If the client and server have different contents for the file, the client's vmt can only use the VertexLitGeneric shader, and can only contain $baseTexture and $bumpmap vars. ForceModelBounds(<string> modelname?, <Vector> min, <Vector> max) Not exactly sure, probably just does what the lua functions do and set the min and max bounding boxes of the model. <float> GetAppID() Returns the AppID. What is that? Idk. <int> GetArea(<Vector> origin) Given an origin, determine which area index the origin is within <string> GetClientConVarValue(<int> clientEntityIndex?, <string>convarName?) Get a convar keyvalue for a specified client <string> GetClientSteamID(<Player> player) Returns the SteamID of the specified player. <int> GetEntityCount() Return the current number of used edict slots <string> GetGameDir() Get the current game directory (hl2, tf2, hl1, cstrike, etc.) <string> GetMapEntitiesString() Get the pristine map entity lump string. (e.g., used by CS to reload the map entities when restarting a round.) <string> GetMostRecentlyLoadedFileName() Name of most recently load .sav file <table> GetPlayerInfo(<int> playerEntIndex) Returns a table of data about a client: 1: Name 2: UserID 3: UniqueID Globally unique ID (SteamID) 4: FriendsName (returned blank when I tested) 5: Files downloaded (not sure, says 'this counter increases each time the server downloaded a new file') 6: Files CRC ('custom files CRC for this player') <string> GetPlayerNetworkIDString(<Player> player) No description, though the name is pretty straightforward. <int> GetPlayerUserId(<Player> player) Returns player's user id InsertServerCommand(<string> command) No description, probably just executes a command on the server <bool> IsClientFullyAuthenticated(<Player> player) Returns true if this client has been fully authenticated by Steam <bool> IsDecalPrecached(<string> path?) <bool> IsModelPrecached(<string> path?) <bool> IsGenericPrecached(<string> path?) Check's if the name is precached, but doesn't actually precache the name if not... <bool> IsDedicatedServer() Is this a dedicated server? <int> IsMapValid(<string> filename) Ask engine whether the specified map is a valid map file (exists and has valid version number). LightStyle(<int> style, <string> val) Set the lightstyle to the specified value and network the change to any connected clients. Note that val must not change place in memory (use MAKE_STRING) for anything that's not compiled into your mod. LoadAdjacentEnts(<string> oldLevel, <string>landmarkname) No idea what in blazes this does <bool> LoadGameState(<string> mapName, <bool>createPlayers) Not sure what this does, probably just the equivalent of starting a new map, idk what the bool is for <bool> LockNetworkStringTables(<bool> lockYesOrNo) Locks/unlocks the network string tables (e.g., when adding bots to server, this needs to happen). Be sure to reset the lock after executing your code!!! LogPrint(<string> message) Print a message to the server log file MultiplayerEndGame() File comment is 'Matchmaking' <string> ParseFile(<string> data, <string> token, <int> maxlen) Parse a token from a file, untested <int> PrecacheModel(<string> filepath, <bool> preload = false) <int> PrecacheSentenceFile(<string> filepath, <bool> preload = false) <int> PrecacheDecal(<string> filepath, <bool> preload = false) <int> PrecacheGeneric(<string> filepath, <bool> preload = false) If preload is specified, the file is loaded into the server/client's cache memory before level startup, otherwise it'll only load when actually used (which can cause a disk i/o hitch if it occurs during play of a level). ServerCommand(<string> command) Issue a command to the command parser as if it was typed at the server console. ServerExecute() Execute any commands currently in the command parser immediately (instead of once per frame) SetDedicatedServerBenchmarkMode(<bool> benchmarkmode) This makes the host run 1 tick per frame instead of checking the system timer to see how many ticks to run in a certain frame. i.e. it does the same thing timedemo does. SetFakeClientConVarValue(<Player> player, <string> cvar, <string> value) Sets a USERINFO client ConVar for a fakeclient SetView(<Player> player, <Entity> ent) Change a specified player's "view entity" (i.e., use the view entity position/orientation for rendering the client view) <float> Time() Get an high precision time for doing profiling work <int> GetPVSForCluster(<int> cluster, <int>outputLength) Get the PVS bits for a specified cluster and copy the bits into outputpvs. Returns the number of bytes needed to pack the PVS ResetPVS(<byte> pvs, <int> pvssize) This should be called right before any calls to AddOriginToPVS <int> CheckHeadnodeVisible(<int> nodenum, <byte> pvs, <int> vissize) Given a node number and the specified PVS, return with the node is in the PVS <int> StartQueryCvarValue(<Player> player, <string>conVarName) Call this to find out the value of a cvar on the client.
Feb 8, 10 - Added GetPVSForCluster, ResetPVS, and CheckHeadnodeVisible
Feb 9, 10 - Added StartQueryCvarValue (QueryCvarCookie_t return type was intimidating, lol @ typedef int. Is pretty much only of any use in conjunction with gm_sourcenet)
Huge thanks as always to Chrisaster who continues to put up with me and help me.