-
-
Notifications
You must be signed in to change notification settings - Fork 0
Client
Twiitchter edited this page Oct 8, 2021
·
10 revisions
Contains a relationship table based on the default groups, plus any additional custom groups you may manage, to then iterate over in loops to set aggression, peace or other factors.
--- Returns Groups after merging the default and Newly created groups.
function c.affil.GetGroups()
local newgroups = c.table.merge(groups, defaultgroups)
return newgroups
end--- [Internal Function] - Add the created group to a table.
---@param name string "Name of group : 'NAME'"
---@param grouphash string "Hash number of the group, typically starts with: '0x'"
---@param relations table "'Table of relations to iterate over : {["Companion"] = {}, ["Respect"] = {}, ["Like"] = {}, ["Nutral"] = {}, ["Dislike"] = {}, ["Hate"] = {}}'"
function c.affil.AddGroupToTable(name, grouphash, relations)
if not groups[name] then
groups[name] = {["hash"] = grouphash, ["relations"] = relations}
end
end--- Returns the cappitalized name as entered and hash of the new group.
---@param str string "Can be lower case, will convert to UPPERCASE"
---@param relations table "'Table of relations to iterate over : {["Companion"] = {}, ["Respect"] = {}, ["Like"] = {}, ["Nutral"] = {}, ["Dislike"] = {}, ["Hate"] = {}}'"
function c.affil.CreateGroup(str, relations)
local name = c.check.String(string.upper(str))
local _, grouphash = AddRelationshipGroup(name)
c.affil.AddGroupToTable(name, grouphash, relations)
return name, grouphash
endProvides a few premade animations as an example, registered to event, bound to command within _commands.lua.
Gets the time set by the server, leveraging convar "Time" Note - "Server Time" is the convar for the real time of the server where is hosted, Pre being altered.
--- Get the current server time based on the GetConvar("Time").
function c.time.GetTime()
local time = GetConvar("Time", "00:00")
local hour = tonumber(time:sub(1,2))
local min = tonumber(time:sub(4,5))
return {hour, min}
endThis alters a local variable that is then used on a loop to set the time constantly. I used to leverage a set milliseconds per minute native. But it stopped working at some point... to test out again eventually.
-- Set a timeout loop to request the time again.
function c.time.UpdateTime()
time = c.time.GetTime()
local function Do()
time = c.time.GetTime()
SetTimeout(c.min, Do)
end
SetTimeout(c.min, Do)
end