-
Notifications
You must be signed in to change notification settings - Fork 3
Utitlies
Konijima edited this page Jul 12, 2022
·
2 revisions
Edit or add new utility functions into:
lua/shared/MyModName/Utils.lua
Import the Utils:
local Utils = require 'MyModName/Utils'Or use the Client & Server object:
Client.Utils
Server.UtilsCheck if the script is running in SinglePlayer.
IsSinglePlayer()Check if the current client is admin or debug mode enabled.
IsClientAdminOrDebug()Check if a mod is activated.
IsModActive(modName)Get a player object from a username (function work on both client and server)
GetPlayerFromUsername(username)Write a string to a file.
WriteFile(filename, str)Read a file and return the content as a string.
ReadFile(filename)Write a table to a file as a json string.
WriteTable(filename, tbl)Read a json string from a file and return a table.
ReadTable(filename)Convert a table to json string.
TableToJson(data)Convert a json string to table.
JsonToTable(str)