-
Notifications
You must be signed in to change notification settings - Fork 0
New functions: C
dounai_lib has it's own C functions, they are meant to deal with the problems that Lua is just can't be done.
There are 2 references: dounai_lib.c and dounai_lib.C. The lowercase c are the wrapper of the uppercase C, and C will directly access C functions.
Using dounai_lib.c wrapper is always recommended! It contain extra codes with fixes and protection that C can't be done.
dounai_lib.c.LuaInit()This function is automatic executed, you don't have to do it by yourself.
dounai_lib.c.IsInGame()Check if the game is fully loaded, not in the map loading screen or so.
Return: true or false
dounai_lib.c.Msg(message, ...)
-- Wrapper
Msg(message, ...)Print a message to console.
message: string
dounai_lib.c.Warning(message, ...)Print a warning message to console.
message: string
dounai_lib.c.ColorMsg(color, message, ...)
-- Wrapper
MsgC(color, message, ...)
print(...)Print a colored message to console.
color: string, Color or number. Example: red, Color(255, 0, 0) or -16776961
message: string
dounai_lib.c.LoadLua(path)Load a lua file from filesystem, return true on success.
BUG: If the client are old version, loading lua will actually load .elo file.
Return: true or false
path: string. Example: scripts/hello.lua
dounai_lib.c.ReadFileFS(path)Read the file in filesystem and return the whole content.
BUG: This cannot read the encrypted (.e) file properly.
Return: string
path: string. Example: sound/stringtable.txt
dounai_lib.c.FileExists(path)Check if the file are exists in the filesystem.
Return: true or false
path: string. Example: sound/stringtable.txt
dounai_lib.c.IsPlayerFast(pointer)Check if the entity pointer address is a player.
BUG: You must always give this function a valid pointer or the game will crashes because invalid pointer.
This is a internal function, which means in the most of time you won't need this.
Return: true or false
pointer: number
dounai_lib.c.prop_dynamic_create(caller, model)The advanced version of command prop_dynamic_create, can be used on bots and players with no delay (no network traffic).
Return: entity or nil
caller: player
model: string
dounai_lib.c.cso2_canister_shoot(caller, damage, radius)The advanced version of command cso2_canister_shoot, can be used on bots and players with no delay (no network traffic).
The following issues is fixed in our wrapper:
- When the airstrike point is too close from the player, the damage will apply instantly.
- The airstrike missile can kill your teammate.
- The airstrike missile can stuck you for about 0.1 sec, very noticeable when jumping.
Return: entity or nil
caller: player
damage: number
radius: number
dounai_lib.c.ActivateEntity(entity)
-- Wrapper
entity:Activate()Activate the entity. In internal, this call Activate() of the entity.
entity: entity
dounai_lib.c.GetKeyValue(entity, key, isstring)
-- Wrapper
entity:GetKeyValue(key, isstring)Get the key's value.
BUG: If isstring is set to true, but the value isn't a string, game will crash.
Return: string
entity: entity
key: string. Example: origin
isstring: bool
dounai_lib.c.SetKeyValue(entity, key, value)
-- Wrapper
entity:SetKeyValue(key, value)Set the key's value.
entity: entity
key: string. Example: origin
value: string
dounai_lib.c.DeleteWString(wstr)Delete wide string buffer to prevent memory leak.
This is a internal function, which means in the most of time you won't need this.
wstr: wchar_t*
dounai_lib.c.DeleteString(str)Delete string buffer to prevent memory leak.
This is a internal function, which means in the most of time you won't need this.
str: char*
dounai_lib.c.EnDecrypt(text, statickey)Encrypt or decrypt the text, give the plaintext will encrypt it, give the encrypted text will decrypt it.
If statickey is set to false, the encrypted text cannot be decrypted after a game restart.
Return: string
text: string
statickey: bool
dounai_lib.c.StringToWString(str, codepage)Convert string to wstring (UTF-16).
BUG: If you don't call dounai_lib.c.DeleteWString(wstr) after you don't need variable anymore, a memory leak will happens.
Return: wchar_t*
str: string
codepage: number
dounai_lib.c.WStringToString(wstr, codepage)Convert wstring (UTF-16) to string.
Return: string
wstr: wchar_t*
codepage: number
dounai_lib.c.Utf8Length(str)Calculate the correct UTF-8 text (contain non-ASCII character) length.
Return: number
str: string
dounai_lib.c.Utf8Substring(str, start, count)A bug free substring for UTF-8 text (contain non-ASCII character).
Return: string
str: string
start: number
count: number
dounai_lib.c.IsFlagSet(checking_flags, flag)Check if the flag is present in the flags.
Return: true or false
checking_flags: number
flag: number
dounai_lib.c.AddFlag(adding_flags, flag)Add the flag to the flags, if flag is already present, does nothing.
Return: number
adding_flags: number
flag: number
dounai_lib.c.RemoveFlag(removing_flags, flag)Remove the flag from the flags, if flag is not present, does nothing.
Return: number
removing_flags: number
flag: number
dounai_lib.c.HandleToIndex(handle)Convert entity handle to index.
This is a internal function, which means in the most of time you won't need this.
Return: number
handle: number
dounai_lib.c.GetLastCreatedEntityIndex()Get the last created entity index.
Return: number
dounai_lib.c.OverrideGetListenServerHostIndex(index)Override the engine function GetListenServerHost() index to given value.
This is a internal function, which means in the most of time you won't need this.
index: number
dounai_lib.c.BaseGameFixes()Executing this function will fixes the following issues that exist in the base game:
- "Bad SetLocalAngles", this make the rotating entities does not rotate anymore.
- "Bad SetLocalAngularVelocity", this make the rotating entities does not properly rotating (rotate speed).
- "Clamping SetLocalVelocity", this make the non-physics entities cannot have a faster movement speed.
- When player has a activated "game_ui" entity but "Freeze Player" flag isn't preset, the player movement begin lagging.
- When player touches the ladder and then exit, his gravity setting will reset to default 100%.
- Lua API "GetMapName()" return incomplete name if the map name is larger than 32 characters.
- "sv_maxrate" command has a internal hard-coded 1048576 value limit.
- "Unknown command: xxx" message doesn't properly print to the console.
- Modifying "modelscale" keyvalue in the entity doesn't take any affect.
- Lua API "GetEntityByIndex()" doesn't return "worldspawn" when given index is 0.
- Debugging keyword "!picker" is not working.
- "m_iPing" netvar in "CCSPlayerResource" are updating slow and cannot effectively show the player latency.
dounai_lib.c.ZombieEscapePatches(overrideSmokeGrenade)Executing this function will apply several patches to different features to make zombie escape run smoother:
- Disable the 0.66 seconds in-game chat ("say" and "say_team" commands) cooldown.
- Make every grenade projectiles doesn't collide with player.
- Override "env_shake" entity input "StartShake" to "StartShake_2".
- Add "FCVAR_NOTIFY" flag to "mp_restartgame" command, so the "server_cvar" event can detect it.
When overrideSmokeGrenade is true:
- Override the "smokegrenade_projectile" detonate sound ("BaseSmokeEffect.Sound" to "IncGrenade.Explode").
- Override the "smokegrenade_projectile" model name ("w_smokegrenade_thrown.mdl" to "w_incendary_grenade_thrown.mdl").
overrideSmokeGrenade: bool
dounai_lib.c.GetListenServerHostOid()
-- Wrapper
player:IsListenServerHost()Get the listenserver host's server UserID.
This is a internal function, which means in the most of time you won't need this.
Return: number
dounai_lib.c.GetGameTickCount()Get how many tick has passed in server, 1 second = 66 ticks.
Return: number
dounai_lib.c.GetEntityPointer(index)
-- Wrapper
entity:GetPointer()Get the pointer address of entity.
This is a internal function, which means in the most of time you won't need this.
Return: number
index: number
dounai_lib.c.GetEntityIndexByPointer(pointer)Get the entity index by pointer address.
This is a internal function, which means in the most of time you won't need this.
Return: number
pointer: number
dounai_lib.c.GetPlayerResourcePointer()
-- Wrapper
player:GetResourcePointer()Get the player statistics (scoreboard) pointer.
This is a internal function, which means in the most of time you won't need this.
Return: number
dounai_lib.c.GetGameRulesProxyPointer()Get the game rules proxy pointer.
This is a internal function, which means in the most of time you won't need this.
Return: number
dounai_lib.c.MemWriteString(address, value, ispointer)Write a string to the memory.
This is a internal function, which means in the most of time you won't need this.
address: number
value: string
ispointer: bool
dounai_lib.c.MemWriteWString(address, value, ispointer)Write a wide string to the memory.
This is a internal function, which means in the most of time you won't need this.
address: number
value: string
ispointer: bool
dounai_lib.c.UnlockMemProt(address, size)Unlock the memory protection, make them writable.
This is a internal function, which means in the most of time you won't need this.
Return: number
address: number
size: number
dounai_lib.c.LockMemProt(address, size, protect)Lock the memory to given protection.
This is a internal function, which means in the most of time you won't need this.
address: number
size: number
protect: number