Skip to content

New functions: Global

dounai2333 edited this page Jan 24, 2025 · 1 revision

Introduction

dounai_lib provide some global functions that was easy to understand and having much less characters, without having to refer dounai_lib variable:

CurTime

CurTime()

Returns the uptime of the server in seconds.

Return: number

Entity

Entity(index)

This is advanced version of original GetEntityByIndex(), and will automatic convert entity to it's proper type.

Return: entity, player, weapon and mathCounter or nil

index: number

Player

Player(userid)

This is a rename of original GetPlayerByUserId(), providing less characters in general for easier coding.

Return: player or nil

userid: number

IsValid

IsValid(ent)

Check whether an entity is valid or not. Can be also used with dounai_lib.cfg.Parse() and dounai_lib.csv.Parse() result.

When checking worldspawn entity, this will return false, use IsWorldspawn() instead.

Return: true or false

ent: entity

IsWorldspawn

IsWorldspawn(ent)

Check whether an entity is worldspawn.

Return: true or false

ent: entity

Msg

Msg(message, ...)

Print a message to console.

message: string

MsgC

MsgC(color, message, ...)

Print a colored message to console.

color: string, Color or number. Example: red, Color(255, 0, 0) or -16776961

message: string

printf

printf(str, ...)

Print a message to console, with formating.

str: string

PrintTable

PrintTable(table)

Print everything in the table to the console.

BUG: If the table is too large, this function will does nothing due to buffer overflow.

table: table

Clone this wiki locally