From 5b04f40c6e6aafc764210b43cb871726488f47a4 Mon Sep 17 00:00:00 2001 From: Zoephix Date: Tue, 16 Feb 2021 18:02:09 +0100 Subject: [PATCH 01/56] Area timer optimizations --- plugins/area/sh_plugin.lua | 55 +++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/plugins/area/sh_plugin.lua b/plugins/area/sh_plugin.lua index b6015b04..88c9e763 100644 --- a/plugins/area/sh_plugin.lua +++ b/plugins/area/sh_plugin.lua @@ -54,6 +54,27 @@ if (SERVER) then return clientPos:WithinAABox(areaData.minVector, areaData.maxVector), areaData end + function PLUGIN:createAreaTimer() + timer.Create("nutAreaController", 0.33, 0, function() + for k, v in ipairs(player.GetAll()) do + local char = v:getChar() + + if (char and v:Alive()) then + local area = v:getArea() + for id, areaData in pairs(nut.area.getAllArea()) do + local clientPos = v:GetPos() + v:OBBCenter() + + if (clientPos:WithinAABox(areaData.minVector, areaData.maxVector) and area != id) then + v.curArea = id + + hook.Run("OnPlayerAreaChanged", v, id) + end + end + end + end + end) + end + -- This is for continous check (ex: checking gas area whatever.) function playerMeta:getArea() return self.curArea @@ -65,6 +86,10 @@ if (SERVER) then function PLUGIN:LoadData() self.areaTable = self:getData() or {} + + if (#self.areaTable > 0) then + self:createAreaTimer() + end end function PLUGIN:PlayerLoadedChar(client, character, lastChar) @@ -115,28 +140,6 @@ if (SERVER) then PLUGIN:saveAreas() end - -- Timer instead of heavy think. - timer.Create("nutAreaController", 0.33, 0, function() - for k, v in ipairs(player.GetAll()) do - local char = v:getChar() - - if (char and v:Alive()) then - local area = v:getArea() - for id, areaData in pairs(nut.area.getAllArea()) do - local clientPos = v:GetPos() + v:OBBCenter() - - if (clientPos:WithinAABox(areaData.minVector, areaData.maxVector)) then - if (area != id) then - v.curArea = id - - hook.Run("OnPlayerAreaChanged", v, id) - end - end - end - end - end - end) - -- If area is changed, set display Area's Name to the client's screen. function PLUGIN:OnPlayerAreaChanged(client, areaID) local areaData = nut.area.getArea(areaID) @@ -414,6 +417,10 @@ nut.command.add("areaadd", { nut.area.addArea(name, min, max) + if (SERVER and !timer.Exists("nutAreaController")) then + PLUGIN:createAreaTimer() + end + return "@areaAdded", name end end @@ -434,6 +441,10 @@ nut.command.add("arearemove", { table.remove(PLUGIN.areaTable, areaID) PLUGIN:saveAreas() + if (SERVER and #nut.area.getAllArea() < 1) then + timer.Remove("nutAreaController") + end + return "@areaRemoved", areaData.name end end From 4a28c5862de91bd8a4526785f713f73357ae0ebb Mon Sep 17 00:00:00 2001 From: Zoephix Date: Wed, 17 Feb 2021 12:57:13 +0100 Subject: [PATCH 02/56] Update database configuration loading (again) (#21) --- gamemode/core/libs/sv_database.lua | 62 ++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 17 deletions(-) diff --git a/gamemode/core/libs/sv_database.lua b/gamemode/core/libs/sv_database.lua index 6a1789a1..902d9100 100644 --- a/gamemode/core/libs/sv_database.lua +++ b/gamemode/core/libs/sv_database.lua @@ -1,8 +1,6 @@ nut.db = nut.db or {} nut.db.queryQueue = nut.db.queue or {} -nut.util.include("nutscript/gamemode/config/sv_database.lua") - local function ThrowQueryFault(query, fault) MsgC(Color(255, 0, 0), "* "..query.."\n") MsgC(Color(255, 0, 0), fault.."\n") @@ -76,10 +74,8 @@ modules.tmysql4 = { local queryStatus, queryError, affected, lastID, time, data = result.status, result.error, result.affected, result.lastid, result.time, result.data - if (queryStatus and queryStatus == true) then - if (callback) then - callback(data, lastID) - end + if (queryStatus and queryStatus == true and callback) then + callback(data, lastID) end else file.Write("nut_queryerror.txt", query) @@ -189,7 +185,7 @@ modules.mysqloo = { for k, db in pairs(nut.db.pool) do local queueSize = db:queueSize() - if (!lowest || queueSize < lowestCount) then + if (!lowest or queueSize < lowestCount) then lowest = db lowestCount = queueSize lowestIndex = k @@ -207,7 +203,7 @@ modules.mysqloo = { return setNetVar("dbError", system.IsWindows() and "Server is missing VC++ redistributables!" or "Server is missing binaries for mysqloo!") end - if (mysqloo.VERSION != "9" || !mysqloo.MINOR_VERSION || tonumber(mysqloo.MINOR_VERSION) < 1) then + if (mysqloo.VERSION != "9" or !mysqloo.MINOR_VERSION or tonumber(mysqloo.MINOR_VERSION) < 1) then MsgC(Color(255, 0, 0), "You are using an outdated mysqloo version\n") MsgC(Color(255, 0, 0), "Download the latest mysqloo9 from here\n") MsgC(Color(86, 156, 214), "https://github.com/syl0r/MySQLOO/releases") @@ -251,7 +247,7 @@ modules.mysqloo = { if (callback) then callback() end - + hook.Run("OnMySQLOOConnected") end end @@ -356,7 +352,6 @@ CREATE TABLE IF NOT EXISTS `nut_players` ( `_intro` BINARY(1) NULL DEFAULT 0, PRIMARY KEY (`_steamID`) ); - CREATE TABLE IF NOT EXISTS `nut_characters` ( `_id` INT(12) NOT NULL AUTO_INCREMENT, `_steamID` VARCHAR(20) NOT NULL COLLATE 'utf8mb4_general_ci', @@ -372,14 +367,12 @@ CREATE TABLE IF NOT EXISTS `nut_characters` ( `_faction` VARCHAR(24) DEFAULT NULL COLLATE 'utf8mb4_general_ci', PRIMARY KEY (`_id`) ); - CREATE TABLE IF NOT EXISTS `nut_inventories` ( `_invID` INT(12) NOT NULL AUTO_INCREMENT, `_charID` INT(12) NULL DEFAULT NULL, `_invType` VARCHAR(24) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci', PRIMARY KEY (`_invID`) ); - CREATE TABLE IF NOT EXISTS `nut_items` ( `_itemID` INT(12) NOT NULL AUTO_INCREMENT, `_invID` INT(12) NULL DEFAULT NULL, @@ -390,7 +383,6 @@ CREATE TABLE IF NOT EXISTS `nut_items` ( `_y` INT(4), PRIMARY KEY (`_itemID`) ); - CREATE TABLE IF NOT EXISTS `nut_invdata` ( `_invID` INT(12) NOT NULL, `_key` VARCHAR(32) NOT NULL COLLATE 'utf8mb4_general_ci', @@ -409,7 +401,6 @@ CREATE TABLE IF NOT EXISTS nut_players ( _data varchar, _intro binary ); - CREATE TABLE IF NOT EXISTS nut_characters ( _id integer PRIMARY KEY AUTOINCREMENT, _steamID varchar, @@ -424,13 +415,11 @@ CREATE TABLE IF NOT EXISTS nut_characters ( _money varchar, _faction varchar ); - CREATE TABLE IF NOT EXISTS nut_inventories ( _invID integer PRIMARY KEY AUTOINCREMENT, _charID integer, _invType varchar ); - CREATE TABLE IF NOT EXISTS nut_items ( _itemID integer PRIMARY KEY AUTOINCREMENT, _invID integer, @@ -440,7 +429,6 @@ CREATE TABLE IF NOT EXISTS nut_items ( _x integer, _y integer ); - CREATE TABLE IF NOT EXISTS nut_invdata ( _invID integer, _key text, @@ -684,6 +672,46 @@ function nut.db.delete(dbTable, condition) return d end +local defaultConfig = { + module = "sqlite", + hostname = "127.0.0.1", + username = "", + password = "", + database = "", + port = 3306 +} + +local validConfig = { + engine.ActiveGamemode().."/database.json", + engine.ActiveGamemode().."/nutscript.json", + "nutscript/database.json", + "nutscript/nutscript.json" +} + +function GM:SetupDatabase() + for _, configPath in ipairs(validConfig) do + local config = file.Read(tostring(configPath), "LUA") + + if (config) then + nut.db.config = config + + for k, v in pairs(util.JSONToTable(nut.db.config)) do + nut.db[k] = v + end + + break + end + end + + if (not nut.db.config) then + MsgC(Color(255, 0, 0), "Database not configured.\n") + + for k, v in pairs(defaultConfig) do + nut.db[k] = v + end + end +end + function GM:OnMySQLOOConnected() hook.Run("RegisterPreparedStatements") MYSQLOO_PREPARED = true From ac684929fcb3b4e5c75cdc778a35d9d07067b154 Mon Sep 17 00:00:00 2001 From: Zoephix Date: Wed, 17 Feb 2021 12:58:06 +0100 Subject: [PATCH 03/56] Create database.example --- database.example | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 database.example diff --git a/database.example b/database.example new file mode 100644 index 00000000..f60d3420 --- /dev/null +++ b/database.example @@ -0,0 +1,8 @@ +{ + "module": "sqlite", + "hostname": "127.0.0.1", + "username": "", + "password": "", + "database": "", + "port": 3306 +} From c2da5731a305da50f2a1b4d33b212e152cbf036f Mon Sep 17 00:00:00 2001 From: Zoephix Date: Wed, 17 Feb 2021 13:08:22 +0100 Subject: [PATCH 04/56] Added persistence plugin (#23) --- plugins/persistence.lua | 176 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 176 insertions(+) create mode 100644 plugins/persistence.lua diff --git a/plugins/persistence.lua b/plugins/persistence.lua new file mode 100644 index 00000000..82f0f713 --- /dev/null +++ b/plugins/persistence.lua @@ -0,0 +1,176 @@ +PLUGIN.name = "Persistence" +PLUGIN.desc = "Saves persisted entities through restarts." +PLUGIN.author = "Zoephix" + +-- Storage for persisted map entities +PLUGIN.entities = PLUGIN.entities or {} + +-- Entities which are blocked from interaction +PLUGIN.blacklist = PLUGIN.blacklist or { + [ "func_button" ] = true, + [ "class C_BaseEntity" ] = true, + [ "func_brush" ] = true, + [ "func_tracktrain" ] = true, + [ "func_door" ] = true, + [ "func_door_rotating" ] = true, + [ "prop_door_rotating" ] = true, + [ "prop_static" ] = true, + [ "prop_dynamic" ] = true, + [ "prop_physics_override" ] = true, +} + +properties.Add( "persist", { + MenuLabel = "#makepersistent", + Order = 400, + MenuIcon = "icon16/link.png", + + Filter = function( self, ent, ply ) + + if ( ent:IsPlayer() ) then return false end + if ( PLUGIN.blacklist[ent:GetClass()] ) then return false end + if ( !gamemode.Call( "CanProperty", ply, "persist", ent ) ) then return false end + + return !ent:getNetVar( "persistent", false ) + + end, + + Action = function( self, ent ) + + self:MsgStart() + net.WriteEntity( ent ) + self:MsgEnd() + + end, + + Receive = function( self, length, ply ) + + local ent = net.ReadEntity() + if ( !IsValid( ent ) ) then return end + if ( !self:Filter( ent, ply ) ) then return end + + ent:setNetVar( "persistent", true ) + + -- Register the entity + PLUGIN.entities[#PLUGIN.entities + 1] = ent + + -- Add new log + nut.log.add(ply, "persistedEntity", ent ) + end + +} ) + +properties.Add( "persist_end", { + MenuLabel = "#stoppersisting", + Order = 400, + MenuIcon = "icon16/link_break.png", + + Filter = function( self, ent, ply ) + + if ( ent:IsPlayer() ) then return false end + if ( !gamemode.Call( "CanProperty", ply, "persist", ent ) ) then return false end + + return ent:getNetVar( "persistent", false ) + + end, + + Action = function( self, ent ) + + self:MsgStart() + net.WriteEntity( ent ) + self:MsgEnd() + + end, + + Receive = function( self, length, ply ) + + local ent = net.ReadEntity() + if ( !IsValid( ent ) ) then return end + if ( !properties.CanBeTargeted( ent, ply ) ) then return end + if ( !self:Filter( ent, ply ) ) then return end + + ent:setNetVar( "persistent", false ) + + -- Remove entity from registration + for k, v in ipairs(PLUGIN.entities) do + if (v == entity) then + PLUGIN.entities[k] = nil + + break + end + end + + -- Add new log + nut.log.add(ply, "unpersistedEntity", ent ) + end + +} ) + +if (SERVER) then + nut.log.addType("persistedEntity", function(client, entity) + return string.format("%s has persisted '%s'.", client:Name(), entity) + end) + + nut.log.addType("unpersistedEntity", function(client, entity) + return string.format("%s has removed persistence from '%s'.", client:Name(), entity) + end) + + -- Prevent from picking up persisted entities + function PLUGIN:PhysgunPickup(client, entity) + if (entity:getNetVar("persistent", false)) then + return false + end + end + + function PLUGIN:SaveData() + local data = {} + + for k, v in ipairs(self.entities) do + if (IsValid(v)) then + local entData = {} + entData.class = v:GetClass() + entData.pos = v:GetPos() + entData.angles = v:GetAngles() + entData.model = v:GetModel() + entData.skin = v:GetSkin() + entData.color = v:GetColor() + entData.material = v:GetMaterial() + entData.bodygroups = v:GetBodyGroups() + + local physicsObject = v:GetPhysicsObject() + if (IsValid(physicsObject)) then + entData.moveable = physicsObject:IsMoveable() + end + + data[#data +1] = entData + end + end + self:setData(data) + end + + function PLUGIN:LoadData() + for k, v in pairs(self:getData() or {}) do + local ent = ents.Create(v.class) + ent:SetPos(v.pos) + ent:SetAngles(v.angles) + ent:SetModel(v.model) + ent:SetSkin(v.skin) + ent:SetColor(v.color) + ent:SetMaterial(v.material) + ent:Spawn() + ent:Activate() + + for _, data in pairs(v.bodygroups) do + ent:SetBodygroup(data.id, data.num) + end + + local physicsObject = ent:GetPhysicsObject() + if (IsValid(physicsObject)) then + physicsObject:EnableMotion(ent.moveable or false) + end + + ent:setNetVar("persistent", true) + + self.entities[#self.entities + 1] = ent + end + end +end From 8767578497f74deb7daf4a9cc0b9b440d617e8b7 Mon Sep 17 00:00:00 2001 From: Zoephix Date: Wed, 17 Feb 2021 13:16:44 +0100 Subject: [PATCH 05/56] snip --- plugins/persistence.lua | 176 ---------------------------------------- 1 file changed, 176 deletions(-) delete mode 100644 plugins/persistence.lua diff --git a/plugins/persistence.lua b/plugins/persistence.lua deleted file mode 100644 index 82f0f713..00000000 --- a/plugins/persistence.lua +++ /dev/null @@ -1,176 +0,0 @@ -PLUGIN.name = "Persistence" -PLUGIN.desc = "Saves persisted entities through restarts." -PLUGIN.author = "Zoephix" - --- Storage for persisted map entities -PLUGIN.entities = PLUGIN.entities or {} - --- Entities which are blocked from interaction -PLUGIN.blacklist = PLUGIN.blacklist or { - [ "func_button" ] = true, - [ "class C_BaseEntity" ] = true, - [ "func_brush" ] = true, - [ "func_tracktrain" ] = true, - [ "func_door" ] = true, - [ "func_door_rotating" ] = true, - [ "prop_door_rotating" ] = true, - [ "prop_static" ] = true, - [ "prop_dynamic" ] = true, - [ "prop_physics_override" ] = true, -} - -properties.Add( "persist", { - MenuLabel = "#makepersistent", - Order = 400, - MenuIcon = "icon16/link.png", - - Filter = function( self, ent, ply ) - - if ( ent:IsPlayer() ) then return false end - if ( PLUGIN.blacklist[ent:GetClass()] ) then return false end - if ( !gamemode.Call( "CanProperty", ply, "persist", ent ) ) then return false end - - return !ent:getNetVar( "persistent", false ) - - end, - - Action = function( self, ent ) - - self:MsgStart() - net.WriteEntity( ent ) - self:MsgEnd() - - end, - - Receive = function( self, length, ply ) - - local ent = net.ReadEntity() - if ( !IsValid( ent ) ) then return end - if ( !self:Filter( ent, ply ) ) then return end - - ent:setNetVar( "persistent", true ) - - -- Register the entity - PLUGIN.entities[#PLUGIN.entities + 1] = ent - - -- Add new log - nut.log.add(ply, "persistedEntity", ent ) - end - -} ) - -properties.Add( "persist_end", { - MenuLabel = "#stoppersisting", - Order = 400, - MenuIcon = "icon16/link_break.png", - - Filter = function( self, ent, ply ) - - if ( ent:IsPlayer() ) then return false end - if ( !gamemode.Call( "CanProperty", ply, "persist", ent ) ) then return false end - - return ent:getNetVar( "persistent", false ) - - end, - - Action = function( self, ent ) - - self:MsgStart() - net.WriteEntity( ent ) - self:MsgEnd() - - end, - - Receive = function( self, length, ply ) - - local ent = net.ReadEntity() - if ( !IsValid( ent ) ) then return end - if ( !properties.CanBeTargeted( ent, ply ) ) then return end - if ( !self:Filter( ent, ply ) ) then return end - - ent:setNetVar( "persistent", false ) - - -- Remove entity from registration - for k, v in ipairs(PLUGIN.entities) do - if (v == entity) then - PLUGIN.entities[k] = nil - - break - end - end - - -- Add new log - nut.log.add(ply, "unpersistedEntity", ent ) - end - -} ) - -if (SERVER) then - nut.log.addType("persistedEntity", function(client, entity) - return string.format("%s has persisted '%s'.", client:Name(), entity) - end) - - nut.log.addType("unpersistedEntity", function(client, entity) - return string.format("%s has removed persistence from '%s'.", client:Name(), entity) - end) - - -- Prevent from picking up persisted entities - function PLUGIN:PhysgunPickup(client, entity) - if (entity:getNetVar("persistent", false)) then - return false - end - end - - function PLUGIN:SaveData() - local data = {} - - for k, v in ipairs(self.entities) do - if (IsValid(v)) then - local entData = {} - entData.class = v:GetClass() - entData.pos = v:GetPos() - entData.angles = v:GetAngles() - entData.model = v:GetModel() - entData.skin = v:GetSkin() - entData.color = v:GetColor() - entData.material = v:GetMaterial() - entData.bodygroups = v:GetBodyGroups() - - local physicsObject = v:GetPhysicsObject() - if (IsValid(physicsObject)) then - entData.moveable = physicsObject:IsMoveable() - end - - data[#data +1] = entData - end - end - self:setData(data) - end - - function PLUGIN:LoadData() - for k, v in pairs(self:getData() or {}) do - local ent = ents.Create(v.class) - ent:SetPos(v.pos) - ent:SetAngles(v.angles) - ent:SetModel(v.model) - ent:SetSkin(v.skin) - ent:SetColor(v.color) - ent:SetMaterial(v.material) - ent:Spawn() - ent:Activate() - - for _, data in pairs(v.bodygroups) do - ent:SetBodygroup(data.id, data.num) - end - - local physicsObject = ent:GetPhysicsObject() - if (IsValid(physicsObject)) then - physicsObject:EnableMotion(ent.moveable or false) - end - - ent:setNetVar("persistent", true) - - self.entities[#self.entities + 1] = ent - end - end -end From f863518115307d50b0492ca9d459b13a422683e4 Mon Sep 17 00:00:00 2001 From: Zoephix Date: Wed, 17 Feb 2021 13:16:55 +0100 Subject: [PATCH 06/56] 1.2 wip (#24) * Add persistence plugin * lua consistency newlines and || vs or * Removed restrictions plugin alliances * Update sv_database.lua * whitespace * Update sh_plugin.lua * Revert "Merge pull request #10 from Zoephix/1.2-wip" This reverts commit 944229f4eb9fc74af5dba8259c689ba28881e243. * Revert "Update sh_plugin.lua" This reverts commit 57cc63e3b3d687afc9fae6b88f9cdb732b2b3ed6. * yet another date modification, this time, lightweight * Removed already defined starting time * Update database configuration loading * Added date migrations * Added date migrations * Update chatbox icons * As suggested, timer runs only on day change rather than every 5 minutes * Update README.md * doesnt exist anymore * Added more valid config locations * Update config loading * Update config loading * Update config loading * Added example database configuration * Added credits tab * Added hover sound * whitespace * Credits tab (WIP) * Added contributors to the credits * Increased spacing, extra polishing * Increased font size Co-authored-by: TovarischPootis <54110479+TovarischPootis@users.noreply.github.com> --- .gitignore | 3 +- database.example.json | 8 + gamemode/config/sv_database.lua | 52 -- gamemode/core/hooks/sv_hooks.lua | 2 +- gamemode/core/libs/sh_character.lua | 2 +- gamemode/core/libs/sh_chatbox.lua | 16 +- gamemode/core/libs/sh_date.lua | 232 +++---- gamemode/core/libs/thirdparty/sh_date.lua | 740 ---------------------- gamemode/core/sh_config.lua | 1 - gamemode/nutscript.example.json | 8 + plugins/f1menu/derma/cl_helps.lua | 166 ++++- plugins/f1menu/derma/cl_information.lua | 4 +- plugins/persistence.lua | 178 ++++++ 13 files changed, 439 insertions(+), 973 deletions(-) create mode 100644 database.example.json delete mode 100644 gamemode/config/sv_database.lua delete mode 100644 gamemode/core/libs/thirdparty/sh_date.lua create mode 100644 gamemode/nutscript.example.json create mode 100644 plugins/persistence.lua diff --git a/.gitignore b/.gitignore index 759a803f..754392b8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ -gamemode/config/sv_database.lua .editorconfig -.vscode/* \ No newline at end of file +.vscode/* diff --git a/database.example.json b/database.example.json new file mode 100644 index 00000000..ae8db1d1 --- /dev/null +++ b/database.example.json @@ -0,0 +1,8 @@ +{ + "module": "sqlite", + "hostname": "127.0.0.1", + "username": "", + "password": "", + "database": "", + "port": 3306 +} \ No newline at end of file diff --git a/gamemode/config/sv_database.lua b/gamemode/config/sv_database.lua deleted file mode 100644 index d8ba5bae..00000000 --- a/gamemode/config/sv_database.lua +++ /dev/null @@ -1,52 +0,0 @@ ---[[ - Welcome to the NutScript database configuration. - Here, you can change what method of data storage you would prefer. - - The following methods are available: - - tmysql4 - - https://code.google.com/p/blackawps-glua-modules/source/browse/gm_tmysql4_boost/Release/ - - Includes both Windows and Linux - - Requires setup (see below) - - mysqloo - - http://facepunch.com/showthread.php?t=1357773 - - Includes both Windows and Linux - - Requires setup (see below) - - sqlite - - No download needed - - No setup required - - If you want to use an external database (tmysql4 and mysqloo) then - you will need to place the included .dll files into your server's - lua/bin folder. Then place the libmysql files (tmysql's website says libs.rar and - the mysqloo thread contains a link labeled libmysql) in the folder that contains - srcds. - - The benefits of using an external database: - - You can display stats on your website. - - Can share data between servers. - - Each to access data than with SQLite (SQLite data is stored in the sv.db file) - Cons: - - Requires setup - - Some server providers do not allow the uploading of .dll files so you may need - to ask them for support. - - Is not as instant as SQLite (but the delay should be barely noticable) - - The following configurations are ONLY needed if you are going to be using an - external database for your NutScript installation. ---]] - - -function GM:SetupDatabase() - -- Which method of storage: sqlite, tmysql4, mysqloo - nut.db.module = "sqlite" - -- The hostname for the MySQL server. - nut.db.hostname = "127.0.0.1" - -- The username to login to the database. - nut.db.username = "root" - -- The password that is associated with the username. - nut.db.password = "" - -- The database that the user should login to. - nut.db.database = "nutscript" - -- The port for the database, you shouldn't need to change this. - nut.db.port = 3306 -end \ No newline at end of file diff --git a/gamemode/core/hooks/sv_hooks.lua b/gamemode/core/hooks/sv_hooks.lua index 2abb4241..3bb1743f 100644 --- a/gamemode/core/hooks/sv_hooks.lua +++ b/gamemode/core/hooks/sv_hooks.lua @@ -660,7 +660,7 @@ Issues with ULX/Ulib on your server will be ignored and we're going to consider that you're taking the risk of ULX/Ulib's critical performance issue. -Nutscript 1.1 only displays this message when you have ULX or +Nutscript 1.2 only displays this message when you have ULX or ULib on your server. -Nutscript Development Team diff --git a/gamemode/core/libs/sh_character.lua b/gamemode/core/libs/sh_character.lua index d8c78b02..a6694a1a 100644 --- a/gamemode/core/libs/sh_character.lua +++ b/gamemode/core/libs/sh_character.lua @@ -11,7 +11,7 @@ if (SERVER) then if (not nut.db) then include("sv_database.lua") end - + -- Fetches all the character names and stores -- them into a table so they only have to be fetched once if (#nut.char.names < 1) then diff --git a/gamemode/core/libs/sh_chatbox.lua b/gamemode/core/libs/sh_chatbox.lua index 8eff1c63..76454686 100644 --- a/gamemode/core/libs/sh_chatbox.lua +++ b/gamemode/core/libs/sh_chatbox.lua @@ -278,15 +278,19 @@ do end, onChatAdd = function(speaker, text) local icon = "icon16/user.png" - - -- man, I did all that works and I deserve differnet icon on ooc chat + local customIcons = { + ["STEAM_0:1:34930764"] = "icon16/script_gear.png", -- Chessnut + ["STEAM_0:0:19814083"] = "icon16/gun.png", -- Black Tea the edgiest man + ["STEAM_0:0:50197118"] = "icon16/script_gear.png", -- Zoephix + ["STEAM_0:1:55088012"] = "icon16/script_gear.png" -- TovarischPootis + } + + -- man, I did all that works and I deserve different icon on ooc chat -- if you dont like it -- well.. -- it's on your own. - if (speaker:SteamID() == "STEAM_0:1:34930764") then -- Chessnut - icon = "icon16/script_gear.png" - elseif (speaker:SteamID() == "STEAM_0:0:19814083") then -- Black Tea the edgiest man - icon = "icon16/gun.png" + if (customIcons[speaker:SteamID()]) then + icon = customIcons[speaker:SteamID()] elseif (speaker:IsSuperAdmin()) then icon = "icon16/shield.png" elseif (speaker:IsAdmin()) then diff --git a/gamemode/core/libs/sh_date.lua b/gamemode/core/libs/sh_date.lua index 8b94241d..d0fe8516 100644 --- a/gamemode/core/libs/sh_date.lua +++ b/gamemode/core/libs/sh_date.lua @@ -1,180 +1,114 @@ ---------------------------------------------------------------------------------------- -- Module for date and time calculations --- --- Version 2.1.2 --- Copyright (C) 2006, by Jas Latrix (jastejada@yahoo.com) --- Copyright (C) 2013-2014, by Thijs Schreijer --- Licensed under MIT, http://opensource.org/licenses/MIT --- https://github.com/Tieske/date --- The MIT License (MIT) http://opensource.org/licenses/MIT - --- Copyright (c) 2013-2017 Thijs Schreijer --- Copyright (c) 2018 Alexander Grist-Hucker, Igor Radovanovic - --- lib based on Helix by Alexander Grist-Hucker, Igor Radovanovic 2018 - --- due to UNIX time, normal os.time() cannnot be set before 1970, as 1st Jan 1970 is 0 --- the library fixes said issue. - nut.date = nut.date or {} -nut.date.lib = nut.date.lib or include("thirdparty/sh_date.lua") -nut.date.timeScale = nut.date.timeScale or nut.config.get("secondsPerMinute", 60) -nut.date.dateObj = nut.date.dateObj or nut.date.lib() -nut.date.start = nut.date.start or CurTime() if (not nut.config) then - include("nutscript/gamemode/core/sh_config.lua") + include("nutscript/gamemode/core/sh_config.lua") end -nut.config.add("year", 2021, "The starting year of the schema.", function(oldValue, newValue) - if (SERVER and not nut.date.saving) then - nut.date.update() - nut.date.dateObj:setyear(newValue) - nut.date.sync() - end -end, { - data = {min = 0, max = 4000}, - category = "date" -}) +nut.config.add("year", tonumber(os.date("%Y")), "The current year of the schema." , nil, { + data = {min = 0, max = 4000}, + category = "date" +} +) -nut.config.add("month", 1, "The starting month of the schema.", function(oldValue, newValue) - if (SERVER and not nut.date.saving) then - nut.date.update() - nut.date.dateObj:setmonth(newValue) - nut.date.sync() - end -end, { - data = {min = 1, max = 12}, - category = "date" -}) +nut.config.add("month", tonumber(os.date("%m")), "The current month of the schema." , nil, { + data = {min = 1, max = 12}, + category = "date" +} +) -nut.config.add("day", 1, "The starting day of the schema.", function(oldValue, newValue) - if (SERVER and not nut.date.saving) then - nut.date.update() - nut.date.dateObj:setday(newValue) - nut.date.sync() - end -end, { - data = {min = 1, max = 31}, - category = "date" -}) - -nut.config.add("secondsPerMinute", 60, "How many real life seconds it takes for a minute to pass in-game.", function(oldValue, newValue) - if (SERVER and not nut.date.saving) then - nut.date.updateTimescale(newValue) - nut.date.sync() - end -end, { - data = {min = 0.01, max = 120}, - category = "date" -}) +nut.config.add("day", tonumber(os.date("%d")), "The current day of the schema." , nil, { + data = {min = 1, max = 31}, + category = "date" +} +) nut.config.add("yearAppendix", "", "Add a custom appendix to your date, if you use a non-conventional calender", nil, { data = {form = "Generic"}, category = "date" -}) - -if (SERVER) then - util.AddNetworkString("nutDateSync") - - -- called upon server startup. Grabs the saved date data, or creates a new date instance, and sets it as the date object - function nut.date.initialize() - local currentDate = nut.data.get("date", nil, false, true) - -- If we don't have date data already, use current defaults to create a new date data table - if (not currentDate) then - currentDate = { - year = nut.config.get("year"), - month = nut.config.get("month"), - day = nut.config.get("day"), - hour = tonumber(os.date("%H")) or 0, - min = tonumber(os.date("%M")) or 0, - sec = tonumber(os.date("%S")) or 0, - } - - currentDate = nut.date.lib.serialize(nut.date.lib(currentDate)) - - nut.data.set("date", currentDate, false, true) -- save the new data - end +} +) - nut.date.timeScale = nut.config.get("secondsPerMinute", 60) - nut.date.dateObj = nut.date.lib.construct(currentDate) -- update the date object with the initialized data - end +-- function returns a number that represents the custom time. the year is always the current year for +-- compatibility, though it can be editted with nut.date.getFormatted - -- Called when date values have been manually changed, updating the date object. - function nut.date.update() - nut.date.dateObj = nut.date.get() - nut.date.start = CurTime() - end +function nut.date.get() + return os.time({ + year=os.date("%Y"), + month=nut.config.get("month"), + day=nut.config.get("day"), + hour=os.date("%H"), + min=os.date("%M"), + sec=os.date("%S") + }) +end - -- This is an internal function that sets the amount of real life seconds in an ingame minute. While you can use this function, - --you probably shouldn't, and rather use the ingame config. - function nut.date.updateTimescale(secondsPerMinute) - nut.date.update() - nut.date.timeScale = secondsPerMinute - end +--function takes the time number if provided, or current time and applies a string format to it - --Syncs the current date with the client/s. This allows the players to have proper date representation, such as in the F1menu. - function nut.date.sync(client) - net.Start("nutDateSync") - net.WriteFloat(nut.date.timeScale) - net.WriteTable(nut.date.dateObj) - net.WriteFloat(nut.date.start) - - if (client) then - net.Send(client) - else - net.Broadcast() - end - end +function nut.date.getFormatted(format, dateNum) + return os.date(format, dateNum or nut.date.get()) +end - -- saves the current in-game date data. - function nut.date.save() - nut.date.saving = true -- prevents from the function from being called before it finishes. +if SERVER then - nut.date.update() + -- This is internal, though you can use it you probably shouldn't. + -- Checks the time difference between the old time values and current time, and updates month and day to advance in the time difference + -- creates a timer that updates the month and day values, in case the server runs continuously without restarts. + function nut.date.initialize() - nut.data.set("date", nut.date.lib.serialize(nut.date.dateObj), false, true) -- saves the current data object + -- Migrations + if (istable(nut.data.get("date", os.time(), true))) then + nut.data.set("date", os.time(), true, true) + end - -- update config to reflect current saved date - nut.config.set("year", nut.date.dateObj:getyear()) - nut.config.set("month", nut.date.dateObj:getmonth()) - nut.config.set("day", nut.date.dateObj:getday()) + local configTime = os.time({ + year = tonumber(os.date("%Y")), + month = tonumber(nut.config.get("month")), + day = tonumber(nut.config.get("day")), + hour = tonumber(os.date("%H")), + min = os.date("%M"), + sec = os.date("%S") + }) + os.difftime(os.time(), nut.data.get("date", os.time(), true)) + + nut.config.set("month", tonumber(os.date("%m", configTime))) + nut.config.set("day", tonumber(os.date("%d", configTime))) + + -- internal function that calculates when the day ends, and updates the month/day when the next day comes. + -- the reason for this complication instead of just upvaluing day/month by 1 is that some months have 28, 30 or 31 days. + -- and its simpler for the server to decide what the next month should be rather than manually computing that + local function updateDateConfigs() + local curDateTable = os.date("*t") -- get the current date table + local remainingSeconds = (curDateTable.hour * -3600 - curDateTable.min * 60 - curDateTable.sec) % 86400 -- get the remaining seconds until the new day + + timer.Simple(remainingSeconds, function() -- run this code only once the day changes + local newTime = os.time({ + year = tonumber(os.date("%Y")), + month = tonumber(nut.config.get("month")), + day = tonumber(nut.config.get("day")), + hour = tonumber(os.date("%H")), + min = os.date("%M"), + sec = os.date("%S") + }) + 86400 -- 24 hours. + + nut.config.set("month", tonumber(os.date("%m", newTime))) + nut.config.set("day", tonumber(os.date("%d", newTime))) + updateDateConfigs() -- create a new timer for the next day + end) + end - nut.date.saving = nil -- allows the date to be saved again + updateDateConfigs() end -else - net.Receive("nutDateSync", function() -- set the clientside values to the updated serverside date values - nut.date.timeScale = net.ReadFloat() - nut.date.dateObj = nut.date.lib.construct(net.ReadTable()) - nut.date.start = net.ReadFloat() - print("synced") - PrintTable(nut.date.dateObj) - end) -end ---- Returns the currently set date. -function nut.date.get() - -- CurTime increases in value by 1 every second. By getting the difference in seconds between now and the date object initialization, - local minutesSinceStart = (CurTime() - nut.date.start) / nut.date.timeScale --and divide it by the timescale, we get the minutes elapsed to add to the date start - - return nut.date.dateObj:copy():addminutes(minutesSinceStart) -end - ---- Returns a string formatted version of a date. -function nut.date.getFormatted(format, currentDate) - return (currentDate or nut.date.get()):fmt(format) -end + -- saves the current actual time. This allows the time to find the difference in elapsed time between server shutdown and startup + function nut.date.save() + nut.data.set("date", os.time(), true, true) + end -if SERVER then - hook.Add("InitializedSchema", "nutInitializeTime", function() + hook.Add("InitializedConfig", "nutInitializeTime", function() nut.date.initialize() end) - hook.Add("PlayerInitialSpawn", "nutDateSync", function(client) - nut.date.sync(client) - end) - hook.Add("SaveData", "nutDateSave", function() nut.date.save() end) diff --git a/gamemode/core/libs/thirdparty/sh_date.lua b/gamemode/core/libs/thirdparty/sh_date.lua deleted file mode 100644 index 983eeddb..00000000 --- a/gamemode/core/libs/thirdparty/sh_date.lua +++ /dev/null @@ -1,740 +0,0 @@ ---------------------------------------------------------------------------------------- --- Module for date and time calculations --- --- Version 2.1.2 --- Copyright (C) 2006, by Jas Latrix (jastejada@yahoo.com) --- Copyright (C) 2013-2014, by Thijs Schreijer --- Licensed under MIT, http://opensource.org/licenses/MIT - ---[[ CONSTANTS ]]-- - local HOURPERDAY = 24 - local MINPERHOUR = 60 - local MINPERDAY = 1440 -- 24*60 - local SECPERMIN = 60 - local SECPERHOUR = 3600 -- 60*60 - local SECPERDAY = 86400 -- 24*60*60 - local TICKSPERSEC = 1000000 - local TICKSPERDAY = 86400000000 - local TICKSPERHOUR = 3600000000 - local TICKSPERMIN = 60000000 - local DAYNUM_MAX = 365242500 -- Sat Jan 01 1000000 00:00:00 - local DAYNUM_MIN = -365242500 -- Mon Jan 01 1000000 BCE 00:00:00 - local DAYNUM_DEF = 0 -- Mon Jan 01 0001 00:00:00 - local _; ---[[ LOCAL ARE FASTER ]]-- - local type = type - local pairs = pairs - local error = error - local assert = assert - local tonumber = tonumber - local tostring = tostring - local string = string - local math = math - local os = os - local unpack = unpack or table.unpack - local setmetatable = setmetatable - local getmetatable = getmetatable ---[[ EXTRA FUNCTIONS ]]-- - local fmt = string.format - local lwr = string.lower - local rep = string.rep - local len = string.len -- luacheck: ignore - local sub = string.sub - local gsub = string.gsub - local gmatch = string.gmatch or string.gfind - local find = string.find - local ostime = os.time - local osdate = os.date - local floor = math.floor - local ceil = math.ceil - local abs = math.abs - -- removes the decimal part of a number - local function fix(n) n = tonumber(n) return n and ((n > 0 and floor or ceil)(n)) end - -- returns the modulo n % d; - local function mod(n,d) return n - d*floor(n/d) end - -- is `str` in string list `tbl`, `ml` is the minimun len - local function inlist(str, tbl, ml, tn) - local sl = len(str) - if sl < (ml or 0) then return nil end - str = lwr(str) - for k, v in pairs(tbl) do - if str == lwr(sub(v, 1, sl)) then - if tn then tn[0] = k end - return k - end - end - end - local function fnil() end ---[[ DATE FUNCTIONS ]]-- - local DATE_EPOCH -- to be set later - local sl_weekdays = { - [0]="Sunday",[1]="Monday",[2]="Tuesday",[3]="Wednesday",[4]="Thursday",[5]="Friday",[6]="Saturday", - [7]="Sun",[8]="Mon",[9]="Tue",[10]="Wed",[11]="Thu",[12]="Fri",[13]="Sat", - } - local sl_meridian = {[-1]="AM", [1]="PM"} - local sl_months = { - [00]="January", [01]="February", [02]="March", - [03]="April", [04]="May", [05]="June", - [06]="July", [07]="August", [08]="September", - [09]="October", [10]="November", [11]="December", - [12]="Jan", [13]="Feb", [14]="Mar", - [15]="Apr", [16]="May", [17]="Jun", - [18]="Jul", [19]="Aug", [20]="Sep", - [21]="Oct", [22]="Nov", [23]="Dec", - } - -- added the '.2' to avoid collision, use `fix` to remove - local sl_timezone = { - [000]="utc", [0.2]="gmt", - [300]="est", [240]="edt", - [360]="cst", [300.2]="cdt", - [420]="mst", [360.2]="mdt", - [480]="pst", [420.2]="pdt", - } - -- set the day fraction resolution - local function setticks(t) - TICKSPERSEC = t; - TICKSPERDAY = SECPERDAY*TICKSPERSEC - TICKSPERHOUR= SECPERHOUR*TICKSPERSEC - TICKSPERMIN = SECPERMIN*TICKSPERSEC - end - -- is year y leap year? - local function isleapyear(y) -- y must be int! - return (mod(y, 4) == 0 and (mod(y, 100) ~= 0 or mod(y, 400) == 0)) - end - -- day since year 0 - local function dayfromyear(y) -- y must be int! - return 365*y + floor(y/4) - floor(y/100) + floor(y/400) - end - -- day number from date, month is zero base - local function makedaynum(y, m, d) - local mm = mod(mod(m,12) + 10, 12) - return dayfromyear(y + floor(m/12) - floor(mm/10)) + floor((mm*306 + 5)/10) + d - 307 - --local yy = y + floor(m/12) - floor(mm/10) - --return dayfromyear(yy) + floor((mm*306 + 5)/10) + (d - 1) - end - -- date from day number, month is zero base - local function breakdaynum(g) - local g = g + 306 - local y = floor((10000*g + 14780)/3652425) - local d = g - dayfromyear(y) - if d < 0 then y = y - 1; d = g - dayfromyear(y) end - local mi = floor((100*d + 52)/3060) - return (floor((mi + 2)/12) + y), mod(mi + 2,12), (d - floor((mi*306 + 5)/10) + 1) - end - --[[ for floats or int32 Lua Number data type - local function breakdaynum2(g) - local g, n = g + 306; - local n400 = floor(g/DI400Y);n = mod(g,DI400Y); - local n100 = floor(n/DI100Y);n = mod(n,DI100Y); - local n004 = floor(n/DI4Y); n = mod(n,DI4Y); - local n001 = floor(n/365); n = mod(n,365); - local y = (n400*400) + (n100*100) + (n004*4) + n001 - ((n001 == 4 or n100 == 4) and 1 or 0) - local d = g - dayfromyear(y) - local mi = floor((100*d + 52)/3060) - return (floor((mi + 2)/12) + y), mod(mi + 2,12), (d - floor((mi*306 + 5)/10) + 1) - end - ]] - -- day fraction from time - local function makedayfrc(h,r,s,t) - return ((h*60 + r)*60 + s)*TICKSPERSEC + t - end - -- time from day fraction - local function breakdayfrc(df) - return - mod(floor(df/TICKSPERHOUR),HOURPERDAY), - mod(floor(df/TICKSPERMIN ),MINPERHOUR), - mod(floor(df/TICKSPERSEC ),SECPERMIN), - mod(df,TICKSPERSEC) - end - -- weekday sunday = 0, monday = 1 ... - local function weekday(dn) return mod(dn + 1, 7) end - -- yearday 0 based ... - local function yearday(dn) - return dn - dayfromyear((breakdaynum(dn))-1) - end - -- parse v as a month - local function getmontharg(v) - local m = tonumber(v); - return (m and fix(m - 1)) or inlist(tostring(v) or "", sl_months, 2) - end - -- get daynum of isoweek one of year y - local function isow1(y) - local f = makedaynum(y, 0, 4) -- get the date for the 4-Jan of year `y` - local d = weekday(f) - d = d == 0 and 7 or d -- get the ISO day number, 1 == Monday, 7 == Sunday - return f + (1 - d) - end - local function isowy(dn) - local w1; - local y = (breakdaynum(dn)) - if dn >= makedaynum(y, 11, 29) then - w1 = isow1(y + 1); - if dn < w1 then - w1 = isow1(y); - else - y = y + 1; - end - else - w1 = isow1(y); - if dn < w1 then - w1 = isow1(y-1) - y = y - 1 - end - end - return floor((dn-w1)/7)+1, y - end - local function isoy(dn) - local y = (breakdaynum(dn)) - return y + (((dn >= makedaynum(y, 11, 29)) and (dn >= isow1(y + 1))) and 1 or (dn < isow1(y) and -1 or 0)) - end - local function makedaynum_isoywd(y,w,d) - return isow1(y) + 7*w + d - 8 -- simplified: isow1(y) + ((w-1)*7) + (d-1) - end ---[[ THE DATE MODULE ]]-- - local fmtstr = "%x %X"; ---#if not DATE_OBJECT_AFX then - local date = {} - setmetatable(date, date) --- Version: VMMMRRRR; V-Major, M-Minor, R-Revision; e.g. 5.45.321 == 50450321 - date.version = 20010003 -- 2.1.3 ---#end -- not DATE_OBJECT_AFX ---[[ THE DATE OBJECT ]]-- - local dobj = {} - dobj.__index = dobj - dobj.__metatable = dobj - -- shout invalid arg - local function date_error_arg() return error("invalid argument(s)",0) end - -- create new date object - local function date_new(dn, df) - return setmetatable({daynum=dn, dayfrc=df}, dobj) - end - - local function date_isdobj(v) - return (istable(v) and getmetatable(v) == dobj) and v - end ---#if not NO_LOCAL_TIME_SUPPORT then - -- magic year table - local date_epoch, yt; - local function getequivyear(y) - assert(not yt) - yt = {} - local de = date_epoch:copy() - local dw, dy - for _ = 0, 3000 do - de:setyear(de:getyear() + 1, 1, 1) - dy = de:getyear() - dw = de:getweekday() * (isleapyear(dy) and -1 or 1) - if not yt[dw] then yt[dw] = dy end --print(de) - if yt[1] and yt[2] and yt[3] and yt[4] and yt[5] and yt[6] and yt[7] and yt[-1] and yt[-2] and yt[-3] and yt[-4] and yt[-5] and yt[-6] and yt[-7] then - getequivyear = function(y) return yt[ (weekday(makedaynum(y, 0, 1)) + 1) * (isleapyear(y) and -1 or 1) ] end - return getequivyear(y) - end - end - end - -- TimeValue from date and time - local function totv(y,m,d,h,r,s) - return (makedaynum(y, m, d) - DATE_EPOCH) * SECPERDAY + ((h*60 + r)*60 + s) - end - -- TimeValue from TimeTable - local function tmtotv(tm) - return tm and totv(tm.year, tm.month - 1, tm.day, tm.hour, tm.min, tm.sec) - end - -- Returns the bias in seconds of utc time daynum and dayfrc - local function getbiasutc2(self) - local y,m,d = breakdaynum(self.daynum) - local h,r,s = breakdayfrc(self.dayfrc) - local tvu = totv(y,m,d,h,r,s) -- get the utc TimeValue of date and time - local tml = osdate("*t", tvu) -- get the local TimeTable of tvu - if (not tml) or (tml.year > (y+1) or tml.year < (y-1)) then -- failed try the magic - y = getequivyear(y) - tvu = totv(y,m,d,h,r,s) - tml = osdate("*t", tvu) - end - local tvl = tmtotv(tml) - if tvu and tvl then - return tvu - tvl, tvu, tvl - else - return error("failed to get bias from utc time") - end - end - -- Returns the bias in seconds of local time daynum and dayfrc - local function getbiasloc2(daynum, dayfrc) - local tvu - -- extract date and time - local y,m,d = breakdaynum(daynum) - local h,r,s = breakdayfrc(dayfrc) - -- get equivalent TimeTable - local tml = {year=y, month=m+1, day=d, hour=h, min=r, sec=s} - -- get equivalent TimeValue - local tvl = tmtotv(tml) - - local function chkutc() - tml.isdst = nil; local tvug = ostime(tml) if tvug and (tvl == tmtotv(osdate("*t", tvug))) then tvu = tvug return end - tml.isdst = true; local tvud = ostime(tml) if tvud and (tvl == tmtotv(osdate("*t", tvud))) then tvu = tvud return end - tvu = tvud or tvug - end - chkutc() - if not tvu then - tml.year = getequivyear(y) - tvl = tmtotv(tml) - chkutc() - end - return ((tvu and tvl) and (tvu - tvl)) or error("failed to get bias from local time"), tvu, tvl - end ---#end -- not NO_LOCAL_TIME_SUPPORT - ---#if not DATE_OBJECT_AFX then - -- the date parser - local strwalker = {} -- ^Lua regular expression is not as powerful as Perl$ - strwalker.__index = strwalker - local function newstrwalker(s)return setmetatable({s=s, i=1, e=1, c=len(s)}, strwalker) end - function strwalker:aimchr() return "\n" .. self.s .. "\n" .. rep(".",self.e-1) .. "^" end - function strwalker:finish() return self.i > self.c end - function strwalker:back() self.i = self.e return self end - function strwalker:restart() self.i, self.e = 1, 1 return self end - function strwalker:match(s) return (find(self.s, s, self.i)) end - function strwalker:__call(s, f)-- print("strwalker:__call "..s..self:aimchr()) - local is, ie; is, ie, self[1], self[2], self[3], self[4], self[5] = find(self.s, s, self.i) - if is then self.e, self.i = self.i, 1+ie; if f then f(unpack(self)) end return self end - end - local function date_parse(str) - local y,m,d, h,r,s, z, w,u, j, e, x,c, dn,df - local sw = newstrwalker(gsub(gsub(str, "(%b())", ""),"^(%s*)","")) -- remove comment, trim leading space - --local function error_out() print(y,m,d,h,r,s) end - local function error_dup(q) --[[error_out()]] error("duplicate value: " .. (q or "") .. sw:aimchr()) end - local function error_syn(q) --[[error_out()]] error("syntax error: " .. (q or "") .. sw:aimchr()) end - local function error_inv(q) --[[error_out()]] error("invalid date: " .. (q or "") .. sw:aimchr()) end - local function sety(q) y = y and error_dup() or tonumber(q); end - local function setm(q) m = (m or w or j) and error_dup(m or w or j) or tonumber(q) end - local function setd(q) d = d and error_dup() or tonumber(q) end - local function seth(q) h = h and error_dup() or tonumber(q) end - local function setr(q) r = r and error_dup() or tonumber(q) end - local function sets(q) s = s and error_dup() or tonumber(q) end - local function adds(q) s = s + tonumber(q) end - local function setj(q) j = (m or w or j) and error_dup() or tonumber(q); end - local function setz(q) z = (z ~= 0 and z) and error_dup() or q end - local function setzn(zs,zn) zn = tonumber(zn); setz( ((zn<24) and (zn*60) or (mod(zn,100) + floor(zn/100) * 60))*( zs=='+' and -1 or 1) ) end - local function setzc(zs,zh,zm) setz( ((tonumber(zh)*60) + tonumber(zm))*( zs=='+' and -1 or 1) ) end - - if not (sw("^(%d%d%d%d)",sety) and (sw("^(%-?)(%d%d)%1(%d%d)",function(_,a,b) setm(tonumber(a)); setd(tonumber(b)) end) or sw("^(%-?)[Ww](%d%d)%1(%d?)",function(_,a,b) w, u = tonumber(a), tonumber(b or 1) end) or sw("^%-?(%d%d%d)",setj) or sw("^%-?(%d%d)",function(a) setm(a);setd(1) end)) - and ((sw("^%s*[Tt]?(%d%d):?",seth) and sw("^(%d%d):?",setr) and sw("^(%d%d)",sets) and sw("^(%.%d+)",adds)) - or sw:finish() or (sw"^%s*$" or sw"^%s*[Zz]%s*$" or sw("^%s-([%+%-])(%d%d):?(%d%d)%s*$",setzc) or sw("^%s*([%+%-])(%d%d)%s*$",setzn)) - ) ) - then --print(y,m,d,h,r,s,z,w,u,j) - sw:restart(); y,m,d,h,r,s,z,w,u,j = nil,nil,nil,nil,nil,nil,nil,nil,nil,nil - repeat -- print(sw:aimchr()) - if sw("^[tT:]?%s*(%d%d?):",seth) then --print("$Time") - _ = sw("^%s*(%d%d?)",setr) and sw("^%s*:%s*(%d%d?)",sets) and sw("^(%.%d+)",adds) - elseif sw("^(%d+)[/\\%s,-]?%s*") then --print("$Digits") - x, c = tonumber(sw[1]), len(sw[1]) - if (x >= 70) or (m and d and (not y)) or (c > 3) then - sety( x + ((x >= 100 or c>3)and 0 or 1900) ) - else - if m then setd(x) else m = x end - end - elseif sw("^(%a+)[/\\%s,-]?%s*") then --print("$Words") - x = sw[1] - if inlist(x, sl_months, 2, sw) then - if m and (not d) and (not y) then d, m = m, false end - setm(mod(sw[0],12)+1) - elseif inlist(x, sl_timezone, 2, sw) then - c = fix(sw[0]) -- ignore gmt and utc - if c ~= 0 then setz(c, x) end - elseif not inlist(x, sl_weekdays, 2, sw) then - sw:back() - -- am pm bce ad ce bc - if sw("^([bB])%s*(%.?)%s*[Cc]%s*(%2)%s*[Ee]%s*(%2)%s*") or sw("^([bB])%s*(%.?)%s*[Cc]%s*(%2)%s*") then - e = e and error_dup() or -1 - elseif sw("^([aA])%s*(%.?)%s*[Dd]%s*(%2)%s*") or sw("^([cC])%s*(%.?)%s*[Ee]%s*(%2)%s*") then - e = e and error_dup() or 1 - elseif sw("^([PApa])%s*(%.?)%s*[Mm]?%s*(%2)%s*") then - x = lwr(sw[1]) -- there should be hour and it must be correct - if (not h) or (h > 12) or (h < 0) then return error_inv() end - if x == 'a' and h == 12 then h = 0 end -- am - if x == 'p' and h ~= 12 then h = h + 12 end -- pm - else error_syn() end - end - elseif not(sw("^([+-])(%d%d?):(%d%d)",setzc) or sw("^([+-])(%d+)",setzn) or sw("^[Zz]%s*$")) then -- sw{"([+-])",{"(%d%d?):(%d%d)","(%d+)"}} - error_syn("?") - end - sw("^%s*") until sw:finish() - --else print("$Iso(Date|Time|Zone)") - end - -- if date is given, it must be complete year, month & day - if (not y and not h) or ((m and not d) or (d and not m)) or ((m and w) or (m and j) or (j and w)) then return error_inv("!") end - -- fix month - if m then m = m - 1 end - -- fix year if we are on BCE - if e and e < 0 and y > 0 then y = 1 - y end - -- create date object - dn = (y and ((w and makedaynum_isoywd(y,w,u)) or (j and makedaynum(y, 0, j)) or makedaynum(y, m, d))) or DAYNUM_DEF - df = makedayfrc(h or 0, r or 0, s or 0, 0) + ((z or 0)*TICKSPERMIN) - --print("Zone",h,r,s,z,m,d,y,df) - return date_new(dn, df) -- no need to :normalize(); - end - local function date_fromtable(v) - local y, m, d = fix(v.year), getmontharg(v.month), fix(v.day) - local h, r, s, t = tonumber(v.hour), tonumber(v.min), tonumber(v.sec), tonumber(v.ticks) - -- atleast there is time or complete date - if (y or m or d) and (not(y and m and d)) then return error("incomplete table") end - return (y or h or r or s or t) and date_new(y and makedaynum(y, m, d) or DAYNUM_DEF, makedayfrc(h or 0, r or 0, s or 0, t or 0)) - end - local tmap = { - ['number'] = function(v) return date_epoch:copy():addseconds(v) end, - ['string'] = function(v) return date_parse(v) end, - ['boolean']= function(v) return date_fromtable(osdate(v and "!*t" or "*t")) end, - ['table'] = function(v) local ref = getmetatable(v) == dobj; return ref and v or date_fromtable(v), ref end - } - local function date_getdobj(v) - local o, r = (tmap[type(v)] or fnil)(v); - return (o and o:normalize() or error"invalid date time value"), r -- if r is true then o is a reference to a date obj - end ---#end -- not DATE_OBJECT_AFX - local function date_from(arg1, arg2, arg3, arg4, arg5, arg6, arg7) - local y, m, d = fix(arg1), getmontharg(arg2), fix(arg3) - local h, r, s, t = tonumber(arg4 or 0), tonumber(arg5 or 0), tonumber(arg6 or 0), tonumber(arg7 or 0) - if y and m and d and h and r and s and t then - return date_new(makedaynum(y, m, d), makedayfrc(h, r, s, t)):normalize() - else - return date_error_arg() - end - end - - --[[ THE DATE OBJECT METHODS ]]-- - function dobj:normalize() - local dn, df = fix(self.daynum), self.dayfrc - self.daynum, self.dayfrc = dn + floor(df/TICKSPERDAY), mod(df, TICKSPERDAY) - return (dn >= DAYNUM_MIN and dn <= DAYNUM_MAX) and self or error("date beyond imposed limits:"..self) - end - - function dobj:getdate() local y, m, d = breakdaynum(self.daynum) return y, m+1, d end - function dobj:gettime() return breakdayfrc(self.dayfrc) end - - function dobj:getclockhour() local h = self:gethours() return h>12 and mod(h,12) or (h==0 and 12 or h) end - - function dobj:getyearday() return yearday(self.daynum) + 1 end - function dobj:getweekday() return weekday(self.daynum) + 1 end -- in lua weekday is sunday = 1, monday = 2 ... - - function dobj:getyear() local r,_,_ = breakdaynum(self.daynum) return r end - function dobj:getmonth() local _,r,_ = breakdaynum(self.daynum) return r+1 end-- in lua month is 1 base - function dobj:getday() local _,_,r = breakdaynum(self.daynum) return r end - function dobj:gethours() return mod(floor(self.dayfrc/TICKSPERHOUR),HOURPERDAY) end - function dobj:getminutes() return mod(floor(self.dayfrc/TICKSPERMIN), MINPERHOUR) end - function dobj:getseconds() return mod(floor(self.dayfrc/TICKSPERSEC ),SECPERMIN) end - function dobj:getfracsec() return mod(floor(self.dayfrc/TICKSPERSEC ),SECPERMIN)+(mod(self.dayfrc,TICKSPERSEC)/TICKSPERSEC) end - function dobj:getticks(u) local x = mod(self.dayfrc,TICKSPERSEC) return u and ((x*u)/TICKSPERSEC) or x end - - function dobj:getweeknumber(wdb) - local wd, yd = weekday(self.daynum), yearday(self.daynum) - if wdb then - wdb = tonumber(wdb) - if wdb then - wd = mod(wd-(wdb-1),7)-- shift the week day base - else - return date_error_arg() - end - end - return (yd < wd and 0) or (floor(yd/7) + ((mod(yd, 7)>=wd) and 1 or 0)) - end - - function dobj:getisoweekday() return mod(weekday(self.daynum)-1,7)+1 end -- sunday = 7, monday = 1 ... - function dobj:getisoweeknumber() return (isowy(self.daynum)) end - function dobj:getisoyear() return isoy(self.daynum) end - function dobj:getisodate() - local w, y = isowy(self.daynum) - return y, w, self:getisoweekday() - end - function dobj:setisoyear(y, w, d) - local cy, cw, cd = self:getisodate() - if y then cy = fix(tonumber(y))end - if w then cw = fix(tonumber(w))end - if d then cd = fix(tonumber(d))end - if cy and cw and cd then - self.daynum = makedaynum_isoywd(cy, cw, cd) - return self:normalize() - else - return date_error_arg() - end - end - - function dobj:setisoweekday(d) return self:setisoyear(nil, nil, d) end - function dobj:setisoweeknumber(w,d) return self:setisoyear(nil, w, d) end - - function dobj:setyear(y, m, d) - local cy, cm, cd = breakdaynum(self.daynum) - if y then cy = fix(tonumber(y))end - if m then cm = getmontharg(m) end - if d then cd = fix(tonumber(d))end - if cy and cm and cd then - self.daynum = makedaynum(cy, cm, cd) - return self:normalize() - else - return date_error_arg() - end - end - - function dobj:setmonth(m, d)return self:setyear(nil, m, d) end - function dobj:setday(d) return self:setyear(nil, nil, d) end - - function dobj:sethours(h, m, s, t) - local ch,cm,cs,ck = breakdayfrc(self.dayfrc) - ch, cm, cs, ck = tonumber(h or ch), tonumber(m or cm), tonumber(s or cs), tonumber(t or ck) - if ch and cm and cs and ck then - self.dayfrc = makedayfrc(ch, cm, cs, ck) - return self:normalize() - else - return date_error_arg() - end - end - - function dobj:setminutes(m,s,t) return self:sethours(nil, m, s, t) end - function dobj:setseconds(s, t) return self:sethours(nil, nil, s, t) end - function dobj:setticks(t) return self:sethours(nil, nil, nil, t) end - - function dobj:spanticks() return (self.daynum*TICKSPERDAY + self.dayfrc) end - function dobj:spanseconds() return (self.daynum*TICKSPERDAY + self.dayfrc)/TICKSPERSEC end - function dobj:spanminutes() return (self.daynum*TICKSPERDAY + self.dayfrc)/TICKSPERMIN end - function dobj:spanhours() return (self.daynum*TICKSPERDAY + self.dayfrc)/TICKSPERHOUR end - function dobj:spandays() return (self.daynum*TICKSPERDAY + self.dayfrc)/TICKSPERDAY end - - function dobj:addyears(y, m, d) - local cy, cm, cd = breakdaynum(self.daynum) - if y then y = fix(tonumber(y))else y = 0 end - if m then m = fix(tonumber(m))else m = 0 end - if d then d = fix(tonumber(d))else d = 0 end - if y and m and d then - self.daynum = makedaynum(cy+y, cm+m, cd+d) - return self:normalize() - else - return date_error_arg() - end - end - - function dobj:addmonths(m, d) - return self:addyears(nil, m, d) - end - - local function dobj_adddayfrc(self,n,pt,pd) - n = tonumber(n) - if n then - local x = floor(n/pd); - self.daynum = self.daynum + x; - self.dayfrc = self.dayfrc + (n-x*pd)*pt; - return self:normalize() - else - return date_error_arg() - end - end - function dobj:adddays(n) return dobj_adddayfrc(self,n,TICKSPERDAY,1) end - function dobj:addhours(n) return dobj_adddayfrc(self,n,TICKSPERHOUR,HOURPERDAY) end - function dobj:addminutes(n) return dobj_adddayfrc(self,n,TICKSPERMIN,MINPERDAY) end - function dobj:addseconds(n) return dobj_adddayfrc(self,n,TICKSPERSEC,SECPERDAY) end - function dobj:addticks(n) return dobj_adddayfrc(self,n,1,TICKSPERDAY) end - local tvspec = { - -- Abbreviated weekday name (Sun) - ['%a']=function(self) return sl_weekdays[weekday(self.daynum) + 7] end, - -- Full weekday name (Sunday) - ['%A']=function(self) return sl_weekdays[weekday(self.daynum)] end, - -- Abbreviated month name (Dec) - ['%b']=function(self) return sl_months[self:getmonth() - 1 + 12] end, - -- Full month name (December) - ['%B']=function(self) return sl_months[self:getmonth() - 1] end, - -- Year/100 (19, 20, 30) - ['%C']=function(self) return fmt("%.2d", fix(self:getyear()/100)) end, - -- The day of the month as a number (range 1 - 31) - ['%d']=function(self) return fmt("%.2d", self:getday()) end, - -- year for ISO 8601 week, from 00 (79) - ['%g']=function(self) return fmt("%.2d", mod(self:getisoyear() ,100)) end, - -- year for ISO 8601 week, from 0000 (1979) - ['%G']=function(self) return fmt("%.4d", self:getisoyear()) end, - -- same as %b - ['%h']=function(self) return self:fmt0("%b") end, - -- hour of the 24-hour day, from 00 (06) - ['%H']=function(self) return fmt("%.2d", self:gethours()) end, - -- The hour as a number using a 12-hour clock (01 - 12) - ['%I']=function(self) return fmt("%.2d", self:getclockhour()) end, - -- The day of the year as a number (001 - 366) - ['%j']=function(self) return fmt("%.3d", self:getyearday()) end, - -- Month of the year, from 01 to 12 - ['%m']=function(self) return fmt("%.2d", self:getmonth()) end, - -- Minutes after the hour 55 - ['%M']=function(self) return fmt("%.2d", self:getminutes())end, - -- AM/PM indicator (AM) - ['%p']=function(self) return sl_meridian[self:gethours() > 11 and 1 or -1] end, --AM/PM indicator (AM) - -- The second as a number (59, 20 , 01) - ['%S']=function(self) return fmt("%.2d", self:getseconds()) end, - -- ISO 8601 day of the week, to 7 for Sunday (7, 1) - ['%u']=function(self) return self:getisoweekday() end, - -- Sunday week of the year, from 00 (48) - ['%U']=function(self) return fmt("%.2d", self:getweeknumber()) end, - -- ISO 8601 week of the year, from 01 (48) - ['%V']=function(self) return fmt("%.2d", self:getisoweeknumber()) end, - -- The day of the week as a decimal, Sunday being 0 - ['%w']=function(self) return self:getweekday() - 1 end, - -- Monday week of the year, from 00 (48) - ['%W']=function(self) return fmt("%.2d", self:getweeknumber(2)) end, - -- The year as a number without a century (range 00 to 99) - ['%y']=function(self) return fmt("%.2d", mod(self:getyear() ,100)) end, - -- Year with century (2000, 1914, 0325, 0001) - ['%Y']=function(self) return fmt("%.4d", self:getyear()) end, - -- Time zone offset, the date object is assumed local time (+1000, -0230) - ['%z']=function(self) local b = -self:getbias(); local x = abs(b); return fmt("%s%.4d", b < 0 and "-" or "+", fix(x/60)*100 + floor(mod(x,60))) end, - -- Time zone name, the date object is assumed local time - ['%Z']=function(self) return self:gettzname() end, - -- Misc -- - -- Year, if year is in BCE, prints the BCE Year representation, otherwise result is similar to "%Y" (1 BCE, 40 BCE) - ['%\b']=function(self) local x = self:getyear() return fmt("%.4d%s", x>0 and x or (-x+1), x>0 and "" or " BCE") end, - -- Seconds including fraction (59.998, 01.123) - ['%\f']=function(self) local x = self:getfracsec() return fmt("%s%.9f",x >= 10 and "" or "0", x) end, - -- percent character % - ['%%']=function(self) return "%" end, - -- Group Spec -- - -- 12-hour time, from 01:00:00 AM (06:55:15 AM); same as "%I:%M:%S %p" - ['%r']=function(self) return self:fmt0("%I:%M:%S %p") end, - -- hour:minute, from 01:00 (06:55); same as "%I:%M" - ['%R']=function(self) return self:fmt0("%I:%M") end, - -- 24-hour time, from 00:00:00 (06:55:15); same as "%H:%M:%S" - ['%T']=function(self) return self:fmt0("%H:%M:%S") end, - -- month/day/year from 01/01/00 (12/02/79); same as "%m/%d/%y" - ['%D']=function(self) return self:fmt0("%m/%d/%y") end, - -- year-month-day (1979-12-02); same as "%Y-%m-%d" - ['%F']=function(self) return self:fmt0("%Y-%m-%d") end, - -- The preferred date and time representation; same as "%x %X" - ['%c']=function(self) return self:fmt0("%x %X") end, - -- The preferred date representation, same as "%a %b %d %\b" - ['%x']=function(self) return self:fmt0("%a %b %d %\b") end, - -- The preferred time representation, same as "%H:%M:%\f" - ['%X']=function(self) return self:fmt0("%H:%M:%\f") end, - -- GroupSpec -- - -- Iso format, same as "%Y-%m-%dT%T" - ['${iso}'] = function(self) return self:fmt0("%Y-%m-%dT%T") end, - -- http format, same as "%a, %d %b %Y %T GMT" - ['${http}'] = function(self) return self:fmt0("%a, %d %b %Y %T GMT") end, - -- ctime format, same as "%a %b %d %T GMT %Y" - ['${ctime}'] = function(self) return self:fmt0("%a %b %d %T GMT %Y") end, - -- RFC850 format, same as "%A, %d-%b-%y %T GMT" - ['${rfc850}'] = function(self) return self:fmt0("%A, %d-%b-%y %T GMT") end, - -- RFC1123 format, same as "%a, %d %b %Y %T GMT" - ['${rfc1123}'] = function(self) return self:fmt0("%a, %d %b %Y %T GMT") end, - -- asctime format, same as "%a %b %d %T %Y" - ['${asctime}'] = function(self) return self:fmt0("%a %b %d %T %Y") end, - } - function dobj:fmt0(str) return (gsub(str, "%%[%a%%\b\f]", function(x) local f = tvspec[x];return (f and f(self)) or x end)) end - function dobj:fmt(str) - str = str or self.fmtstr or fmtstr - return self:fmt0((gmatch(str, "${%w+}")) and (gsub(str, "${%w+}", function(x)local f=tvspec[x];return (f and f(self)) or x end)) or str) - end - - function dobj.__lt(a, b) if (a.daynum == b.daynum) then return (a.dayfrc < b.dayfrc) else return (a.daynum < b.daynum) end end - function dobj.__le(a, b) if (a.daynum == b.daynum) then return (a.dayfrc <= b.dayfrc) else return (a.daynum <= b.daynum) end end - function dobj.__eq(a, b)return (a.daynum == b.daynum) and (a.dayfrc == b.dayfrc) end - function dobj.__sub(a,b) - local d1, d2 = date_getdobj(a), date_getdobj(b) - local d0 = d1 and d2 and date_new(d1.daynum - d2.daynum, d1.dayfrc - d2.dayfrc) - return d0 and d0:normalize() - end - function dobj.__add(a,b) - local d1, d2 = date_getdobj(a), date_getdobj(b) - local d0 = d1 and d2 and date_new(d1.daynum + d2.daynum, d1.dayfrc + d2.dayfrc) - return d0 and d0:normalize() - end - function dobj.__concat(a, b) return tostring(a) .. tostring(b) end - function dobj:__tostring() return self:fmt() end - - function dobj:copy() return date_new(self.daynum, self.dayfrc) end - ---[[ THE LOCAL DATE OBJECT METHODS ]]-- - function dobj:tolocal() - local dn,df = self.daynum, self.dayfrc - local bias = getbiasutc2(self) - if bias then - -- utc = local + bias; local = utc - bias - self.daynum = dn - self.dayfrc = df - bias*TICKSPERSEC - return self:normalize() - else - return nil - end - end - - function dobj:toutc() - local dn,df = self.daynum, self.dayfrc - local bias = getbiasloc2(dn, df) - if bias then - -- utc = local + bias; - self.daynum = dn - self.dayfrc = df + bias*TICKSPERSEC - return self:normalize() - else - return nil - end - end - - function dobj:getbias() return (getbiasloc2(self.daynum, self.dayfrc))/SECPERMIN end - - function dobj:gettzname() - local _, tvu, _ = getbiasloc2(self.daynum, self.dayfrc) - return tvu and osdate("%Z",tvu) or "" - end - ---#if not DATE_OBJECT_AFX then - function date.time(h, r, s, t) - h, r, s, t = tonumber(h or 0), tonumber(r or 0), tonumber(s or 0), tonumber(t or 0) - if h and r and s and t then - return date_new(DAYNUM_DEF, makedayfrc(h, r, s, t)) - else - return date_error_arg() - end - end - - function date:__call(arg1, ...) - local arg_count = select("#", ...) + (arg1 == nil and 0 or 1) - if arg_count > 1 then return (date_from(arg1, ...)) - elseif arg_count == 0 then return (date_getdobj(false)) - else local o, r = date_getdobj(arg1); return r and o:copy() or o end - end - - date.diff = dobj.__sub - - function date.isleapyear(v) - local y = fix(v); - if not y then - y = date_getdobj(v) - y = y and y:getyear() - end - return isleapyear(y+0) - end - - function date.epoch() return date_epoch:copy() end - - function date.isodate(y,w,d) return date_new(makedaynum_isoywd(y + 0, w and (w+0) or 1, d and (d+0) or 1), 0) end - --- Internal functions - function date.fmt(str) if str then fmtstr = str end; return fmtstr end - function date.daynummin(n) DAYNUM_MIN = (n and n < DAYNUM_MAX) and n or DAYNUM_MIN return n and DAYNUM_MIN or date_new(DAYNUM_MIN, 0):normalize()end - function date.daynummax(n) DAYNUM_MAX = (n and n > DAYNUM_MIN) and n or DAYNUM_MAX return n and DAYNUM_MAX or date_new(DAYNUM_MAX, 0):normalize()end - function date.ticks(t) if t then setticks(t) end return TICKSPERSEC end ---#end -- not DATE_OBJECT_AFX - - local tm = osdate("!*t", 0); - if tm then - date_epoch = date_new(makedaynum(tm.year, tm.month - 1, tm.day), makedayfrc(tm.hour, tm.min, tm.sec, 0)) - -- the distance from our epoch to os epoch in daynum - DATE_EPOCH = date_epoch and date_epoch:spandays() - else -- error will be raise only if called! - date_epoch = setmetatable({},{__index = function() error("failed to get the epoch date") end}) - end - - function date.serialize(object) - return {tostring(object.daynum), tostring(object.dayfrc)} - end - - function date.construct(object) - return date_isdobj(object) or (object.daynum and date_new(object.daynum, object.dayfrc) or date_new(object[1], object[2])) - end - ---#if not DATE_OBJECT_AFX then -return date ---#else ---$return date_from ---#end diff --git a/gamemode/core/sh_config.lua b/gamemode/core/sh_config.lua index 14acc60f..4d6b65aa 100644 --- a/gamemode/core/sh_config.lua +++ b/gamemode/core/sh_config.lua @@ -70,7 +70,6 @@ function nut.config.load() if (SERVER) then local globals = nut.data.get("config", nil, true, true) local data = nut.data.get("config", nil, false, true) - if (globals) then for k, v in pairs(globals) do nut.config.stored[k] = nut.config.stored[k] or {} diff --git a/gamemode/nutscript.example.json b/gamemode/nutscript.example.json new file mode 100644 index 00000000..a5d4b337 --- /dev/null +++ b/gamemode/nutscript.example.json @@ -0,0 +1,8 @@ +{ + "module": "sqlite", + "hostname": "127.0.0.1", + "username": "", + "password": "", + "database": "", + "port": 3306 +} \ No newline at end of file diff --git a/plugins/f1menu/derma/cl_helps.lua b/plugins/f1menu/derma/cl_helps.lua index b53ab28e..380fa065 100644 --- a/plugins/f1menu/derma/cl_helps.lua +++ b/plugins/f1menu/derma/cl_helps.lua @@ -1,4 +1,16 @@ -if (CLIENT) then + + surface.CreateFont("nutSmallCredits", { + font = "Roboto", + size = 18, + weight = 400 + }) + + surface.CreateFont("nutBigCredits", { + font = "Roboto", + size = 25, + weight = 600 + }) + local HELP_DEFAULT hook.Add("CreateMenuButtons", "nutHelpMenu", function(tabs) @@ -49,6 +61,19 @@ if (CLIENT) then if (node.onGetHTML) then local source = node:onGetHTML() + if (IsValid(devAvatar)) then + helpPanel:Remove() + + helpPanel = panel:Add("DListView") + helpPanel:Dock(FILL) + helpPanel.Paint = function(this, w, h) + end + + html = helpPanel:Add("DHTML") + html:Dock(FILL) + html:SetHTML(header..HELP_DEFAULT) + end + if (source:sub(1, 4) == "http") then html:OpenURL(source) else @@ -57,7 +82,12 @@ if (CLIENT) then end end - html = panel:Add("DHTML") + helpPanel = panel:Add("DListView") + helpPanel:Dock(FILL) + helpPanel.Paint = function(this, w, h) + end + + html = helpPanel:Add("DHTML") html:Dock(FILL) html:SetHTML(header..HELP_DEFAULT) @@ -75,7 +105,6 @@ if (CLIENT) then end end end) -end hook.Add("BuildHelpMenu", "nutBasicHelp", function(tabs) tabs["commands"] = function(node) @@ -112,6 +141,30 @@ hook.Add("BuildHelpMenu", "nutBasicHelp", function(tabs) return body end + tabs["flags"] = function(node) + local body = [[]] + + for k, v in SortedPairs(nut.flag.list) do + local icon + + if (LocalPlayer():getChar():hasFlags(k)) then + icon = [[]] + else + icon = [[]] + end + + body = body..Format([[ + + + + + + ]], icon, k, v.desc) + end + + return body.."
%s%s%s
" + end + tabs["plugins"] = function(node) local body = "" @@ -134,27 +187,102 @@ hook.Add("BuildHelpMenu", "nutBasicHelp", function(tabs) return body end - tabs["flags"] = function(node) - local body = [[]] + local authorCredits = { + {desc = "Creator", steamid = "76561198030127257"}, -- Chessnut + {desc = "Co-Creator", steamid = "76561197999893894"}, -- Black Tea + {desc = "Developer", steamid = "76561198060659964"}, -- Zoephix + {desc = "Developer", steamid = "76561198070441753"}, -- TovarischPootis + {desc = "Contributors", button = "View all contributors", url = "https://github.com/NutScript/NutScript/graphs/contributors"} + } - for k, v in SortedPairs(nut.flag.list) do - local icon + tabs["Credits"] = function(node) + local body = [[ +
+
+ +
NutScript +
+
+ ]] + local scrW = ScrW() + local scrH = ScrH() + local offsetW = scrW*0.025 + local offsetH = scrH*0.08 + local offsetC = scrW*0.25 - if (LocalPlayer():getChar():hasFlags(k)) then - icon = [[]] + local nscredits = helpPanel:Add("DScrollPanel") + nscredits:Dock(FILL) + nscredits:DockMargin(0, scrH*0.32, 0, 0) + nscredits.Paint = function() + end + + local function createDevName(text) + devName = nscredits:Add("DLabel") + devName:SetText(text) + devName:SetFont("nutBigCredits") + devName:SetTextColor(Color(255, 255, 255)) + devName:SizeToContents() + end + + for k, v in ipairs(authorCredits) do + local offsetH = k == 1 and 0 or (k*offsetH)-offsetH + + if (v.steamid) then + steamworks.RequestPlayerInfo(v.steamid, function(steamName) + createDevName(steamName) + end) + -- + -- add custom field else - icon = [[]] + createDevName(v.desc) end - body = body..Format([[ - - - - - - ]], icon, k, v.desc) + if (v.steamid or v.text) then + desc = nscredits:Add("DLabel") + desc:SetText(v.desc) + desc:SetFont("nutSmallCredits") + desc:SetTextColor(Color(255, 255, 255)) + desc:SizeToContents() + elseif (v.button) then + desc = nscredits:Add("DButton") + desc:SetText(v.button) + desc:SizeToContents() + desc.DoClick = function() + surface.PlaySound("buttons/button14.wav") + + gui.OpenURL(v.url) + end + + offsetH = offsetH + 25 + end + + -- fucking end my suffering + -- this shit took me over three hours... + local offsetW2 = string.Explode(" ", v.button and desc:GetSize() or desc:GetTextSize())[1] + local offsetW3 = string.Explode(" ", devName:GetTextSize())[1] + + devName:SetPos(devName:GetPos()+(offsetC-devName:GetPos()), 0) + devName:SetPos(devName:GetPos()-(offsetW3/2), offsetH) + + desc:SetPos(desc:GetPos()+(offsetC-desc:GetPos()), 0) + desc:SetPos(desc:GetPos()-(offsetW2/2), offsetH+(v.button and scrH*0.03 or scrH*0.022)) + + if (v.steamid) then + devAvatar = vgui.Create("AvatarImage", nscredits) + devAvatar:SetPos(devName:GetPos()-(scrW*0.025), offsetH) + devAvatar:SetSteamID(v.steamid, 64) + devAvatar:SetSize(40, 40) + devAvatar.OnCursorEntered = function() + surface.PlaySound("garrysmod/ui_return.wav") + end + devAvatar.OnMousePressed = function() + surface.PlaySound("buttons/button14.wav") + + gui.OpenURL("http://steamcommunity.com/profiles/"..v.steamid) + end + end end - return body.."
%s%s%s
" + return body end -end) \ No newline at end of file +end) diff --git a/plugins/f1menu/derma/cl_information.lua b/plugins/f1menu/derma/cl_information.lua index 671f6a80..7b4b8c12 100644 --- a/plugins/f1menu/derma/cl_information.lua +++ b/plugins/f1menu/derma/cl_information.lua @@ -74,7 +74,7 @@ local PANEL = {} if (!suppress or !suppress.class) then local class = nut.class.list[LocalPlayer():getChar():getClass()] - + if (class) then self.class = self.info:Add("DLabel") self.class:Dock(TOP) @@ -126,7 +126,7 @@ local PANEL = {} end if (self.time) then - local format = "%A, %d %B "..nut.config.get("yearAppendix", "").." %Y %T" + local format = "%A, %d %B "..nut.config.get("year") .. nut.config.get("yearAppendix", "").." %T" self.time:SetText(L("curTime", nut.date.getFormatted(format))) self.time.Think = function(this) diff --git a/plugins/persistence.lua b/plugins/persistence.lua new file mode 100644 index 00000000..cf46adb0 --- /dev/null +++ b/plugins/persistence.lua @@ -0,0 +1,178 @@ +local PLUGIN = PLUGIN + +PLUGIN.name = "Persistence" +PLUGIN.desc = "Saves persisted entities through restarts." +PLUGIN.author = "Zoephix" + +-- Storage for persisted map entities +PLUGIN.entities = PLUGIN.entities or {} + +-- Entities which are blocked from interaction +PLUGIN.blacklist = PLUGIN.blacklist or { + [ "func_button" ] = true, + [ "class C_BaseEntity" ] = true, + [ "func_brush" ] = true, + [ "func_tracktrain" ] = true, + [ "func_door" ] = true, + [ "func_door_rotating" ] = true, + [ "prop_door_rotating" ] = true, + [ "prop_static" ] = true, + [ "prop_dynamic" ] = true, + [ "prop_physics_override" ] = true, +} + +properties.Add( "persist", { + MenuLabel = "#makepersistent", + Order = 400, + MenuIcon = "icon16/link.png", + + Filter = function( self, ent, ply ) + + if ( ent:IsPlayer() ) then return false end + if ( PLUGIN.blacklist[ent:GetClass()] ) then return false end + if ( !gamemode.Call( "CanProperty", ply, "persist", ent ) ) then return false end + + return !ent:getNetVar( "persistent", false ) + + end, + + Action = function( self, ent ) + + self:MsgStart() + net.WriteEntity( ent ) + self:MsgEnd() + + end, + + Receive = function( self, length, ply ) + + local ent = net.ReadEntity() + if ( !IsValid( ent ) ) then return end + if ( !self:Filter( ent, ply ) ) then return end + + ent:setNetVar( "persistent", true ) + + -- Register the entity + PLUGIN.entities[#PLUGIN.entities + 1] = ent + + -- Add new log + nut.log.add(ply, "persistedEntity", ent ) + end + +} ) + +properties.Add( "persist_end", { + MenuLabel = "#stoppersisting", + Order = 400, + MenuIcon = "icon16/link_break.png", + + Filter = function( self, ent, ply ) + + if ( ent:IsPlayer() ) then return false end + if ( !gamemode.Call( "CanProperty", ply, "persist", ent ) ) then return false end + + return ent:getNetVar( "persistent", false ) + + end, + + Action = function( self, ent ) + + self:MsgStart() + net.WriteEntity( ent ) + self:MsgEnd() + + end, + + Receive = function( self, length, ply ) + + local ent = net.ReadEntity() + if ( !IsValid( ent ) ) then return end + if ( !properties.CanBeTargeted( ent, ply ) ) then return end + if ( !self:Filter( ent, ply ) ) then return end + + ent:setNetVar( "persistent", false ) + + -- Remove entity from registration + for k, v in ipairs(PLUGIN.entities) do + if (v == entity) then + PLUGIN.entities[k] = nil + + break + end + end + + -- Add new log + nut.log.add(ply, "unpersistedEntity", ent ) + end + +} ) + +if (SERVER) then + nut.log.addType("persistedEntity", function(client, entity) + return string.format("%s has persisted '%s'.", client:Name(), entity) + end) + + nut.log.addType("unpersistedEntity", function(client, entity) + return string.format("%s has removed persistence from '%s'.", client:Name(), entity) + end) + + -- Prevent from picking up persisted entities + function PLUGIN:PhysgunPickup(client, entity) + if (entity:getNetVar("persistent", false)) then + return false + end + end + + function PLUGIN:SaveData() + local data = {} + + for k, v in ipairs(self.entities) do + if (IsValid(v)) then + local entData = {} + entData.class = v:GetClass() + entData.pos = v:GetPos() + entData.angles = v:GetAngles() + entData.model = v:GetModel() + entData.skin = v:GetSkin() + entData.color = v:GetColor() + entData.material = v:GetMaterial() + entData.bodygroups = v:GetBodyGroups() + + local physicsObject = v:GetPhysicsObject() + if (IsValid(physicsObject)) then + entData.moveable = physicsObject:IsMoveable() + end + + data[#data +1] = entData + end + end + self:setData(data) + end + + function PLUGIN:LoadData() + for k, v in pairs(self:getData() or {}) do + local ent = ents.Create(v.class) + ent:SetPos(v.pos) + ent:SetAngles(v.angles) + ent:SetModel(v.model) + ent:SetSkin(v.skin) + ent:SetColor(v.color) + ent:SetMaterial(v.material) + ent:Spawn() + ent:Activate() + + for _, data in pairs(v.bodygroups) do + ent:SetBodygroup(data.id, data.num) + end + + local physicsObject = ent:GetPhysicsObject() + if (IsValid(physicsObject)) then + physicsObject:EnableMotion(ent.moveable or false) + end + + ent:setNetVar("persistent", true) + + self.entities[#self.entities + 1] = ent + end + end +end From 7e48bb812390ac50c28b57c0b8a6d5551297f0e1 Mon Sep 17 00:00:00 2001 From: Zoephix Date: Wed, 17 Feb 2021 13:18:34 +0100 Subject: [PATCH 07/56] snip --- database.example | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 database.example diff --git a/database.example b/database.example deleted file mode 100644 index f60d3420..00000000 --- a/database.example +++ /dev/null @@ -1,8 +0,0 @@ -{ - "module": "sqlite", - "hostname": "127.0.0.1", - "username": "", - "password": "", - "database": "", - "port": 3306 -} From a8b9a740b332c60f3ca0b138edab4edc71f08692 Mon Sep 17 00:00:00 2001 From: Zoephix Date: Wed, 17 Feb 2021 14:00:20 +0100 Subject: [PATCH 08/56] Fixed devName error --- plugins/f1menu/derma/cl_helps.lua | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/plugins/f1menu/derma/cl_helps.lua b/plugins/f1menu/derma/cl_helps.lua index 380fa065..a7f5c92f 100644 --- a/plugins/f1menu/derma/cl_helps.lua +++ b/plugins/f1menu/derma/cl_helps.lua @@ -216,25 +216,25 @@ hook.Add("BuildHelpMenu", "nutBasicHelp", function(tabs) nscredits.Paint = function() end - local function createDevName(text) - devName = nscredits:Add("DLabel") - devName:SetText(text) - devName:SetFont("nutBigCredits") - devName:SetTextColor(Color(255, 255, 255)) - devName:SizeToContents() - end - for k, v in ipairs(authorCredits) do local offsetH = k == 1 and 0 or (k*offsetH)-offsetH if (v.steamid) then steamworks.RequestPlayerInfo(v.steamid, function(steamName) - createDevName(steamName) + devName = nscredits:Add("DLabel") + devName:SetText(steamName) + devName:SetFont("nutBigCredits") + devName:SetTextColor(Color(255, 255, 255)) + devName:SizeToContents() end) -- -- add custom field else - createDevName(v.desc) + devName = nscredits:Add("DLabel") + devName:SetText(v.desc) + devName:SetFont("nutBigCredits") + devName:SetTextColor(Color(255, 255, 255)) + devName:SizeToContents() end if (v.steamid or v.text) then From 3fe5ebadac91b04eec347f8ff211fe5b45b2e707 Mon Sep 17 00:00:00 2001 From: Zoephix Date: Wed, 17 Feb 2021 16:25:53 +0100 Subject: [PATCH 09/56] Author name fetching via Steam ID (#27) * Author name fetching via Steam ID * string.match --- gamemode/core/hooks/cl_hooks.lua | 17 +++++++++++++++++ plugins/persistence.lua | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/gamemode/core/hooks/cl_hooks.lua b/gamemode/core/hooks/cl_hooks.lua index b52d03d2..54b99732 100644 --- a/gamemode/core/hooks/cl_hooks.lua +++ b/gamemode/core/hooks/cl_hooks.lua @@ -537,3 +537,20 @@ function GM:ScreenResolutionChanged(oldW, oldH) nut.config.get("genericFont") ) end + +function GM:NutScriptLoaded() + for _, PLUGIN in pairs(nut.plugin.list) do + local author64ID = tonumber(PLUGIN.author) + local authorSteamID = string.match(PLUGIN.author, "STEAM_", 1) + + if (author64ID or authorSteamID) then + -- Store the Steam ID + PLUGIN.authorID = author64ID and util.SteamIDFrom64(PLUGIN.author) or PLUGIN.author + + steamworks.RequestPlayerInfo(authorSteamID and util.SteamIDTo64(PLUGIN.author) or PLUGIN.author, function(steamName) + -- Update the author name + PLUGIN.author = steamName + end) + end + end +end diff --git a/plugins/persistence.lua b/plugins/persistence.lua index cf46adb0..6ed006b9 100644 --- a/plugins/persistence.lua +++ b/plugins/persistence.lua @@ -2,7 +2,7 @@ local PLUGIN = PLUGIN PLUGIN.name = "Persistence" PLUGIN.desc = "Saves persisted entities through restarts." -PLUGIN.author = "Zoephix" +PLUGIN.author = "STEAM_0:0:50197118" -- Storage for persisted map entities PLUGIN.entities = PLUGIN.entities or {} From 3f5a36e6b0bd643e92203120c95d2ff68f61e25a Mon Sep 17 00:00:00 2001 From: Zoephix Date: Sun, 28 Feb 2021 11:57:33 +0100 Subject: [PATCH 10/56] Fixed admin delay --- gamemode/core/libs/sh_chatbox.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gamemode/core/libs/sh_chatbox.lua b/gamemode/core/libs/sh_chatbox.lua index 76454686..3dd1e28d 100644 --- a/gamemode/core/libs/sh_chatbox.lua +++ b/gamemode/core/libs/sh_chatbox.lua @@ -260,7 +260,7 @@ do -- Only need to check the time if they have spoken in OOC chat before. if (delay > 0 and speaker.nutLastOOC) then -- Admin delay bypass - if (speaker:IsAdmin() and nut.config.get("oocDelayAdmin", false)) then + if (!speaker:IsAdmin() and nut.config.get("oocDelayAdmin", false)) then local lastOOC = CurTime() - speaker.nutLastOOC -- Use this method of checking time in case the oocDelay config changes. @@ -318,7 +318,7 @@ do -- Only need to check the time if they have spoken in OOC chat before. if (delay > 0 and speaker.nutLastLOOC) then -- Admin delay bypass - if (speaker:IsAdmin() and nut.config.get("loocDelayAdmin", false)) then + if (!speaker:IsAdmin() and nut.config.get("loocDelayAdmin", false)) then local lastLOOC = CurTime() - speaker.nutLastLOOC -- Use this method of checking time in case the oocDelay config changes. From 84db2dad966d947ebb263c34c6123d850d1082e8 Mon Sep 17 00:00:00 2001 From: Zoephix Date: Sun, 28 Feb 2021 12:09:41 +0100 Subject: [PATCH 11/56] Fixed admin chat delay --- gamemode/core/libs/sh_chatbox.lua | 32 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/gamemode/core/libs/sh_chatbox.lua b/gamemode/core/libs/sh_chatbox.lua index 3dd1e28d..5a6946e4 100644 --- a/gamemode/core/libs/sh_chatbox.lua +++ b/gamemode/core/libs/sh_chatbox.lua @@ -257,10 +257,10 @@ do else local delay = nut.config.get("oocDelay", 10) - -- Only need to check the time if they have spoken in OOC chat before. - if (delay > 0 and speaker.nutLastOOC) then - -- Admin delay bypass - if (!speaker:IsAdmin() and nut.config.get("oocDelayAdmin", false)) then + -- Admin delay bypass + if (speaker:IsAdmin() and nut.config.get("oocDelayAdmin", false)) then + -- Only need to check the time if they have spoken in OOC chat before. + if (delay > 0 and speaker.nutLastOOC) then local lastOOC = CurTime() - speaker.nutLastOOC -- Use this method of checking time in case the oocDelay config changes. @@ -278,19 +278,15 @@ do end, onChatAdd = function(speaker, text) local icon = "icon16/user.png" - local customIcons = { - ["STEAM_0:1:34930764"] = "icon16/script_gear.png", -- Chessnut - ["STEAM_0:0:19814083"] = "icon16/gun.png", -- Black Tea the edgiest man - ["STEAM_0:0:50197118"] = "icon16/script_gear.png", -- Zoephix - ["STEAM_0:1:55088012"] = "icon16/script_gear.png" -- TovarischPootis - } - - -- man, I did all that works and I deserve different icon on ooc chat + + -- man, I did all that works and I deserve differnet icon on ooc chat -- if you dont like it -- well.. -- it's on your own. - if (customIcons[speaker:SteamID()]) then - icon = customIcons[speaker:SteamID()] + if (speaker:SteamID() == "STEAM_0:1:34930764") then -- Chessnut + icon = "icon16/script_gear.png" + elseif (speaker:SteamID() == "STEAM_0:0:19814083") then -- Black Tea the edgiest man + icon = "icon16/gun.png" elseif (speaker:IsSuperAdmin()) then icon = "icon16/shield.png" elseif (speaker:IsAdmin()) then @@ -315,10 +311,10 @@ do onCanSay = function(speaker, text) local delay = nut.config.get("loocDelay", 0) - -- Only need to check the time if they have spoken in OOC chat before. - if (delay > 0 and speaker.nutLastLOOC) then - -- Admin delay bypass - if (!speaker:IsAdmin() and nut.config.get("loocDelayAdmin", false)) then + -- Admin delay bypass + if (speaker:IsAdmin() and nut.config.get("loocDelayAdmin", false)) then + -- Only need to check the time if they have spoken in OOC chat before. + if (delay > 0 and speaker.nutLastLOOC) then local lastLOOC = CurTime() - speaker.nutLastLOOC -- Use this method of checking time in case the oocDelay config changes. From ddc3f660e8789dda5b6da8d88a6a39e4f51b086d Mon Sep 17 00:00:00 2001 From: Zoephix Date: Sun, 28 Feb 2021 12:20:56 +0100 Subject: [PATCH 12/56] Added chat icons --- gamemode/core/libs/sh_chatbox.lua | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/gamemode/core/libs/sh_chatbox.lua b/gamemode/core/libs/sh_chatbox.lua index 5a6946e4..1441575f 100644 --- a/gamemode/core/libs/sh_chatbox.lua +++ b/gamemode/core/libs/sh_chatbox.lua @@ -278,15 +278,19 @@ do end, onChatAdd = function(speaker, text) local icon = "icon16/user.png" - - -- man, I did all that works and I deserve differnet icon on ooc chat + local customIcons = { + ["STEAM_0:1:34930764"] = "icon16/script_gear.png", -- Chessnut + ["STEAM_0:0:19814083"] = "icon16/gun.png", -- Black Tea the edgiest man + ["STEAM_0:0:50197118"] = "icon16/script_gear.png", -- Zoephix + ["STEAM_0:1:55088012"] = "icon16/script_gear.png" -- TovarischPootis + } + + -- man, I did all that works and I deserve different icon on ooc chat -- if you dont like it -- well.. -- it's on your own. - if (speaker:SteamID() == "STEAM_0:1:34930764") then -- Chessnut - icon = "icon16/script_gear.png" - elseif (speaker:SteamID() == "STEAM_0:0:19814083") then -- Black Tea the edgiest man - icon = "icon16/gun.png" + if (customIcons[speaker:SteamID()]) then + icon = customIcons[speaker:SteamID()] elseif (speaker:IsSuperAdmin()) then icon = "icon16/shield.png" elseif (speaker:IsAdmin()) then From 6c65114a2e6f341d525b76c0fd8e87e041d7cc58 Mon Sep 17 00:00:00 2001 From: Zoephix Date: Wed, 3 Mar 2021 15:57:41 +0100 Subject: [PATCH 13/56] Return the disconnected player's Steam ID --- plugins/logging.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/logging.lua b/plugins/logging.lua index 8c6fd76c..fdc61095 100644 --- a/plugins/logging.lua +++ b/plugins/logging.lua @@ -28,7 +28,7 @@ if (SERVER) then end) nut.log.addType("playerDisconnected", function(client, ...) - return string.format("%s has disconnected from the server.", client:Name()) + return string.format("%s (%s) has disconnected from the server.", client:Name(), client:SteamID()) end) nut.log.addType("itemTake", function(client, ...) From edc8445cfac573defa887c781f862674420919de Mon Sep 17 00:00:00 2001 From: Zoephix Date: Wed, 3 Mar 2021 15:58:34 +0100 Subject: [PATCH 14/56] Lua consistency --- plugins/logging.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/logging.lua b/plugins/logging.lua index fdc61095..d0159d8c 100644 --- a/plugins/logging.lua +++ b/plugins/logging.lua @@ -28,7 +28,7 @@ if (SERVER) then end) nut.log.addType("playerDisconnected", function(client, ...) - return string.format("%s (%s) has disconnected from the server.", client:Name(), client:SteamID()) + return string.format("%s[%s] has disconnected from the server.", client:Name(), client:SteamID()) end) nut.log.addType("itemTake", function(client, ...) From 9386baf9feb29be635b4158aac9ae411ea4fe03d Mon Sep 17 00:00:00 2001 From: VindoesCompooter <100soundsystem32@gmail.com> Date: Thu, 4 Mar 2021 17:13:32 +0000 Subject: [PATCH 15/56] Whitespaces + Deprecated Cleanup Whitespaces and deprecated code cleanup. --- entities/weapons/nut_hands.lua | 187 ++++++++++++++++----------------- 1 file changed, 89 insertions(+), 98 deletions(-) diff --git a/entities/weapons/nut_hands.lua b/entities/weapons/nut_hands.lua index 232d0f5b..1c7eac5f 100644 --- a/entities/weapons/nut_hands.lua +++ b/entities/weapons/nut_hands.lua @@ -139,7 +139,7 @@ local function removeVelocity(entity, normalize) timer.Simple(0, function() -- reformed physics SetSubPhysMotionEnabled(entity, true) - + if (IsValid(phys)) then phys:SetVelocity(vel) end @@ -160,11 +160,11 @@ local function throwVelocity(entity, client, power) -- reformed physics if (IsValid(entity)) then SetSubPhysMotionEnabled(entity, true) - + if (IsValid(phys)) then phys:SetVelocity(vel) end - + entity:SetVelocity(vel) entity:SetLocalAngularVelocity(Angle()) end @@ -202,7 +202,7 @@ function SWEP:reset(throw) if (!throw) then removeVelocity(self.holdingEntity) else - throwVelocity(self.holdingEntity, self.Owner, 300) + throwVelocity(self.holdingEntity, self:GetOwner(), 300) end hook.Run("GravGunOnDropped", self:GetOwner(), self.holdingEntity, throw) @@ -319,13 +319,11 @@ if (SERVER) then end else function SWEP:Think() - if (CLIENT) then - if (self.Owner) then - local viewModel = self.Owner:GetViewModel() + if (CLIENT and self:GetOwner()) then + local viewModel = self:GetOwner():GetViewModel() - if (IsValid(viewModel)) then - viewModel:SetPlaybackRate(1) - end + if (IsValid(viewModel)) then + viewModel:SetPlaybackRate(1) end end end @@ -337,38 +335,36 @@ function SWEP:PrimaryAttack() end if (IsValid(self.holdingEntity)) then - self:doPickup(not self.isWepRaised or self:GetOwner():isWepRaised()) + self:doPickup(!self.isWepRaised or self:GetOwner():isWepRaised()) return end self:SetNextPrimaryFire(CurTime() + self.Primary.Delay) - if (hook.Run("CanPlayerThrowPunch", self.Owner) == false) then + if (hook.Run("CanPlayerThrowPunch", self:GetOwner()) == false) then return end local staminaUse = nut.config.get("punchStamina", 10) if (staminaUse > 0) then - local value = self.Owner:getLocalVar("stm", 0) - staminaUse + local value = self:GetOwner():getLocalVar("stm", 0) - staminaUse if (value < 0) then return elseif (SERVER) then - self.Owner:setLocalVar("stm", value) + self:GetOwner():setLocalVar("stm", value) end end if (SERVER) then - self.Owner:EmitSound("npc/vort/claw_swing"..math.random(1, 2)..".wav") + self:GetOwner():EmitSound("npc/vort/claw_swing"..math.random(1, 2)..".wav") end - local damage = self.Primary.Damage - self:doPunchAnimation() - self.Owner:SetAnimation(PLAYER_ATTACK1) - self.Owner:ViewPunch(Angle(self.LastHand + 2, self.LastHand + 5, 0.125)) + self:GetOwner():SetAnimation(PLAYER_ATTACK1) + self:GetOwner():ViewPunch(Angle(self.LastHand + 2, self.LastHand + 5, 0.125)) self:SetNW2Float( "startTime", CurTime() ); self:SetNW2Bool( "startPunch", true ); @@ -380,7 +376,7 @@ function SWEP:SecondaryAttack() return end - local client = self.Owner + local client = self:GetOwner() local data = {} data.start = client:GetShootPos() data.endpos = data.start + client:GetAimVector() * PLAYER_PICKUP_RANGE @@ -393,13 +389,13 @@ function SWEP:SecondaryAttack() if (SERVER and IsValid(entity)) then if (entity:isDoor()) then - if (hook.Run("PlayerCanKnock", self.Owner, entity) == false) then + if (hook.Run("PlayerCanKnock", self:GetOwner(), entity) == false) then return end - self.Owner:ViewPunch(Angle(-1.3, 1.8, 0)) - self.Owner:EmitSound("physics/wood/wood_crate_impact_hard"..math.random(2, 3)..".wav") - self.Owner:SetAnimation(PLAYER_ATTACK1) + self:GetOwner():ViewPunch(Angle(-1.3, 1.8, 0)) + self:GetOwner():EmitSound("physics/wood/wood_crate_impact_hard"..math.random(2, 3)..".wav") + self:GetOwner():SetAnimation(PLAYER_ATTACK1) self:doPunchAnimation() self:SetNextSecondaryFire(CurTime() + 0.4) @@ -417,8 +413,8 @@ function SWEP:SecondaryAttack() end function SWEP:dragObject(phys, targetpos, is_ragdoll) - if (!IsValid(phys)) then - return + if (!IsValid(phys)) then + return end local point = self:GetOwner():GetShootPos() + self:GetOwner():GetAimVector() * 50 @@ -444,74 +440,71 @@ function SWEP:allowPickup(target) local phys = target:GetPhysicsObject() local client = self:GetOwner() - return ( - IsValid(phys) and IsValid(client) and client:getChar() and - (not phys:HasGameFlag(FVPHYSICS_NO_PLAYER_PICKUP)) and - phys:GetMass() <= CARRY_WEIGHT_LIMIT and - (not isPlayerStandsOn(target)) and - (target.CanPickup != false) and - hook.Run("GravGunPickupAllowed", self:GetOwner(), target) != false and - (target.GravGunPickupAllowed and (target:GravGunPickupAllowed(self:GetOwner()) != false) or true) - ) + return + IsValid(phys) and IsValid(client) and client:getChar() and + (!phys:HasGameFlag(FVPHYSICS_NO_PLAYER_PICKUP)) and + phys:GetMass() <= CARRY_WEIGHT_LIMIT and + (!isPlayerStandsOn(target)) and + (target.CanPickup != false) and + hook.Run("GravGunPickupAllowed", self:GetOwner(), target) != false and + (target.GravGunPickupAllowed and (target:GravGunPickupAllowed(self:GetOwner()) != false) or true) end function SWEP:doPickup(throw, entity, trace) - self.Weapon:SetNextPrimaryFire( CurTime() + .1 ) - self.Weapon:SetNextSecondaryFire( CurTime() + .1 ) + self:SetNextPrimaryFire( CurTime() + .1 ) + self:SetNextSecondaryFire( CurTime() + .1 ) if (IsValid(self.holdingEntity)) then self:drop(throw) - self.Weapon:SetNextSecondaryFire(CurTime() + 0.1) + self:SetNextSecondaryFire(CurTime() + 0.1) return end local client = self:GetOwner() if (IsValid(entity)) then local phys = entity:GetPhysicsObject() - + if (!IsValid(phys) or !phys:IsMoveable() or phys:HasGameFlag(FVPHYSICS_PLAYER_HELD)) then - hook.Run("OnPickupObject", false, self.Owner, entity) + hook.Run("OnPickupObject", false, self:GetOwner(), entity) return end - + -- if we let the client mess with physics, desync ensues - if (SERVER) then - if (client:EyePos() - (entity:GetPos() + entity:OBBCenter())):Length() < self:getRange(entity) then - if (self:allowPickup(entity)) then - self:pickup(entity, trace) - self:SendWeaponAnim(ACT_VM_HITCENTER) - - -- make the refire slower to avoid immediately dropping - local delay = (entity:GetClass() == "prop_ragdoll") and 0.8 or 0.1 - - hook.Run("OnPickupObject", true, self.Owner, entity) - self:SetNextSecondaryFire(CurTime() + delay) - return - else - local is_ragdoll = entity:GetClass() == "prop_ragdoll" + if (SERVER and (client:EyePos() - (entity:GetPos() + entity:OBBCenter())):Length() < self:getRange(entity)) then + if (self:allowPickup(entity)) then + self:pickup(entity, trace) + self:SendWeaponAnim(ACT_VM_HITCENTER) - --[[ - --Drag ragdoll/props + -- make the refire slower to avoid immediately dropping + local delay = (entity:GetClass() == "prop_ragdoll") and 0.8 or 0.1 - local ent = entity - local phys = ent:GetPhysicsObject() - local pdir = trace.Normal * -1 + hook.Run("OnPickupObject", true, self:GetOwner(), entity) + self:SetNextSecondaryFire(CurTime() + delay) + return + else + local is_ragdoll = entity:GetClass() == "prop_ragdoll" - if is_ragdoll then + --[[ + --Drag ragdoll/props - phys = ent:GetPhysicsObjectNum(trace.PhysicsBone) + local ent = entity + local phys = ent:GetPhysicsObject() + local pdir = trace.Normal * -1 - -- increase refire to make rags easier to drag - --self.Weapon:SetNextSecondaryFire(CurTime() + 0.04) - end - - if (IsValid(phys)) then - self:dragObject(phys, pdir, 6000, is_ragdoll) - return - end - ]]-- - end + if is_ragdoll then + + phys = ent:GetPhysicsObjectNum(trace.PhysicsBone) + + -- increase refire to make rags easier to drag + --self.Weapon:SetNextSecondaryFire(CurTime() + 0.04) + end + + if (IsValid(phys)) then + self:dragObject(phys, pdir, 6000, is_ragdoll) + return + end + ]]-- end end end @@ -535,7 +528,7 @@ function SWEP:pickup(entity, trace) pos = pos + self.holdingEntity:GetUp()*obb.z self.carryHack:SetPos(pos) - + self.carryHack:SetModel("models/weapons/w_bugbait.mdl") self.carryHack:SetColor(Color(50, 250, 50, 240)) @@ -601,7 +594,7 @@ function SWEP:pickup(entity, trace) self:SetNW2Bool("holdingObject", true) self.constr = constraint.Weld(self.carryHack, self.holdingEntity, 0, bone, max_force, true) - self.Owner:EmitSound("physics/body/body_medium_impact_soft"..math.random(1, 3)..".wav", 75) + self:GetOwner():EmitSound("physics/body/body_medium_impact_soft"..math.random(1, 3)..".wav", 75) hook.Run("GravGunOnPickedUp", self:GetOwner(), self.holdingEntity) end @@ -611,8 +604,8 @@ end local down = Vector(0, 0, -1) function SWEP:allowEntityDrop() local client = self:GetOwner() - local ent = self.carryHack - if (!IsValid(client)) or (!IsValid(ent)) then return false end + + if (!IsValid(client)) or (!IsValid(self.carryHack)) then return false end local ground = client:GetGroundEntity() if ground and (ground:IsWorld() or IsValid(ground)) then return true end @@ -645,13 +638,13 @@ ACT_VM_FISTS_DRAW = 3 ACT_VM_FISTS_HOLSTER = 2 function SWEP:Deploy() - if (!IsValid(self.Owner)) then + if (!IsValid(self:GetOwner())) then return end self:reset() - local viewModel = self.Owner:GetViewModel() + local viewModel = self:GetOwner():GetViewModel() if (IsValid(viewModel)) then viewModel:SetPlaybackRate(1) @@ -662,13 +655,13 @@ function SWEP:Deploy() end function SWEP:Holster() - if (!IsValid(self.Owner)) then + if (!IsValid(self:GetOwner())) then return end self:reset() - local viewModel = self.Owner:GetViewModel() + local viewModel = self:GetOwner():GetViewModel() if (IsValid(viewModel)) then viewModel:SetPlaybackRate(1) @@ -693,27 +686,25 @@ function SWEP:doPunchAnimation() self.LastHand = math.abs(1 - self.LastHand) local sequence = 4 + self.LastHand - local viewModel = self.Owner:GetViewModel() + local viewModel = self:GetOwner():GetViewModel() if (IsValid(viewModel)) then viewModel:SetPlaybackRate(0.5) viewModel:SetSequence(sequence) end - if(self:GetNW2Bool( "startPunch", false )) then - if( CurTime() > self:GetNW2Float( "startTime", CurTime() ) + 0.055 ) then - self:doPunch(); - self:SetNW2Bool( "startPunch", false ); - self:SetNW2Float( "startTime", 0 ); - end + if (self:GetNW2Bool( "startPunch", false )) and ( CurTime() > self:GetNW2Float( "startTime", CurTime() ) + 0.055 ) then + self:doPunch() + self:SetNW2Bool( "startPunch", false ) + self:SetNW2Float( "startTime", 0 ) end end function SWEP:doPunch() - if (IsValid(self) and IsValid(self.Owner)) then + if (IsValid(self) and IsValid(self:GetOwner())) then local damage = self.Primary.Damage local context = {damage = damage} - local result = hook.Run("PlayerGetFistDamage", self.Owner, damage, context) + local result = hook.Run("PlayerGetFistDamage", self:GetOwner(), damage, context) if (result != nil) then damage = result @@ -721,11 +712,11 @@ function SWEP:doPunch() damage = context.damage end - self.Owner:LagCompensation(true) + self:GetOwner():LagCompensation(true) local data = {} - data.start = self.Owner:GetShootPos() - data.endpos = data.start + self.Owner:GetAimVector()*96 - data.filter = self.Owner + data.start = self:GetOwner():GetShootPos() + data.endpos = data.start + self:GetOwner():GetAimVector()*96 + data.filter = self:GetOwner() local trace = util.TraceLine(data) if (SERVER and trace.Hit) then @@ -733,19 +724,19 @@ function SWEP:doPunch() if (IsValid(entity)) then local damageInfo = DamageInfo() - damageInfo:SetAttacker(self.Owner) + damageInfo:SetAttacker(self:GetOwner()) damageInfo:SetInflictor(self) damageInfo:SetDamage(damage) damageInfo:SetDamageType(DMG_SLASH) damageInfo:SetDamagePosition(trace.HitPos) - damageInfo:SetDamageForce(self.Owner:GetAimVector()*10000) + damageInfo:SetDamageForce(self:GetOwner():GetAimVector()*10000) entity:DispatchTraceAttack(damageInfo, data.start, data.endpos) - self.Owner:EmitSound("physics/body/body_medium_impact_hard"..math.random(1, 6)..".wav", 80) + self:GetOwner():EmitSound("physics/body/body_medium_impact_hard"..math.random(1, 6)..".wav", 80) end end - hook.Run("PlayerThrowPunch", self.Owner, trace) - self.Owner:LagCompensation(false) + hook.Run("PlayerThrowPunch", self:GetOwner(), trace) + self:GetOwner():LagCompensation(false) end end From c64e719bf27a08424eee7a54ca9bcfba836628b6 Mon Sep 17 00:00:00 2001 From: VindoesCompooter <100soundsystem32@gmail.com> Date: Thu, 4 Mar 2021 17:20:31 +0000 Subject: [PATCH 16/56] Key fix for 1.2-wip Added the key fix for 1.2-wip --- plugins/doors/entities/weapons/nut_keys.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/doors/entities/weapons/nut_keys.lua b/plugins/doors/entities/weapons/nut_keys.lua index e40bdc83..0062627b 100644 --- a/plugins/doors/entities/weapons/nut_keys.lua +++ b/plugins/doors/entities/weapons/nut_keys.lua @@ -112,6 +112,10 @@ function SWEP:PrimaryAttack() data.filter = self.Owner local entity = util.TraceLine(data).Entity + if (hook.Run("KeyLockOverride",self:GetOwner(),entity)) then + return + end + --[[ Locks the entity if the contiditon fits: 1. The entity is door and client has access to the door. @@ -192,6 +196,9 @@ function SWEP:SecondaryAttack() data.filter = self.Owner local entity = util.TraceLine(data).Entity + if (hook.Run("KeyUnlockOverride",self:GetOwner(),entity)) then + return + end --[[ Unlocks the entity if the contiditon fits: From bcb381afe7fcea330244e746e92ea44a82434af9 Mon Sep 17 00:00:00 2001 From: Zoephix Date: Thu, 4 Mar 2021 18:32:39 +0100 Subject: [PATCH 17/56] Optimizations --- entities/weapons/nut_hands.lua | 97 ++++++++++++++++++++-------------- 1 file changed, 56 insertions(+), 41 deletions(-) diff --git a/entities/weapons/nut_hands.lua b/entities/weapons/nut_hands.lua index 1c7eac5f..1ba6ce43 100644 --- a/entities/weapons/nut_hands.lua +++ b/entities/weapons/nut_hands.lua @@ -181,6 +181,8 @@ function SWEP:reset(throw) end if (IsValid(self.holdingEntity)) then + local owner = self:GetOwner() + if (!self.holdingEntity:IsWeapon()) then if (!IsValid(self.prevOwner)) then self.holdingEntity:SetOwner(nil) @@ -202,10 +204,10 @@ function SWEP:reset(throw) if (!throw) then removeVelocity(self.holdingEntity) else - throwVelocity(self.holdingEntity, self:GetOwner(), 300) + throwVelocity(self.holdingEntity, owner, 300) end - hook.Run("GravGunOnDropped", self:GetOwner(), self.holdingEntity, throw) + hook.Run("GravGunOnDropped", owner, self.holdingEntity, throw) end self.dt.carried_rag = nil @@ -304,11 +306,12 @@ if (SERVER) then stand_time = curTime + 0.1 end + local owner = self:GetOwner() local obb = math.abs(self.holdingEntity:GetModelBounds():Length2D()) - self.carryHack:SetPos(self:GetOwner():EyePos() + self:GetOwner():GetAimVector() * (35+obb)) + self.carryHack:SetPos(owner:EyePos() + owner:GetAimVector() * (35+obb)) - local targetAng = self:GetOwner():GetAngles() + local targetAng = owner:GetAngles() if (self.carryHack.preferedAngle) then targetAng.p = 0 @@ -319,8 +322,10 @@ if (SERVER) then end else function SWEP:Think() - if (CLIENT and self:GetOwner()) then - local viewModel = self:GetOwner():GetViewModel() + local owner = self:GetOwner() + + if (CLIENT and owner) then + local viewModel = owner:GetViewModel() if (IsValid(viewModel)) then viewModel:SetPlaybackRate(1) @@ -334,37 +339,39 @@ function SWEP:PrimaryAttack() return end + local owner = self:GetOwner() + if (IsValid(self.holdingEntity)) then - self:doPickup(!self.isWepRaised or self:GetOwner():isWepRaised()) + self:doPickup(!self.isWepRaised or owner:isWepRaised()) return end self:SetNextPrimaryFire(CurTime() + self.Primary.Delay) - if (hook.Run("CanPlayerThrowPunch", self:GetOwner()) == false) then + if (hook.Run("CanPlayerThrowPunch", owner) == false) then return end local staminaUse = nut.config.get("punchStamina", 10) if (staminaUse > 0) then - local value = self:GetOwner():getLocalVar("stm", 0) - staminaUse + local value = owner:getLocalVar("stm", 0) - staminaUse if (value < 0) then return elseif (SERVER) then - self:GetOwner():setLocalVar("stm", value) + owner:setLocalVar("stm", value) end end if (SERVER) then - self:GetOwner():EmitSound("npc/vort/claw_swing"..math.random(1, 2)..".wav") + owner:EmitSound("npc/vort/claw_swing"..math.random(1, 2)..".wav") end self:doPunchAnimation() - self:GetOwner():SetAnimation(PLAYER_ATTACK1) - self:GetOwner():ViewPunch(Angle(self.LastHand + 2, self.LastHand + 5, 0.125)) + owner:SetAnimation(PLAYER_ATTACK1) + owner:ViewPunch(Angle(self.LastHand + 2, self.LastHand + 5, 0.125)) self:SetNW2Float( "startTime", CurTime() ); self:SetNW2Bool( "startPunch", true ); @@ -389,13 +396,13 @@ function SWEP:SecondaryAttack() if (SERVER and IsValid(entity)) then if (entity:isDoor()) then - if (hook.Run("PlayerCanKnock", self:GetOwner(), entity) == false) then + if (hook.Run("PlayerCanKnock", client, entity) == false) then return end - self:GetOwner():ViewPunch(Angle(-1.3, 1.8, 0)) - self:GetOwner():EmitSound("physics/wood/wood_crate_impact_hard"..math.random(2, 3)..".wav") - self:GetOwner():SetAnimation(PLAYER_ATTACK1) + client:ViewPunch(Angle(-1.3, 1.8, 0)) + client:EmitSound("physics/wood/wood_crate_impact_hard"..math.random(2, 3)..".wav") + client:SetAnimation(PLAYER_ATTACK1) self:doPunchAnimation() self:SetNextSecondaryFire(CurTime() + 0.4) @@ -417,7 +424,9 @@ function SWEP:dragObject(phys, targetpos, is_ragdoll) return end - local point = self:GetOwner():GetShootPos() + self:GetOwner():GetAimVector() * 50 + local owner = self:GetOwner() + + local point = owner:GetShootPos() + owner:GetAimVector() * 50 local physDirection = targetpos - point local length = physDirection:Length2D() physDirection:Normalize() @@ -446,8 +455,8 @@ function SWEP:allowPickup(target) phys:GetMass() <= CARRY_WEIGHT_LIMIT and (!isPlayerStandsOn(target)) and (target.CanPickup != false) and - hook.Run("GravGunPickupAllowed", self:GetOwner(), target) != false and - (target.GravGunPickupAllowed and (target:GravGunPickupAllowed(self:GetOwner()) != false) or true) + hook.Run("GravGunPickupAllowed", client, target) != false and + (target.GravGunPickupAllowed and (target:GravGunPickupAllowed(client) != false) or true) end function SWEP:doPickup(throw, entity, trace) @@ -466,7 +475,7 @@ function SWEP:doPickup(throw, entity, trace) local phys = entity:GetPhysicsObject() if (!IsValid(phys) or !phys:IsMoveable() or phys:HasGameFlag(FVPHYSICS_PLAYER_HELD)) then - hook.Run("OnPickupObject", false, self:GetOwner(), entity) + hook.Run("OnPickupObject", false, client, entity) return end @@ -479,7 +488,7 @@ function SWEP:doPickup(throw, entity, trace) -- make the refire slower to avoid immediately dropping local delay = (entity:GetClass() == "prop_ragdoll") and 0.8 or 0.1 - hook.Run("OnPickupObject", true, self:GetOwner(), entity) + hook.Run("OnPickupObject", true, client, entity) self:SetNextSecondaryFire(CurTime() + delay) return else @@ -543,7 +552,7 @@ function SWEP:pickup(entity, trace) -- TODO: set the desired angles before adding the constraint local preferredAngles = hook.Run("GetPreferredCarryAngles", self.holdingEntity) - if (self:GetOwner():KeyDown(IN_RELOAD) and !preferredAngles) then + if (client:KeyDown(IN_RELOAD) and !preferredAngles) then preferredAngles = Angle() end @@ -558,7 +567,7 @@ function SWEP:pickup(entity, trace) self.carryHack:SetAngles(grabAngle) else - self.carryHack:SetAngles(self:GetOwner():GetAngles()) + self.carryHack:SetAngles(client:GetAngles()) end self.carryHack:Spawn() @@ -594,9 +603,9 @@ function SWEP:pickup(entity, trace) self:SetNW2Bool("holdingObject", true) self.constr = constraint.Weld(self.carryHack, self.holdingEntity, 0, bone, max_force, true) - self:GetOwner():EmitSound("physics/body/body_medium_impact_soft"..math.random(1, 3)..".wav", 75) + client:EmitSound("physics/body/body_medium_impact_soft"..math.random(1, 3)..".wav", 75) - hook.Run("GravGunOnPickedUp", self:GetOwner(), self.holdingEntity) + hook.Run("GravGunOnPickedUp", client, self.holdingEntity) end end end @@ -638,13 +647,15 @@ ACT_VM_FISTS_DRAW = 3 ACT_VM_FISTS_HOLSTER = 2 function SWEP:Deploy() - if (!IsValid(self:GetOwner())) then + local owner = self:GetOwner() + + if (!IsValid(owner)) then return end self:reset() - local viewModel = self:GetOwner():GetViewModel() + local viewModel = owner:GetViewModel() if (IsValid(viewModel)) then viewModel:SetPlaybackRate(1) @@ -655,13 +666,15 @@ function SWEP:Deploy() end function SWEP:Holster() - if (!IsValid(self:GetOwner())) then + local owner = self:GetOwner() + + if (!IsValid(owner)) then return end self:reset() - local viewModel = self:GetOwner():GetViewModel() + local viewModel = owner:GetViewModel() if (IsValid(viewModel)) then viewModel:SetPlaybackRate(1) @@ -701,10 +714,12 @@ function SWEP:doPunchAnimation() end function SWEP:doPunch() - if (IsValid(self) and IsValid(self:GetOwner())) then + local owner = self:GetOwner() + + if (IsValid(self) and IsValid(owner)) then local damage = self.Primary.Damage local context = {damage = damage} - local result = hook.Run("PlayerGetFistDamage", self:GetOwner(), damage, context) + local result = hook.Run("PlayerGetFistDamage", owner, damage, context) if (result != nil) then damage = result @@ -712,11 +727,11 @@ function SWEP:doPunch() damage = context.damage end - self:GetOwner():LagCompensation(true) + owner:LagCompensation(true) local data = {} - data.start = self:GetOwner():GetShootPos() - data.endpos = data.start + self:GetOwner():GetAimVector()*96 - data.filter = self:GetOwner() + data.start = owner:GetShootPos() + data.endpos = data.start + owner:GetAimVector()*96 + data.filter = owner local trace = util.TraceLine(data) if (SERVER and trace.Hit) then @@ -724,19 +739,19 @@ function SWEP:doPunch() if (IsValid(entity)) then local damageInfo = DamageInfo() - damageInfo:SetAttacker(self:GetOwner()) + damageInfo:SetAttacker(owner) damageInfo:SetInflictor(self) damageInfo:SetDamage(damage) damageInfo:SetDamageType(DMG_SLASH) damageInfo:SetDamagePosition(trace.HitPos) - damageInfo:SetDamageForce(self:GetOwner():GetAimVector()*10000) + damageInfo:SetDamageForce(owner:GetAimVector()*10000) entity:DispatchTraceAttack(damageInfo, data.start, data.endpos) - self:GetOwner():EmitSound("physics/body/body_medium_impact_hard"..math.random(1, 6)..".wav", 80) + owner:EmitSound("physics/body/body_medium_impact_hard"..math.random(1, 6)..".wav", 80) end end - hook.Run("PlayerThrowPunch", self:GetOwner(), trace) - self:GetOwner():LagCompensation(false) + hook.Run("PlayerThrowPunch", owner, trace) + owner:LagCompensation(false) end end From c0d12cbf6a69dd32cd75e4509c7f3fb6e0db788f Mon Sep 17 00:00:00 2001 From: Zoephix Date: Mon, 8 Mar 2021 11:42:48 +0100 Subject: [PATCH 18/56] Added hook for chat text add --- plugins/chatbox/derma/cl_chatbox.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/chatbox/derma/cl_chatbox.lua b/plugins/chatbox/derma/cl_chatbox.lua index de9ad954..c0ea018e 100644 --- a/plugins/chatbox/derma/cl_chatbox.lua +++ b/plugins/chatbox/derma/cl_chatbox.lua @@ -260,6 +260,8 @@ local PANEL = {} text = "" end + text = hook.Run("ChatAddText", text, ...) + for k, v in ipairs({...}) do if (type(v) == "IMaterial") then local ttx = v:GetName() From 967c0421715ddcc99c97596d2dca5ef4837354ee Mon Sep 17 00:00:00 2001 From: Zoephix Date: Mon, 8 Mar 2021 12:28:14 +0100 Subject: [PATCH 19/56] Added chat timestamps (#34) --- gamemode/config/sh_config.lua | 4 ++++ gamemode/core/libs/sh_chatbox.lua | 12 +++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/gamemode/config/sh_config.lua b/gamemode/config/sh_config.lua index 97b59708..daf3b332 100644 --- a/gamemode/config/sh_config.lua +++ b/gamemode/config/sh_config.lua @@ -62,6 +62,10 @@ nut.config.add("loocDelayAdmin", false, "Whether or not LOOC chat delay is enabl category = "chat" }) +nut.config.add("chatShowTime", false, "Whether or not to show timestamps in front of chat messages.", nil, { + category = "chat" +}) + nut.config.add("spawnTime", 5, "The time it takes to respawn.", nil, { data = {min = 0, max = 10000}, category = "characters" diff --git a/gamemode/core/libs/sh_chatbox.lua b/gamemode/core/libs/sh_chatbox.lua index 1441575f..01c84288 100644 --- a/gamemode/core/libs/sh_chatbox.lua +++ b/gamemode/core/libs/sh_chatbox.lua @@ -7,6 +7,11 @@ if (!nut.command) then include("sh_command.lua") end +-- Returns a timestamp +function nut.chat.timestamp(ooc) + return nut.config.get("chatShowTime") and (ooc and " " or "").."("..nut.date.getFormatted("%H:%M")..")"..(ooc and "" or " ") or "" +end + -- Registers a new chat type with the information provided. function nut.chat.register(chatType, data) if (!data.onCanHear) then @@ -52,9 +57,10 @@ function nut.chat.register(chatType, data) color = data.onGetColor(speaker, text) end + local timestamp = nut.chat.timestamp(false) local translated = L2(chatType.."Format", name, text) - chat.AddText(color, translated or string.format(data.format, name, text)) + chat.AddText(timestamp, color, translated or timestamp..string.format(data.format, name, text)) end end @@ -303,7 +309,7 @@ do icon = Material(hook.Run("GetPlayerIcon", speaker) or icon) - chat.AddText(icon, Color(255, 50, 50), " [OOC] ", speaker, color_white, ": "..text) + chat.AddText(icon, nut.chat.timestamp(true), Color(255, 50, 50), " [OOC] ", speaker, color_white, ": "..text) end, prefix = {"//", "/ooc"}, noSpaceAfter = true, @@ -334,7 +340,7 @@ do speaker.nutLastLOOC = CurTime() end, onChatAdd = function(speaker, text) - chat.AddText(Color(255, 50, 50), "[LOOC] ", nut.config.get("chatColor"), speaker:Name()..": "..text) + chat.AddText(nut.chat.timestamp(false), Color(255, 50, 50), "[LOOC] ", nut.config.get("chatColor"), speaker:Name()..": "..text) end, onCanHear = nut.config.get("chatRange", 280), prefix = {".//", "[[", "/looc"}, From de88a739ffb456ac7f298cbc2a6adddc01ccf34b Mon Sep 17 00:00:00 2001 From: Zoephix Date: Mon, 8 Mar 2021 13:01:43 +0100 Subject: [PATCH 20/56] Added chat size difference plugin --- plugins/chatsizediff.lua | 64 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 plugins/chatsizediff.lua diff --git a/plugins/chatsizediff.lua b/plugins/chatsizediff.lua new file mode 100644 index 00000000..41b2eca9 --- /dev/null +++ b/plugins/chatsizediff.lua @@ -0,0 +1,64 @@ +--[[ + This script is part of Black Mesa Roleplay schema by Zoephix and + exclusively made for LimeFruit (limefruit.net) + + © Copyright 2020: Zoephix. do not share, use, re-distribute or modify + without written permission from Zoephix. +--]] + +PLUGIN.name = "Chat Size Difference" +PLUGIN.desc = "Overrides size for different chat types." +PLUGIN.author = "Zoephix" + +nut.config.add("chatSizeDiff", true, "Whether or not to use different chat sizes.", nil, { + category = "chat" +}) + +if (CLIENT) then + function PLUGIN:LoadFonts(font) + print(font) + surface.CreateFont("nutSmallChatFont", { + font = font, + size = math.max(ScreenScale(7), 17), + extended = true, + weight = 200 + }) + + surface.CreateFont("nutMediumChatFont", { + font = font, + size = math.max(ScreenScale(9), 17), + extended = true, + weight = 200 + }) + + surface.CreateFont("nutBigChatFont", { + font = font, + size = math.max(ScreenScale(11), 17), + extended = true, + weight = 200 + }) + end + + function PLUGIN:ChatAddText(text, ...) + if (nut.config.get("chatSizeDiff", true)) then + local chatText = {...} + local chatMode = #chatText > 5 and chatText[3] or chatText[#chatText] + + if (istable(chatMode)) then + return "" + else + local chatMode = string.lower(chatMode) + + if (string.match(chatMode, "yell")) then + return "" + elseif (string.match(chatMode, "whisper")) then + return "" + else + return "" + end + end + else + return text + end + end +end From da3202d45e396e88e492e18463ae304d3a347845 Mon Sep 17 00:00:00 2001 From: Zoephix Date: Mon, 8 Mar 2021 13:56:26 +0100 Subject: [PATCH 21/56] Update chatsizediff.lua --- plugins/chatsizediff.lua | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/plugins/chatsizediff.lua b/plugins/chatsizediff.lua index 41b2eca9..f9b23b7f 100644 --- a/plugins/chatsizediff.lua +++ b/plugins/chatsizediff.lua @@ -1,11 +1,3 @@ ---[[ - This script is part of Black Mesa Roleplay schema by Zoephix and - exclusively made for LimeFruit (limefruit.net) - - © Copyright 2020: Zoephix. do not share, use, re-distribute or modify - without written permission from Zoephix. ---]] - PLUGIN.name = "Chat Size Difference" PLUGIN.desc = "Overrides size for different chat types." PLUGIN.author = "Zoephix" @@ -16,7 +8,6 @@ nut.config.add("chatSizeDiff", true, "Whether or not to use different chat sizes if (CLIENT) then function PLUGIN:LoadFonts(font) - print(font) surface.CreateFont("nutSmallChatFont", { font = font, size = math.max(ScreenScale(7), 17), @@ -53,6 +44,8 @@ if (CLIENT) then return "" elseif (string.match(chatMode, "whisper")) then return "" + elseif (string.match(chatMode, "ooc") or string.match(chatMode, "looc")) then + return "" else return "" end From d2f4c12086a444a85917bc0404a8b4de92532038 Mon Sep 17 00:00:00 2001 From: Zoephix Date: Mon, 8 Mar 2021 14:00:27 +0100 Subject: [PATCH 22/56] Update chatsizediff.lua --- plugins/chatsizediff.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/chatsizediff.lua b/plugins/chatsizediff.lua index f9b23b7f..ad7ac647 100644 --- a/plugins/chatsizediff.lua +++ b/plugins/chatsizediff.lua @@ -33,7 +33,7 @@ if (CLIENT) then function PLUGIN:ChatAddText(text, ...) if (nut.config.get("chatSizeDiff", true)) then local chatText = {...} - local chatMode = #chatText > 5 and chatText[3] or chatText[#chatText] + local chatMode = #chatText <= 4 and chatText[2] or chatText[3] if (istable(chatMode)) then return "" From 5b171f1f8b7afc3aff01748a11c199e7cc214107 Mon Sep 17 00:00:00 2001 From: Zoephix Date: Mon, 8 Mar 2021 14:22:13 +0100 Subject: [PATCH 23/56] tweaked font sizes --- plugins/chatsizediff.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/chatsizediff.lua b/plugins/chatsizediff.lua index ad7ac647..80c1e980 100644 --- a/plugins/chatsizediff.lua +++ b/plugins/chatsizediff.lua @@ -10,21 +10,21 @@ if (CLIENT) then function PLUGIN:LoadFonts(font) surface.CreateFont("nutSmallChatFont", { font = font, - size = math.max(ScreenScale(7), 17), + size = math.max(ScreenScale(6), 17), extended = true, weight = 200 }) surface.CreateFont("nutMediumChatFont", { font = font, - size = math.max(ScreenScale(9), 17), + size = math.max(ScreenScale(7), 17), extended = true, weight = 200 }) surface.CreateFont("nutBigChatFont", { font = font, - size = math.max(ScreenScale(11), 17), + size = math.max(ScreenScale(8), 17), extended = true, weight = 200 }) From 4532414b06ae6efaec83b9e9a023aa12558965c3 Mon Sep 17 00:00:00 2001 From: Zoephix Date: Mon, 8 Mar 2021 14:45:54 +0100 Subject: [PATCH 24/56] Support added for actions --- plugins/chatsizediff.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/chatsizediff.lua b/plugins/chatsizediff.lua index 80c1e980..41833674 100644 --- a/plugins/chatsizediff.lua +++ b/plugins/chatsizediff.lua @@ -15,6 +15,14 @@ if (CLIENT) then weight = 200 }) + surface.CreateFont("nutItalicsChatFont", { + font = font, + size = math.max(ScreenScale(7), 17), + extended = true, + weight = 600, + italic = true + }) + surface.CreateFont("nutMediumChatFont", { font = font, size = math.max(ScreenScale(7), 17), @@ -42,6 +50,8 @@ if (CLIENT) then if (string.match(chatMode, "yell")) then return "" + elseif (string.sub(chatMode, 1, 2) == "**") then + return "" elseif (string.match(chatMode, "whisper")) then return "" elseif (string.match(chatMode, "ooc") or string.match(chatMode, "looc")) then From cb68ea335939b3768ff15e7824f80fe4e946de1c Mon Sep 17 00:00:00 2001 From: Zoephix Date: Mon, 8 Mar 2021 14:49:11 +0100 Subject: [PATCH 25/56] Fixed invalid chat mode returning nil --- plugins/chatsizediff.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/chatsizediff.lua b/plugins/chatsizediff.lua index 41833674..6113745a 100644 --- a/plugins/chatsizediff.lua +++ b/plugins/chatsizediff.lua @@ -43,7 +43,7 @@ if (CLIENT) then local chatText = {...} local chatMode = #chatText <= 4 and chatText[2] or chatText[3] - if (istable(chatMode)) then + if (!chatMode or istable(chatMode)) then return "" else local chatMode = string.lower(chatMode) From b4f087f35d32d1daf6338941791deee0426075d5 Mon Sep 17 00:00:00 2001 From: Zoephix Date: Mon, 8 Mar 2021 14:50:31 +0100 Subject: [PATCH 26/56] Increased font weight --- plugins/chatsizediff.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/chatsizediff.lua b/plugins/chatsizediff.lua index 6113745a..d5f1778a 100644 --- a/plugins/chatsizediff.lua +++ b/plugins/chatsizediff.lua @@ -12,7 +12,7 @@ if (CLIENT) then font = font, size = math.max(ScreenScale(6), 17), extended = true, - weight = 200 + weight = 750 }) surface.CreateFont("nutItalicsChatFont", { From 01a7b126033c51cdcd70605516db2dec3299df0f Mon Sep 17 00:00:00 2001 From: TovarischPootis <54110479+TovarischPootis@users.noreply.github.com> Date: Sun, 14 Mar 2021 20:45:06 +0200 Subject: [PATCH 27/56] 1.2 wip Date/Time. != vs ~=, small fix when spawning bots (#33) --- entities/weapons/nut_hands.lua | 62 ++++++++--------- gamemode/core/derma/cl_inventory.lua | 10 +-- gamemode/core/derma/cl_modelpanel.lua | 2 +- gamemode/core/derma/cl_spawnicon.lua | 2 +- gamemode/core/hooks/cl_hooks.lua | 7 +- gamemode/core/hooks/sh_hooks.lua | 2 +- gamemode/core/hooks/sv_hooks.lua | 6 +- gamemode/core/libs/cl_networking.lua | 4 +- gamemode/core/libs/sh_character.lua | 10 +-- gamemode/core/libs/sh_chatbox.lua | 6 +- gamemode/core/libs/sh_class.lua | 2 +- gamemode/core/libs/sh_command.lua | 8 +-- gamemode/core/libs/sh_date.lua | 69 ++++++++++++++++--- gamemode/core/libs/sh_flag.lua | 4 +- gamemode/core/libs/sh_item.lua | 2 +- gamemode/core/libs/sv_database.lua | 16 ++--- gamemode/core/libs/sv_networking.lua | 6 +- gamemode/core/libs/thirdparty/cl_ikon.lua | 4 +- .../core/libs/thirdparty/sh_netstream2.lua | 4 +- gamemode/core/meta/sh_character.lua | 10 +-- gamemode/core/meta/sh_item.lua | 2 +- gamemode/core/sh_config.lua | 10 +-- gamemode/core/sv_data.lua | 8 +-- gamemode/core/util/cl_draw.lua | 4 +- gamemode/core/util/sv_action.lua | 2 +- gamemode/items/base/sh_outfit.lua | 4 +- gamemode/items/base/sh_pacoutfit.lua | 4 +- gamemode/items/base/sh_weapons.lua | 4 +- gamemode/languages/sh_english.lua | 5 -- gamemode/shared.lua | 6 +- plugins/area/sh_plugin.lua | 8 +-- plugins/attributes/derma/cl_attribute.lua | 2 +- plugins/attributes/sh_plugin.lua | 2 +- plugins/bars/libs/cl_bar.lua | 2 +- plugins/business/derma/cl_business.lua | 6 +- .../entities/entities/nut_shipment.lua | 2 +- plugins/chatbox/sh_plugin.lua | 2 +- plugins/crosshair.lua | 2 +- plugins/deathscreen.lua | 4 +- plugins/doors/cl_plugin.lua | 2 +- plugins/doors/derma/cl_door.lua | 8 +-- plugins/doors/sv_plugin.lua | 8 +-- .../derma/cl_grid_inventory_panel.lua | 2 +- plugins/gridinv/sh_grid_inv.lua | 2 +- plugins/nshud/sh_plugin.lua | 4 +- plugins/nsintro/sh_plugin.lua | 2 +- plugins/persistence.lua | 21 +++--- plugins/recognition.lua | 14 ++-- plugins/scoreboard/derma/cl_scoreboard.lua | 12 ++-- plugins/spawns.lua | 2 +- plugins/stamina/sh_plugin.lua | 2 +- plugins/storage/sh_plugin.lua | 2 +- .../entities/entities/nut_vendor/shared.lua | 2 +- plugins/vignette.lua | 2 +- 54 files changed, 221 insertions(+), 179 deletions(-) diff --git a/entities/weapons/nut_hands.lua b/entities/weapons/nut_hands.lua index 1ba6ce43..39addcee 100644 --- a/entities/weapons/nut_hands.lua +++ b/entities/weapons/nut_hands.lua @@ -100,7 +100,7 @@ local CurTime = CurTime local function SetSubPhysMotionEnabled(entity, enable) - if (!IsValid(entity)) then + if (not IsValid(entity)) then return end @@ -183,8 +183,8 @@ function SWEP:reset(throw) if (IsValid(self.holdingEntity)) then local owner = self:GetOwner() - if (!self.holdingEntity:IsWeapon()) then - if (!IsValid(self.prevOwner)) then + if (not self.holdingEntity:IsWeapon()) then + if (not IsValid(self.prevOwner)) then self.holdingEntity:SetOwner(nil) else self.holdingEntity:SetOwner(self.prevOwner) @@ -201,7 +201,7 @@ function SWEP:reset(throw) phys:EnableMotion(true) end - if (!throw) then + if (not throw) then removeVelocity(self.holdingEntity) else throwVelocity(self.holdingEntity, owner, 300) @@ -219,8 +219,8 @@ function SWEP:reset(throw) end function SWEP:drop(throw) - if (!self:checkValidity()) then return end - if (!self:allowEntityDrop()) then return end + if (not self:checkValidity()) then return end + if (not self:allowEntityDrop()) then return end if (SERVER) then self.constr:Remove() @@ -253,7 +253,7 @@ function SWEP:drop(throw) end function SWEP:checkValidity() - if (!IsValid(self.holdingEntity)) or (!IsValid(self.carryHack)) or (!IsValid(self.constr)) then + if (not IsValid(self.holdingEntity)) or (not IsValid(self.carryHack)) or (not IsValid(self.constr)) then -- if one of them is not valid but another is non-nil... if (self.holdingEntity or self.carryHack or self.constr) then self:reset() @@ -281,7 +281,7 @@ if (SERVER) then local stand_time = 0 function SWEP:Think() - if (!self:checkValidity()) then + if (not self:checkValidity()) then return end @@ -322,7 +322,7 @@ if (SERVER) then end else function SWEP:Think() - local owner = self:GetOwner() + local owner = self:GetOwner() if (CLIENT and owner) then local viewModel = owner:GetViewModel() @@ -335,14 +335,14 @@ else end function SWEP:PrimaryAttack() - if (!IsFirstTimePredicted()) then + if (not IsFirstTimePredicted()) then return end local owner = self:GetOwner() if (IsValid(self.holdingEntity)) then - self:doPickup(!self.isWepRaised or owner:isWepRaised()) + self:doPickup(not self.isWepRaised or owner:isWepRaised()) return end @@ -379,7 +379,7 @@ end local hull = Vector(4, 4, 4) function SWEP:SecondaryAttack() - if (!IsFirstTimePredicted()) then + if (not IsFirstTimePredicted()) then return end @@ -407,9 +407,9 @@ function SWEP:SecondaryAttack() self:doPunchAnimation() self:SetNextSecondaryFire(CurTime() + 0.4) self:SetNextPrimaryFire(CurTime() + 1) - elseif (!entity:IsPlayer() and !entity:IsNPC()) then + elseif (not entity:IsPlayer() and not entity:IsNPC()) then self:doPickup(false, entity, trace) - elseif (IsValid(self.heldEntity) and !self.heldEntity:IsPlayerHolding()) then + elseif (IsValid(self.heldEntity) and not self.heldEntity:IsPlayerHolding()) then self.heldEntity = nil end else @@ -419,8 +419,8 @@ function SWEP:SecondaryAttack() end end -function SWEP:dragObject(phys, targetpos, is_ragdoll) - if (!IsValid(phys)) then +function SWEP:dragObject(phys, targetpos) + if (not IsValid(phys)) then return end @@ -431,8 +431,6 @@ function SWEP:dragObject(phys, targetpos, is_ragdoll) local length = physDirection:Length2D() physDirection:Normalize() - local mass = phys:GetMass() - phys:SetVelocity(physDirection * math.min(length, 250)) end @@ -451,12 +449,12 @@ function SWEP:allowPickup(target) return IsValid(phys) and IsValid(client) and client:getChar() and - (!phys:HasGameFlag(FVPHYSICS_NO_PLAYER_PICKUP)) and + (not phys:HasGameFlag(FVPHYSICS_NO_PLAYER_PICKUP)) and phys:GetMass() <= CARRY_WEIGHT_LIMIT and - (!isPlayerStandsOn(target)) and - (target.CanPickup != false) and - hook.Run("GravGunPickupAllowed", client, target) != false and - (target.GravGunPickupAllowed and (target:GravGunPickupAllowed(client) != false) or true) + (not isPlayerStandsOn(target)) and + (target.CanPickup ~= false) and + hook.Run("GravGunPickupAllowed", client, target) ~= false and + (target.GravGunPickupAllowed and (target:GravGunPickupAllowed(client) ~= false) or true) end function SWEP:doPickup(throw, entity, trace) @@ -474,7 +472,7 @@ function SWEP:doPickup(throw, entity, trace) if (IsValid(entity)) then local phys = entity:GetPhysicsObject() - if (!IsValid(phys) or !phys:IsMoveable() or phys:HasGameFlag(FVPHYSICS_PLAYER_HELD)) then + if (not IsValid(phys) or not phys:IsMoveable() or phys:HasGameFlag(FVPHYSICS_PLAYER_HELD)) then hook.Run("OnPickupObject", false, client, entity) return end @@ -492,7 +490,7 @@ function SWEP:doPickup(throw, entity, trace) self:SetNextSecondaryFire(CurTime() + delay) return else - local is_ragdoll = entity:GetClass() == "prop_ragdoll" + --local is_ragdoll = entity:GetClass() == "prop_ragdoll" --[[ --Drag ragdoll/props @@ -552,7 +550,7 @@ function SWEP:pickup(entity, trace) -- TODO: set the desired angles before adding the constraint local preferredAngles = hook.Run("GetPreferredCarryAngles", self.holdingEntity) - if (client:KeyDown(IN_RELOAD) and !preferredAngles) then + if (client:KeyDown(IN_RELOAD) and not preferredAngles) then preferredAngles = Angle() end @@ -572,7 +570,7 @@ function SWEP:pickup(entity, trace) self.carryHack:Spawn() - if (!self.holdingEntity:IsWeapon()) then + if (not self.holdingEntity:IsWeapon()) then self.prevOwner = self.holdingEntity:GetOwner() self.holdingEntity:SetOwner(client) @@ -614,7 +612,7 @@ local down = Vector(0, 0, -1) function SWEP:allowEntityDrop() local client = self:GetOwner() - if (!IsValid(client)) or (!IsValid(self.carryHack)) then return false end + if (not IsValid(client)) or (not IsValid(self.carryHack)) then return false end local ground = client:GetGroundEntity() if ground and (ground:IsWorld() or IsValid(ground)) then return true end @@ -648,8 +646,8 @@ ACT_VM_FISTS_HOLSTER = 2 function SWEP:Deploy() local owner = self:GetOwner() - - if (!IsValid(owner)) then + + if (not IsValid(owner)) then return end @@ -668,7 +666,7 @@ end function SWEP:Holster() local owner = self:GetOwner() - if (!IsValid(owner)) then + if (not IsValid(owner)) then return end @@ -721,7 +719,7 @@ function SWEP:doPunch() local context = {damage = damage} local result = hook.Run("PlayerGetFistDamage", owner, damage, context) - if (result != nil) then + if (result ~= nil) then damage = result else damage = context.damage diff --git a/gamemode/core/derma/cl_inventory.lua b/gamemode/core/derma/cl_inventory.lua index 967c45c9..20be1b44 100644 --- a/gamemode/core/derma/cl_inventory.lua +++ b/gamemode/core/derma/cl_inventory.lua @@ -160,7 +160,7 @@ function PANEL:openActionMenu() end end - if (send != false) then + if (send ~= false) then netstream.Start("invAct", k, itemTable.id, self.invID) end itemTable.player = nil @@ -190,7 +190,7 @@ function PANEL:openActionMenu() end end - if (send != false) then + if (send ~= false) then netstream.Start( "invAct", k, @@ -221,7 +221,7 @@ function PANEL:openActionMenu() end end - if (send != false) then + if (send ~= false) then netstream.Start("invAct", k, itemTable.id, self.invID) end itemTable.player = nil @@ -287,7 +287,7 @@ vgui.Register("nutInventory", PANEL, "DFrame") local margin = 10 hook.Add("CreateMenuButtons", "nutInventory", function(tabs) - if (hook.Run("CanPlayerViewInventory") != false) then + if (hook.Run("CanPlayerViewInventory") ~= false) then tabs["inv"] = function(panel) local inventory = LocalPlayer():getChar():getInv() @@ -302,7 +302,7 @@ hook.Add("CreateMenuButtons", "nutInventory", function(tabs) totalSize.y = math.max(totalSize.y, mainPanel:GetTall()) for id, item in pairs(inventory:getItems()) do - if (item.isBag and hook.Run("CanOpenBagPanel", item) != false) then + if (item.isBag and hook.Run("CanOpenBagPanel", item) ~= false) then local inventory = item:getInv() local childPanels = inventory:show(mainPanel) diff --git a/gamemode/core/derma/cl_modelpanel.lua b/gamemode/core/derma/cl_modelpanel.lua index b6452e53..8bbc8526 100644 --- a/gamemode/core/derma/cl_modelpanel.lua +++ b/gamemode/core/derma/cl_modelpanel.lua @@ -24,7 +24,7 @@ local PANEL = {} local found = false for k, v in ipairs(entity:GetSequenceList()) do - if ((v:lower():find("idle") or v:lower():find("fly")) and v != "idlenoise") then + if ((v:lower():find("idle") or v:lower():find("fly")) and v ~= "idlenoise") then entity:ResetSequence(v) found = true diff --git a/gamemode/core/derma/cl_spawnicon.lua b/gamemode/core/derma/cl_spawnicon.lua index df399ad9..dc94d4f2 100644 --- a/gamemode/core/derma/cl_spawnicon.lua +++ b/gamemode/core/derma/cl_spawnicon.lua @@ -34,7 +34,7 @@ local PANEL = {} local found = false for k, v in ipairs(entity:GetSequenceList()) do - if ((v:lower():find("idle") or v:lower():find("fly")) and v != "idlenoise") then + if ((v:lower():find("idle") or v:lower():find("fly")) and v ~= "idlenoise") then entity:ResetSequence(v) found = true diff --git a/gamemode/core/hooks/cl_hooks.lua b/gamemode/core/hooks/cl_hooks.lua index 54b99732..28d588fa 100644 --- a/gamemode/core/hooks/cl_hooks.lua +++ b/gamemode/core/hooks/cl_hooks.lua @@ -285,7 +285,8 @@ function GM:InitializedConfig() end function GM:CharacterListLoaded() - local shouldPlayIntro = not nut.config.get("playIntroOnlyOnce", true) or not nut.localData.intro or nil + local shouldPlayIntro = nut.config.get("alwaysPlayIntro", true) or not nut.localData.intro or nil + print("shouldPlayIntro", shouldPlayIntro) timer.Create("nutWaitUntilPlayerValid", 0.5, 0, function() if (not IsValid(LocalPlayer())) then return end timer.Remove("nutWaitUntilPlayerValid") @@ -294,7 +295,7 @@ function GM:CharacterListLoaded() if (IsValid(nut.gui.loading)) then nut.gui.loading:Remove() end - + RunConsoleCommand("stopsound") -- Show the intro if needed, then show the character menu. local intro = shouldPlayIntro and hook.Run("CreateIntroduction") or nil @@ -462,7 +463,7 @@ function GM:ItemShowEntityMenu(entity) surface.PlaySound(v.sound) end - if (send != false) then + if (send ~= false) then callback(k) end end diff --git a/gamemode/core/hooks/sh_hooks.lua b/gamemode/core/hooks/sh_hooks.lua index 2bf4e404..df8dbdad 100644 --- a/gamemode/core/hooks/sh_hooks.lua +++ b/gamemode/core/hooks/sh_hooks.lua @@ -374,6 +374,6 @@ function GM:CanItemBeTransfered(itemObject, curInv, inventory) if (itemObject.onCanBeTransfered) then local itemHook = itemObject:onCanBeTransfered(curInv, inventory) - return (itemHook != false) + return (itemHook ~= false) end end diff --git a/gamemode/core/hooks/sv_hooks.lua b/gamemode/core/hooks/sv_hooks.lua index 3bb1743f..3e6682e7 100644 --- a/gamemode/core/hooks/sv_hooks.lua +++ b/gamemode/core/hooks/sv_hooks.lua @@ -107,7 +107,7 @@ function GM:CanPlayerDropItem(client, item) if (inventory) then local items = inventory:getItems() - + for id, item in pairs(items) do if (not item.ignoreEquipCheck and item:getData("equip") == true) then client:notifyLocalized("cantDropBagHasEquipped") @@ -158,7 +158,7 @@ function GM:CanPlayerTakeItem(client, item) end function GM:PlayerShouldTakeDamage(client, attacker) - return client:getChar() != nil + return client:getChar() ~= nil end function GM:EntityTakeDamage(entity, dmgInfo) @@ -607,7 +607,7 @@ end function GM:OnServerLog(client, logType, ...) for k, v in pairs(nut.util.getAdmins()) do - if (hook.Run("CanPlayerSeeLog", v, logType) != false) then + if (hook.Run("CanPlayerSeeLog", v, logType) ~= false) then nut.log.send(v, nut.log.getString(client, logType, ...)) end end diff --git a/gamemode/core/libs/cl_networking.lua b/gamemode/core/libs/cl_networking.lua index b211541d..d1a1386b 100644 --- a/gamemode/core/libs/cl_networking.lua +++ b/gamemode/core/libs/cl_networking.lua @@ -25,13 +25,13 @@ end) function getNetVar(key, default) local value = nut.net.globals[key] - return value != nil and value or default + return value ~= nil and value or default end function entityMeta:getNetVar(key, default) local index = self:EntIndex() - if (nut.net[index] and nut.net[index][key] != nil) then + if (nut.net[index] and nut.net[index][key] ~= nil) then return nut.net[index][key] end diff --git a/gamemode/core/libs/sh_character.lua b/gamemode/core/libs/sh_character.lua index a6694a1a..bff30dd9 100644 --- a/gamemode/core/libs/sh_character.lua +++ b/gamemode/core/libs/sh_character.lua @@ -28,7 +28,7 @@ if (SERVER) then netstream.Hook("nutCharFetchNames", function(client) netstream.Start(client, "nutCharFetchNames", nut.char.names) end) - + -- Removes name from table upon character deletion hook.Add("nutCharDeleted", "nutCharRemoveName", function(client, character) nut.char.names[character:getID()] = nil @@ -101,9 +101,9 @@ do if (not isstring(value) or not value:find("%S")) then return false, "invalid", "name" end - + local allowExistNames = nut.config.get("allowExistNames", true) - + -- Fetch existing character names if (CLIENT and #nut.char.names < 1 and !allowExistNames) then netstream.Start("nutCharFetchNames") @@ -112,7 +112,7 @@ do nut.char.names = data end) end - + -- Check whether the chosen character name already exists if (!nut.config.get("allowExistNames", true)) then for k, v in pairs(nut.char.names) do @@ -121,7 +121,7 @@ do end end end - + return true end, onAdjust = function(client, data, value, newData) diff --git a/gamemode/core/libs/sh_chatbox.lua b/gamemode/core/libs/sh_chatbox.lua index 01c84288..fe62a402 100644 --- a/gamemode/core/libs/sh_chatbox.lua +++ b/gamemode/core/libs/sh_chatbox.lua @@ -147,12 +147,12 @@ if (SERVER) then function nut.chat.send(speaker, chatType, text, anonymous, receivers) local class = nut.chat.classes[chatType] - if (class and class.onCanSay(speaker, text) != false) then + if (class and class.onCanSay(speaker, text) ~= false) then if (class.onCanHear and !receivers) then receivers = {} for k, v in ipairs(player.GetAll()) do - if (v:getChar() and class.onCanHear(speaker, v) != false) then + if (v:getChar() and class.onCanHear(speaker, v) ~= false) then receivers[#receivers + 1] = v end end @@ -175,7 +175,7 @@ else if (class) then CHAT_CLASS = class class.onChatAdd(client, text, anonymous) - if (SOUND_CUSTOM_CHAT_SOUND and SOUND_CUSTOM_CHAT_SOUND != "") then + if (SOUND_CUSTOM_CHAT_SOUND and SOUND_CUSTOM_CHAT_SOUND ~= "") then surface.PlaySound(SOUND_CUSTOM_CHAT_SOUND) else chat.PlaySound() diff --git a/gamemode/core/libs/sh_class.lua b/gamemode/core/libs/sh_class.lua index 5203a851..21bb64c8 100644 --- a/gamemode/core/libs/sh_class.lua +++ b/gamemode/core/libs/sh_class.lua @@ -71,7 +71,7 @@ function nut.class.canBe(client, class) end -- If the player's faction matches the class's faction. - if (client:Team() != info.faction) then + if (client:Team() ~= info.faction) then return false, "not correct team" end diff --git a/gamemode/core/libs/sh_command.lua b/gamemode/core/libs/sh_command.lua index 974ed467..67ad3f06 100644 --- a/gamemode/core/libs/sh_command.lua +++ b/gamemode/core/libs/sh_command.lua @@ -76,12 +76,12 @@ function nut.command.add(command, data) nut.command.list[alias:lower()] = data end end - + if (command == command:lower()) then nut.command.list[command] = data else data.realCommand = command - + nut.command.list[command:lower()] = data end end @@ -122,7 +122,7 @@ function nut.command.extractArgs(text) else curString = curString..c end - elseif (c == " " and curString != "") then + elseif (c == " " and curString ~= "") then arguments[#arguments + 1] = curString curString = "" else @@ -134,7 +134,7 @@ function nut.command.extractArgs(text) end end - if (curString != "") then + if (curString ~= "") then arguments[#arguments + 1] = curString end diff --git a/gamemode/core/libs/sh_date.lua b/gamemode/core/libs/sh_date.lua index d0fe8516..6c6651ad 100644 --- a/gamemode/core/libs/sh_date.lua +++ b/gamemode/core/libs/sh_date.lua @@ -1,24 +1,53 @@ -- Module for date and time calculations nut.date = nut.date or {} +nut.date.diff = nut.date.diff or 0 if (not nut.config) then include("nutscript/gamemode/core/sh_config.lua") end -nut.config.add("year", tonumber(os.date("%Y")), "The current year of the schema." , nil, { +if SERVER then + util.AddNetworkString("syncClientTime") + + nut.date.syncClientTime = function(client) + net.Start("syncClientTime") + net.WriteString(tostring(nut.date.diff)) + net.Send(client) + end +end + +nut.config.add("year", tonumber(os.date("%Y")), "The current year of the schema." , function() + if SERVER then + for k, client in pairs(player.GetHumans()) do + nut.date.syncClientTime(client) + end + end +end, { data = {min = 0, max = 4000}, category = "date" } ) -nut.config.add("month", tonumber(os.date("%m")), "The current month of the schema." , nil, { +nut.config.add("month", tonumber(os.date("%m")), "The current month of the schema." , function() + if SERVER then + for k, client in pairs(player.GetHumans()) do + nut.date.syncClientTime(client) + end + end +end, { data = {min = 1, max = 12}, category = "date" } ) -nut.config.add("day", tonumber(os.date("%d")), "The current day of the schema." , nil, { +nut.config.add("day", tonumber(os.date("%d")), "The current day of the schema." , function() + if SERVER then + for k, client in pairs(player.GetHumans()) do + nut.date.syncClientTime(client) + end + end +end, { data = {min = 1, max = 31}, category = "date" } @@ -35,13 +64,13 @@ nut.config.add("yearAppendix", "", "Add a custom appendix to your date, if you u function nut.date.get() return os.time({ - year=os.date("%Y"), - month=nut.config.get("month"), - day=nut.config.get("day"), - hour=os.date("%H"), - min=os.date("%M"), - sec=os.date("%S") - }) + year=os.date("%Y"), + month=nut.config.get("month"), + day=nut.config.get("day"), + hour=os.date("!%H"), + min=os.date("!%M"), + sec=os.date("!%S") + }) + (nut.date.diff or 0) end --function takes the time number if provided, or current time and applies a string format to it @@ -56,6 +85,12 @@ if SERVER then -- Checks the time difference between the old time values and current time, and updates month and day to advance in the time difference -- creates a timer that updates the month and day values, in case the server runs continuously without restarts. function nut.date.initialize() + local function getTimeZoneDifference() + local now = os.time() + return now - os.time(os.date("!*t", now)) + end + + nut.date.diff = getTimeZoneDifference() -- Migrations if (istable(nut.data.get("date", os.time(), true))) then @@ -112,4 +147,18 @@ if SERVER then hook.Add("SaveData", "nutDateSave", function() nut.date.save() end) + + net.Receive("syncClientTime", function(_, client) + nut.date.syncClientTime(client) + end) + +elseif CLIENT then + net.Receive("syncClientTime", function() + nut.date.diff = tonumber(net.ReadString()) + end) + + hook.Add("InitPostEntity", "nutSyncTime", function() + net.Start("syncClientTime") + net.SendToServer() + end) end \ No newline at end of file diff --git a/gamemode/core/libs/sh_flag.lua b/gamemode/core/libs/sh_flag.lua index 0f77d299..72ca7159 100644 --- a/gamemode/core/libs/sh_flag.lua +++ b/gamemode/core/libs/sh_flag.lua @@ -63,7 +63,7 @@ do end -- Only change the flag string if it is different. - if (addedFlags != "") then + if (addedFlags ~= "") then self:setFlags(self:getFlags()..addedFlags) end end @@ -87,7 +87,7 @@ do newFlags = newFlags:gsub(flag, "") end - if (newFlags != oldFlags) then + if (newFlags ~= oldFlags) then self:setFlags(newFlags) end end diff --git a/gamemode/core/libs/sh_item.lua b/gamemode/core/libs/sh_item.lua index e53222bb..9904f2cb 100644 --- a/gamemode/core/libs/sh_item.lua +++ b/gamemode/core/libs/sh_item.lua @@ -161,7 +161,7 @@ nut.char.registerVar("inv", { noNetworking = true, noDisplay = true, onGet = function(character, index) - if (index and type(index) != "number") then + if (index and type(index) ~= "number") then return character.vars.inv or {} end diff --git a/gamemode/core/libs/sv_database.lua b/gamemode/core/libs/sv_database.lua index 902d9100..14ffb632 100644 --- a/gamemode/core/libs/sv_database.lua +++ b/gamemode/core/libs/sv_database.lua @@ -94,8 +94,8 @@ modules.tmysql4 = { return tmysql and tmysql.escape and tmysql.escape(value) or sql.SQLStr(value, true) end, connect = function(callback) - if (!pcall(require, "tmysql4")) then - return setNetVar("dbError", system.IsWindows() and "Server is missing VC++ redistributables!" or "Server is missing binaries for tmysql4!") + if (not pcall(require, "tmysql4")) then + return setNetVar("dbError", system.IsWindows() and "Server is missing VC++ redistributables! " or "Server is missing binaries for tmysql4! ") end local hostname = nut.db.hostname @@ -185,7 +185,7 @@ modules.mysqloo = { for k, db in pairs(nut.db.pool) do local queueSize = db:queueSize() - if (!lowest or queueSize < lowestCount) then + if (not lowest or queueSize < lowestCount) then lowest = db lowestCount = queueSize lowestIndex = k @@ -199,11 +199,11 @@ modules.mysqloo = { return lowest, lowestIndex end, connect = function(callback) - if (!pcall(require, "mysqloo")) then - return setNetVar("dbError", system.IsWindows() and "Server is missing VC++ redistributables!" or "Server is missing binaries for mysqloo!") + if (not pcall(require, "mysqloo")) then + return setNetVar("dbError", system.IsWindows() and "Server is missing VC++ redistributables! " or "Server is missing binaries for mysqloo! ") end - if (mysqloo.VERSION != "9" or !mysqloo.MINOR_VERSION or tonumber(mysqloo.MINOR_VERSION) < 1) then + if (mysqloo.VERSION ~= "9" or not mysqloo.MINOR_VERSION or tonumber(mysqloo.MINOR_VERSION) < 1) then MsgC(Color(255, 0, 0), "You are using an outdated mysqloo version\n") MsgC(Color(255, 0, 0), "Download the latest mysqloo9 from here\n") MsgC(Color(86, 156, 214), "https://github.com/syl0r/MySQLOO/releases") @@ -335,7 +335,7 @@ function nut.db.connect(callback, reconnect) nut.db.escape = dbModule.escape nut.db.query = dbModule.query else - ErrorNoHalt("[NutScript] '"..(nut.db.module or "nil").."' is not a valid data storage method!\n") + ErrorNoHalt("[NutScript] '"..(nut.db.module or "nil").."' is not a valid data storage method! \n") end end @@ -497,7 +497,7 @@ end local resetCalled = 0 concommand.Add("nut_recreatedb", function(client) -- this command can be run in RCON or SERVER CONSOLE - if (!IsValid(client)) then + if (not IsValid(client)) then if (resetCalled < RealTime()) then resetCalled = RealTime() + 3 diff --git a/gamemode/core/libs/sv_networking.lua b/gamemode/core/libs/sv_networking.lua index 530f1730..343fce82 100644 --- a/gamemode/core/libs/sv_networking.lua +++ b/gamemode/core/libs/sv_networking.lua @@ -57,7 +57,7 @@ function entityMeta:setNetVar(key, value, receiver) nut.net[self] = nut.net[self] or {} - if (nut.net[self][key] != value) then + if (nut.net[self][key] ~= value) then nut.net[self][key] = value end @@ -65,7 +65,7 @@ function entityMeta:setNetVar(key, value, receiver) end function entityMeta:getNetVar(key, default) - if (nut.net[self] and nut.net[self][key] != nil) then + if (nut.net[self] and nut.net[self][key] ~= nil) then return nut.net[self][key] end @@ -86,7 +86,7 @@ playerMeta.getLocalVar = entityMeta.getNetVar function getNetVar(key, default) local value = nut.net.globals[key] - return value != nil and value or default + return value ~= nil and value or default end hook.Add("EntityRemoved", "nCleanUp", function(entity) diff --git a/gamemode/core/libs/thirdparty/cl_ikon.lua b/gamemode/core/libs/thirdparty/cl_ikon.lua index ecf35475..1e560f7a 100644 --- a/gamemode/core/libs/thirdparty/cl_ikon.lua +++ b/gamemode/core/libs/thirdparty/cl_ikon.lua @@ -66,7 +66,7 @@ function ikon:init() */ OLD_HALOADD = OLD_HALOADD or halo.Add function halo.Add(...) - if (ikon.rendering != true) then + if (ikon.rendering ~= true) then OLD_HALOADD(...) end end @@ -74,7 +74,7 @@ function ikon:init() OLD_HALORENDER = OLD_HALORENDER or halo.Render function halo.Render(...) - if (ikon.rendering != true) then + if (ikon.rendering ~= true) then OLD_HALORENDER(...) end end diff --git a/gamemode/core/libs/thirdparty/sh_netstream2.lua b/gamemode/core/libs/thirdparty/sh_netstream2.lua index 086ea01d..8fb6a1ff 100644 --- a/gamemode/core/libs/thirdparty/sh_netstream2.lua +++ b/gamemode/core/libs/thirdparty/sh_netstream2.lua @@ -56,7 +56,7 @@ if (SERVER) then local bShouldSend = false; local bSendPVS = false; - if (type(player) != "table") then + if (type(player) ~= "table") then if (!player) then player = _player.GetAll(); elseif (type(player) == "Vector") then @@ -66,7 +66,7 @@ if (SERVER) then end; end; - if (type(player) != "Vector") then + if (type(player) ~= "Vector") then for k, v in pairs(player) do if (type(v) == "Player") then recipients[#recipients + 1] = v; diff --git a/gamemode/core/meta/sh_character.lua b/gamemode/core/meta/sh_character.lua index e383c7cf..05b204c5 100644 --- a/gamemode/core/meta/sh_character.lua +++ b/gamemode/core/meta/sh_character.lua @@ -33,7 +33,7 @@ if (SERVER) then -- Save all the character variables. for k, v in pairs(nut.char.vars) do - if (v.field and self.vars[k] != nil) then + if (v.field and self.vars[k] ~= nil) then data[v.field] = self.vars[k] end end @@ -41,7 +41,7 @@ if (SERVER) then -- Let plugins/schema determine if the character should be saved. local shouldSave = hook.Run("CharacterPreSave", self) - if (shouldSave != false) then + if (shouldSave ~= false) then -- Run a query to save the character to the database. nut.db.updateTable(data, function() if (callback) then @@ -65,7 +65,7 @@ if (SERVER) then local data = {} for k, v in pairs(self.vars) do - if (nut.char.vars[k] != nil and !nut.char.vars[k].noNetworking) then + if (nut.char.vars[k] ~= nil and !nut.char.vars[k].noNetworking) then data[k] = v end end @@ -103,7 +103,7 @@ if (SERVER) then if (IsValid(client)) then -- Set the faction, model, and character index for the player. - client:SetModel(self:getModel()) + client:SetModel(isstring(self:getModel()) and self:getModel() or self:getModel()[1]) client:SetTeam(self:getFaction()) client:setNetVar("char", self:getID()) @@ -267,7 +267,7 @@ function nut.char.registerVar(key, data) CHAR["get"..upperName] = function(self, default) local value = self.vars[key] - if (value != nil) then + if (value ~= nil) then return value end diff --git a/gamemode/core/meta/sh_item.lua b/gamemode/core/meta/sh_item.lua index 11fb7044..ffe77d51 100644 --- a/gamemode/core/meta/sh_item.lua +++ b/gamemode/core/meta/sh_item.lua @@ -105,7 +105,7 @@ function ITEM:getData(key, default) -- Try to get the data stored in the item. local value = self.data[key] - if (value != nil) then return value end + if (value ~= nil) then return value end -- If that didn't work, back up to getting the data from its entity. if (IsValid(self.entity)) then diff --git a/gamemode/core/sh_config.lua b/gamemode/core/sh_config.lua index 4d6b65aa..6d725bd2 100644 --- a/gamemode/core/sh_config.lua +++ b/gamemode/core/sh_config.lua @@ -53,12 +53,12 @@ function nut.config.get(key, default) local config = nut.config.stored[key] if (config) then - if (config.value != nil) then + if (config.value ~= nil) then if istable(config.value) and config.value.r and config.value.g and config.value.b then -- if the value is a table with rgb values config.value = Color(config.value.r, config.value.g, config.value.b) -- convert it to a Color table end return config.value - elseif (config.default != nil) then + elseif (config.default ~= nil) then return config.default end end @@ -94,7 +94,7 @@ if (SERVER) then local data = {} for k, v in pairs(nut.config.stored) do - if (v.default != v.value) then + if (v.default ~= v.value) then data[k] = v.value end end @@ -124,7 +124,7 @@ if (SERVER) then end netstream.Hook("cfgSet", function(client, key, value) - if (client:IsSuperAdmin() and type(nut.config.stored[key].default) == type(value) and hook.Run("CanPlayerModifyConfig", client, key) != false) then + if (client:IsSuperAdmin() and type(nut.config.stored[key].default) == type(value) and hook.Run("CanPlayerModifyConfig", client, key) ~= false) then nut.config.set(key, value) if (type(value) == "table") then @@ -182,7 +182,7 @@ end if (CLIENT) then hook.Add("CreateMenuButtons", "nutConfig", function(tabs) - if (LocalPlayer():IsSuperAdmin() and hook.Run("CanPlayerUseConfig", LocalPlayer()) != false) then + if (LocalPlayer():IsSuperAdmin() and hook.Run("CanPlayerUseConfig", LocalPlayer()) ~= false) then tabs["config"] = function(panel) local scroll = panel:Add("DScrollPanel") scroll:Dock(FILL) diff --git a/gamemode/core/sv_data.lua b/gamemode/core/sv_data.lua index b5870c34..6bcb1a19 100644 --- a/gamemode/core/sv_data.lua +++ b/gamemode/core/sv_data.lua @@ -34,7 +34,7 @@ function nut.data.get(key, default, global, ignoreMap, refresh) if (!refresh) then local stored = nut.data.stored[key] - if (stored != nil) then + if (stored ~= nil) then return stored end end @@ -47,7 +47,7 @@ function nut.data.get(key, default, global, ignoreMap, refresh) -- Read the data from a local file. local contents = file.Read(path..key..".txt", "DATA") - if (contents and contents != "") then + if (contents and contents ~= "") then -- Decode the contents and return the data. local status, decoded = pcall(pon.decode, contents) @@ -55,7 +55,7 @@ function nut.data.get(key, default, global, ignoreMap, refresh) local value = decoded[1] nut.data.stored[key] = value - if (value != nil) then + if (value ~= nil) then return value else return default @@ -80,7 +80,7 @@ function nut.data.delete(key, global, ignoreMap) -- Read the data from a local file. local contents = file.Read(path..key..".txt", "DATA") - if (contents and contents != "") then + if (contents and contents ~= "") then file.Delete(path..key..".txt") nut.data.stored[key] = nil return true diff --git a/gamemode/core/util/cl_draw.lua b/gamemode/core/util/cl_draw.lua index e08d6ed0..3966751d 100644 --- a/gamemode/core/util/cl_draw.lua +++ b/gamemode/core/util/cl_draw.lua @@ -44,7 +44,7 @@ function nut.util.wrapText(text, width, font) end end - if (line != "") then + if (line ~= "") then lines[#lines + 1] = line end @@ -57,7 +57,7 @@ local LAST_HEIGHT = ScrH() timer.Create("nutResolutionMonitor", 1, 0, function() local scrW, scrH = ScrW(), ScrH() - if (scrW != LAST_WIDTH or scrH != LAST_HEIGHT) then + if (scrW ~= LAST_WIDTH or scrH ~= LAST_HEIGHT) then hook.Run("ScreenResolutionChanged", LAST_WIDTH, LAST_HEIGHT) LAST_WIDTH = scrW diff --git a/gamemode/core/util/sv_action.lua b/gamemode/core/util/sv_action.lua index 612a7f74..7420596c 100644 --- a/gamemode/core/util/sv_action.lua +++ b/gamemode/core/util/sv_action.lua @@ -56,7 +56,7 @@ function playerMeta:doStaredAction(entity, callback, time, onCancel, distance) ) then targetEntity = targetEntity:getNetVar("player") end - if (targetEntity != entity) then + if (targetEntity ~= entity) then timer.Remove(uniqueID) if (onCancel) then diff --git a/gamemode/items/base/sh_outfit.lua b/gamemode/items/base/sh_outfit.lua index 68c188c8..eb91b0af 100644 --- a/gamemode/items/base/sh_outfit.lua +++ b/gamemode/items/base/sh_outfit.lua @@ -53,7 +53,7 @@ function ITEM:removeOutfit(client) self:setData("equip", nil) -- Revert the model, skin, and bodygroups. - if (hook.Run("CanOutfitChangeModel", self) != false) then + if (hook.Run("CanOutfitChangeModel", self) ~= false) then character:setModel(character:getData("oldMdl", character:getModel())) character:setData("oldMdl", nil) @@ -147,7 +147,7 @@ ITEM.functions.Equip = { item:setData("equip", true) - if (hook.Run("CanOutfitChangeModel", item) != false) then + if (hook.Run("CanOutfitChangeModel", item) ~= false) then char:setData( "oldMdl", char:getData("oldMdl", item.player:GetModel()) diff --git a/gamemode/items/base/sh_pacoutfit.lua b/gamemode/items/base/sh_pacoutfit.lua index 82533a33..ee6da84d 100644 --- a/gamemode/items/base/sh_pacoutfit.lua +++ b/gamemode/items/base/sh_pacoutfit.lua @@ -96,7 +96,7 @@ ITEM.functions.Equip = { local items = char:getInv():getItems() for k, v in pairs(items) do - if (v.id != item.id) then + if (v.id ~= item.id) then if (v.pacData and v.outfitCategory == item.outfitCategory and v:getData("equip")) then item.player:notify("You're already equipping this kind of outfit") @@ -120,7 +120,7 @@ ITEM.functions.Equip = { return false end, onCanRun = function(item) - return (!IsValid(item.entity) and item:getData("equip") != true) + return (!IsValid(item.entity) and item:getData("equip") ~= true) end } diff --git a/gamemode/items/base/sh_weapons.lua b/gamemode/items/base/sh_weapons.lua index 389cd231..edc2e10b 100644 --- a/gamemode/items/base/sh_weapons.lua +++ b/gamemode/items/base/sh_weapons.lua @@ -90,7 +90,7 @@ ITEM.functions.Equip = { client.carryWeapons = client.carryWeapons or {} for k, v in pairs(items) do - if (v.id != item.id) then + if (v.id ~= item.id) then if ( v.isWeapon and client.carryWeapons[item.weaponCategory] and @@ -137,7 +137,7 @@ ITEM.functions.Equip = { return false end, onCanRun = function(item) - return (!IsValid(item.entity) and item:getData("equip") != true) + return (!IsValid(item.entity) and item:getData("equip") ~= true) end } diff --git a/gamemode/languages/sh_english.lua b/gamemode/languages/sh_english.lua index 9b3f92a0..99330dd7 100644 --- a/gamemode/languages/sh_english.lua +++ b/gamemode/languages/sh_english.lua @@ -21,7 +21,6 @@ LANGUAGE = { charCreateTip = "Fill in the fields below and press 'Finish' to create your character.", invalid = "You have provided an invalid %s", descMinLen = "Your description must be at least %d character(s).", - model = "Model", player = "Player", finish = "Finish", finishTip = "Finish creating the character.", @@ -40,7 +39,6 @@ LANGUAGE = { author = "Author", version = "Version", characters = "Characters", - business = "Business", settings = "Settings", config = "Config", chat = "Chat", @@ -49,7 +47,6 @@ LANGUAGE = { oocDelay = "You must wait %s more second(s) before using OOC again.", loocDelay = "You must wait %s more second(s) before using LOOC again.", usingChar = "You are already using this character.", - notAllowed = "Sorry, you are not allowed to do this.", itemNoExist = "Sorry, the item that you requested does not exist.", cmdNoExist = "Sorry, that command does not exist.", plyNoExist = "Sorry, a matching player could not be found.", @@ -85,7 +82,6 @@ LANGUAGE = { dSold = "You have sold this door for %s.", notOwner = "You are not the owner of this.", invalidArg = "You have provided an invalid value for argument #%s.", - invalidFaction = "The faction you provided could not be found.", flagGive = "%s has given %s '%s' flags.", flagGiveTitle = "Give Flags", flagGiveDesc = "Give the following flags to the player.", @@ -239,7 +235,6 @@ LANGUAGE = { deleteTip = "Delete this character.", moneyLeft = "Your Money: ", currentMoney = "Money Left: ", - checkout = "Checkout", -- 2018 patch diff --git a/gamemode/shared.lua b/gamemode/shared.lua index 02854a88..8ec58efd 100644 --- a/gamemode/shared.lua +++ b/gamemode/shared.lua @@ -26,21 +26,21 @@ do local model2 = model:gsub("models/", "models/player/") result = NutTranslateModel(model2) - if (result != "kleiner") then + if (result ~= "kleiner") then return result end model2 = model:gsub("models/humans", "models/player") result = NutTranslateModel(model2) - if (result != "kleiner") then + if (result ~= "kleiner") then return result end model2 = model:gsub("models/zombie/", "models/player/zombie_") result = NutTranslateModel(model2) - if (result != "kleiner") then + if (result ~= "kleiner") then return result end end diff --git a/plugins/area/sh_plugin.lua b/plugins/area/sh_plugin.lua index 88c9e763..48403922 100644 --- a/plugins/area/sh_plugin.lua +++ b/plugins/area/sh_plugin.lua @@ -64,7 +64,7 @@ if (SERVER) then for id, areaData in pairs(nut.area.getAllArea()) do local clientPos = v:GetPos() + v:OBBCenter() - if (clientPos:WithinAABox(areaData.minVector, areaData.maxVector) and area != id) then + if (clientPos:WithinAABox(areaData.minVector, areaData.maxVector) and area ~= id) then v.curArea = id hook.Run("OnPlayerAreaChanged", v, id) @@ -339,9 +339,9 @@ else scale = Lerp(ft*1, scale, targetScale) -- change event - if (maxDisplay != curChar and curChar < strEnd) then + if (maxDisplay ~= curChar and curChar < strEnd) then curChar = maxDisplay - if (string.utf8sub(dispString, curChar, curChar) != " ") then + if (string.utf8sub(dispString, curChar, curChar) ~= " ") then LocalPlayer():EmitSound(tickSound, 100, math.random(190, 200)) end end @@ -373,7 +373,7 @@ else end if (maxDisplay >= strEnd) then - if (dieTrigger != true) then + if (dieTrigger ~= true) then dieTrigger = true dieTimer = RealTime() + 2 else diff --git a/plugins/attributes/derma/cl_attribute.lua b/plugins/attributes/derma/cl_attribute.lua index bfca5843..4bcf1fc8 100644 --- a/plugins/attributes/derma/cl_attribute.lua +++ b/plugins/attributes/derma/cl_attribute.lua @@ -104,7 +104,7 @@ local PANEL = {} self.nextPress = CurTime() + 0.2 - if (self:onChanged(self.pressing) != false) then + if (self:onChanged(self.pressing) ~= false) then self.value = math.Clamp(self.value + self.pressing, 0, self.max) end end diff --git a/plugins/attributes/sh_plugin.lua b/plugins/attributes/sh_plugin.lua index b806a587..8d4781e1 100644 --- a/plugins/attributes/sh_plugin.lua +++ b/plugins/attributes/sh_plugin.lua @@ -21,7 +21,7 @@ nut.char.registerVar("attribs", { isLocal = true, index = 4, onValidate = function(value, data, client) - if (value != nil) then + if (value ~= nil) then if (istable(value)) then local count = 0 diff --git a/plugins/bars/libs/cl_bar.lua b/plugins/bars/libs/cl_bar.lua index 256f01bb..59cbfcc4 100644 --- a/plugins/bars/libs/cl_bar.lua +++ b/plugins/bars/libs/cl_bar.lua @@ -140,7 +140,7 @@ function nut.bar.drawAll() deltas[i] = value - if (deltas[i] != realValue) then + if (deltas[i] ~= realValue) then bar.lifeTime = curTime + 5 end diff --git a/plugins/business/derma/cl_business.lua b/plugins/business/derma/cl_business.lua index f08bd4f3..ce559548 100644 --- a/plugins/business/derma/cl_business.lua +++ b/plugins/business/derma/cl_business.lua @@ -153,7 +153,7 @@ function PANEL:Init() surface.DrawOutlinedRect(0, 0, w, h) end button.DoClick = function(this) - if (self.selected != this) then + if (self.selected ~= this) then self.selected = this self:loadItems(realName) timer.Simple(0.01, function() @@ -213,7 +213,7 @@ function PANEL:loadItems(category, search) end if (itemTable.category == category) then - if (search and search != "" and !L(itemTable.name):lower():find(search, 1, true)) then + if (search and search ~= "" and !L(itemTable.name):lower():find(search, 1, true)) then continue end @@ -445,7 +445,7 @@ PANEL = {} vgui.Register("nutBusinessCheckout", PANEL, "DFrame") hook.Add("CreateMenuButtons", "nutBusiness", function(tabs) - if (hook.Run("BuildBusinessMenu", panel) != false) then + if (hook.Run("BuildBusinessMenu", panel) ~= false) then tabs["business"] = function(panel) panel:Add("nutBusiness") end diff --git a/plugins/business/entities/entities/nut_shipment.lua b/plugins/business/entities/entities/nut_shipment.lua index 25f2b0ab..7bd7ce5b 100644 --- a/plugins/business/entities/entities/nut_shipment.lua +++ b/plugins/business/entities/entities/nut_shipment.lua @@ -30,7 +30,7 @@ if (SERVER) then end function ENT:Use(activator) - if (activator:getChar() and activator:getChar():getID() == self:getNetVar("owner", 0) and hook.Run("PlayerCanOpenShipment", activator, self) != false) then + if (activator:getChar() and activator:getChar():getID() == self:getNetVar("owner", 0) and hook.Run("PlayerCanOpenShipment", activator, self) ~= false) then activator.nutShipment = self netstream.Start(activator, "openShp", self, self.items) end diff --git a/plugins/chatbox/sh_plugin.lua b/plugins/chatbox/sh_plugin.lua index 2183f179..78051be5 100644 --- a/plugins/chatbox/sh_plugin.lua +++ b/plugins/chatbox/sh_plugin.lua @@ -53,7 +53,7 @@ if (CLIENT) then function PLUGIN:ChatText(index, name, text, messageType) if (messageType == "none" and IsValid(self.panel)) then self.panel:addText(text) - if (SOUND_CUSTOM_CHAT_SOUND and SOUND_CUSTOM_CHAT_SOUND != "") then + if (SOUND_CUSTOM_CHAT_SOUND and SOUND_CUSTOM_CHAT_SOUND ~= "") then surface.PlaySound(SOUND_CUSTOM_CHAT_SOUND) else chat.PlaySound() diff --git a/plugins/crosshair.lua b/plugins/crosshair.lua index 618b6f5c..6f00e35b 100644 --- a/plugins/crosshair.lua +++ b/plugins/crosshair.lua @@ -97,7 +97,7 @@ function PLUGIN:PostDrawHUD() end if (icon) then - if (icon != lastIcon) then + if (icon ~= lastIcon) then lastIcon = icon end diff --git a/plugins/deathscreen.lua b/plugins/deathscreen.lua index be42f88f..d93c6426 100644 --- a/plugins/deathscreen.lua +++ b/plugins/deathscreen.lua @@ -15,14 +15,14 @@ if (CLIENT) then if (owner:getChar()) then if (owner:Alive()) then - if (aprg != 0) then + if (aprg ~= 0) then aprg2 = clmp(aprg2 - ft*1.3, 0, 1) if (aprg2 == 0) then aprg = clmp(aprg - ft*.7, 0, 1) end end else - if (aprg2 != 1) then + if (aprg2 ~= 1) then aprg = clmp(aprg + ft*.5, 0, 1) if (aprg == 1) then aprg2 = clmp(aprg2 + ft*.4, 0, 1) diff --git a/plugins/doors/cl_plugin.lua b/plugins/doors/cl_plugin.lua index 84a3eaba..d11f47b2 100644 --- a/plugins/doors/cl_plugin.lua +++ b/plugins/doors/cl_plugin.lua @@ -17,7 +17,7 @@ local configGet = nut.config.get local teamGetColor = team.GetColor function PLUGIN:DrawEntityInfo(entity, alpha) - if (entity.isDoor(entity) and !entity:getNetVar("hidden") and hook.Run("CanDrawDoorInfo") != false) then + if (entity.isDoor(entity) and !entity:getNetVar("hidden") and hook.Run("CanDrawDoorInfo") ~= false) then local position = toScreen(entity.LocalToWorld(entity, entity.OBBCenter(entity))) local x, y = position.x, position.y local owner = entity.GetDTEntity(entity, 0) diff --git a/plugins/doors/derma/cl_door.lua b/plugins/doors/derma/cl_door.lua index af1a04ee..0dbb8242 100644 --- a/plugins/doors/derma/cl_door.lua +++ b/plugins/doors/derma/cl_door.lua @@ -13,17 +13,17 @@ local PANEL = {} if (IsValid(line.player)) then local menu = DermaMenu() menu:AddOption(L"tenant", function() - if (self.accessData and self.accessData[line.player] != DOOR_TENANT) then + if (self.accessData and self.accessData[line.player] ~= DOOR_TENANT) then netstream.Start("doorPerm", self.door, line.player, DOOR_TENANT) end end):SetImage("icon16/user_add.png") menu:AddOption(L"guest", function() - if (self.accessData and self.accessData[line.player] != DOOR_GUEST) then + if (self.accessData and self.accessData[line.player] ~= DOOR_GUEST) then netstream.Start("doorPerm", self.door, line.player, DOOR_GUEST) end end):SetImage("icon16/user_green.png") menu:AddOption(L"none", function() - if (self.accessData and self.accessData[line.player] != DOOR_NONE) then + if (self.accessData and self.accessData[line.player] ~= DOOR_NONE) then netstream.Start("doorPerm", self.door, line.player, DOOR_NONE) end end):SetImage("icon16/user_red.png") @@ -39,7 +39,7 @@ local PANEL = {} self.door = door for k, v in ipairs(player.GetAll()) do - if (v != LocalPlayer() and v:getChar()) then + if (v ~= LocalPlayer() and v:getChar()) then self.access:AddLine( v:Name():gsub("#", "\226\128\139#"), L(ACCESS_LABELS[access[v] or 0]) diff --git a/plugins/doors/sv_plugin.lua b/plugins/doors/sv_plugin.lua index 28b0a2ff..42a3107b 100644 --- a/plugins/doors/sv_plugin.lua +++ b/plugins/doors/sv_plugin.lua @@ -60,7 +60,7 @@ function PLUGIN:copyParentDoor(child) for k, v in ipairs(variables) do local value = parent:getNetVar(v) - if (child:getNetVar(v) != value) then + if (child:getNetVar(v) ~= value) then child:setNetVar(v, value) end end @@ -185,11 +185,11 @@ function PLUGIN:CanPlayerAccessDoor(client, door, access) if (class and classData and classData2) then if (classData.team) then - if (classData.team != classData2.team) then + if (classData.team ~= classData2.team) then return false end else - if (charClass != class) then + if (charClass ~= class) then return false end end @@ -242,7 +242,7 @@ function PLUGIN:PlayerDisconnected(client) end netstream.Hook("doorPerm", function(client, door, target, access) - if (IsValid(target) and target:getChar() and door.nutAccess and door:GetDTEntity(0) == client and target != client) then + if (IsValid(target) and target:getChar() and door.nutAccess and door:GetDTEntity(0) == client and target ~= client) then access = math.Clamp(access or 0, DOOR_NONE, DOOR_TENANT) if (access == door.nutAccess[target]) then diff --git a/plugins/gridinv/plugins/gridinvui/derma/cl_grid_inventory_panel.lua b/plugins/gridinv/plugins/gridinvui/derma/cl_grid_inventory_panel.lua index 481b5dd5..3b5d8d53 100644 --- a/plugins/gridinv/plugins/gridinvui/derma/cl_grid_inventory_panel.lua +++ b/plugins/gridinv/plugins/gridinvui/derma/cl_grid_inventory_panel.lua @@ -62,7 +62,7 @@ function PANEL:removeIcon(icon) end function PANEL:onItemPressed(itemIcon, keyCode) - if (hook.Run("InterceptClickItemIcon", self, itemIcon, keyCode) != true) then + if (hook.Run("InterceptClickItemIcon", self, itemIcon, keyCode) ~= true) then if (keyCode == MOUSE_RIGHT) then itemIcon:openActionMenu() elseif (keyCode == MOUSE_LEFT) then diff --git a/plugins/gridinv/sh_grid_inv.lua b/plugins/gridinv/sh_grid_inv.lua index 31607d6c..69440480 100644 --- a/plugins/gridinv/sh_grid_inv.lua +++ b/plugins/gridinv/sh_grid_inv.lua @@ -214,7 +214,7 @@ if (SERVER) then end end - if (isStackCommand and item.isStackable != true) then + if (isStackCommand and item.isStackable ~= true) then isStackCommand = false end diff --git a/plugins/nshud/sh_plugin.lua b/plugins/nshud/sh_plugin.lua index cbc8aa88..8548a2ca 100644 --- a/plugins/nshud/sh_plugin.lua +++ b/plugins/nshud/sh_plugin.lua @@ -158,7 +158,7 @@ function PLUGIN:ShouldDrawEntityInfo(entity) if (entity.onShouldDrawEntityInfo) then return entity:onShouldDrawEntityInfo() end - if (entity:IsPlayer() and entity:getChar() and entity:GetNoDraw() != true) then + if (entity:IsPlayer() and entity:getChar() and entity:GetNoDraw() ~= true) then return true end end @@ -202,7 +202,7 @@ function PLUGIN:HUDPaintBackground() frameTime * 1000 ) - if (lastEntity != entity) then + if (lastEntity ~= entity) then paintedEntitiesCache[entity] = false end diff --git a/plugins/nsintro/sh_plugin.lua b/plugins/nsintro/sh_plugin.lua index fe34b49c..dcf45046 100644 --- a/plugins/nsintro/sh_plugin.lua +++ b/plugins/nsintro/sh_plugin.lua @@ -7,7 +7,7 @@ nut.config.add("introEnabled", true, "Whether or not intro is enabled.", nil, { category = PLUGIN.name }) -nut.config.add("playIntroOnlyOnce", true, "Whether the intro, if enabled, should play every time, or only on first join", nil, { +nut.config.add("alwaysPlayIntro", false, "Whether the intro, if enabled, should play every time, or only on first join", nil, { category = PLUGIN.name }) diff --git a/plugins/persistence.lua b/plugins/persistence.lua index 6ed006b9..7db70f4d 100644 --- a/plugins/persistence.lua +++ b/plugins/persistence.lua @@ -30,9 +30,9 @@ properties.Add( "persist", { if ( ent:IsPlayer() ) then return false end if ( PLUGIN.blacklist[ent:GetClass()] ) then return false end - if ( !gamemode.Call( "CanProperty", ply, "persist", ent ) ) then return false end + if ( not gamemode.Call( "CanProperty", ply, "persist", ent ) ) then return false end - return !ent:getNetVar( "persistent", false ) + return not ent:getNetVar( "persistent", false ) end, @@ -47,14 +47,14 @@ properties.Add( "persist", { Receive = function( self, length, ply ) local ent = net.ReadEntity() - if ( !IsValid( ent ) ) then return end - if ( !self:Filter( ent, ply ) ) then return end + if ( not IsValid( ent ) ) then return end + if ( not self:Filter( ent, ply ) ) then return end ent:setNetVar( "persistent", true ) - + -- Register the entity PLUGIN.entities[#PLUGIN.entities + 1] = ent - + -- Add new log nut.log.add(ply, "persistedEntity", ent ) end @@ -69,7 +69,7 @@ properties.Add( "persist_end", { Filter = function( self, ent, ply ) if ( ent:IsPlayer() ) then return false end - if ( !gamemode.Call( "CanProperty", ply, "persist", ent ) ) then return false end + if ( not gamemode.Call( "CanProperty", ply, "persist", ent ) ) then return false end return ent:getNetVar( "persistent", false ) @@ -86,10 +86,9 @@ properties.Add( "persist_end", { Receive = function( self, length, ply ) local ent = net.ReadEntity() - if ( !IsValid( ent ) ) then return end - if ( !properties.CanBeTargeted( ent, ply ) ) then return end - if ( !self:Filter( ent, ply ) ) then return end - + if ( not IsValid( ent ) ) then return end + if ( not properties.CanBeTargeted( ent, ply ) ) then return end + if ( not self:Filter( ent, ply ) ) then return end ent:setNetVar( "persistent", false ) -- Remove entity from registration diff --git a/plugins/recognition.lua b/plugins/recognition.lua index 3c97bd29..a4077c68 100644 --- a/plugins/recognition.lua +++ b/plugins/recognition.lua @@ -7,13 +7,13 @@ do if (SERVER) then function character:recognize(id) - if (type(id) != "number" and id.getID) then + if (type(id) ~= "number" and id.getID) then id = id:getID() end local recognized = self:getData("rgn", "") - if (recognized != "" and recognized:find(","..id..",")) then + if (recognized ~= "" and recognized:find(","..id..",")) then return false; end; @@ -24,11 +24,11 @@ do end function character:doesRecognize(id) - if (type(id) != "number" and id.getID) then + if (type(id) ~= "number" and id.getID) then id = id:getID() end - return hook.Run("IsCharRecognized", self, id) != false + return hook.Run("IsCharRecognized", self, id) ~= false end function PLUGIN:IsCharRecognized(char, id) @@ -66,7 +66,7 @@ if (CLIENT) then end function PLUGIN:GetDisplayedDescription(client) - if (client:getChar() and client != LocalPlayer() and LocalPlayer():getChar() and !LocalPlayer():getChar():doesRecognize(client:getChar()) and !hook.Run("IsPlayerRecognized", client)) then + if (client:getChar() and client ~= LocalPlayer() and LocalPlayer():getChar() and !LocalPlayer():getChar():doesRecognize(client:getChar()) and !hook.Run("IsPlayerRecognized", client)) then return L"noRecog" end end @@ -78,7 +78,7 @@ if (CLIENT) then end function PLUGIN:GetDisplayedName(client, chatType) - if (client != LocalPlayer()) then + if (client ~= LocalPlayer()) then local character = client:getChar() local ourCharacter = LocalPlayer():getChar() @@ -176,7 +176,7 @@ else class = nut.chat.classes[class] for k, v in ipairs(player.GetAll()) do - if (client != v and v:getChar() and class.onCanHear(client, v)) then + if (client ~= v and v:getChar() and class.onCanHear(client, v)) then targets[#targets + 1] = v end end diff --git a/plugins/scoreboard/derma/cl_scoreboard.lua b/plugins/scoreboard/derma/cl_scoreboard.lua index 4a61b060..047ea64f 100644 --- a/plugins/scoreboard/derma/cl_scoreboard.lua +++ b/plugins/scoreboard/derma/cl_scoreboard.lua @@ -52,7 +52,7 @@ local PANEL = {} list:SetTall(28) list.Think = function(this) for k2, v2 in ipairs(team.GetPlayers(k)) do - if (!IsValid(v2.nutScoreSlot) or v2.nutScoreSlot:GetParent() != this) then + if (!IsValid(v2.nutScoreSlot) or v2.nutScoreSlot:GetParent() ~= this) then if (IsValid(v2.nutPlayerSlot)) then v2.nutPlayerSlot:SetParent(this) else @@ -192,13 +192,13 @@ local PANEL = {} local oldTeam = client:Team() function slot:update() - if (!IsValid(client) or !client:getChar() or !self.character or self.character != client:getChar() or oldTeam != client:Team()) then + if (!IsValid(client) or !client:getChar() or !self.character or self.character ~= client:getChar() or oldTeam ~= client:Team()) then self:Remove() local i = 0 for k, v in ipairs(parent:GetChildren()) do - if (IsValid(v.model) and v != self) then + if (IsValid(v.model) and v ~= self) then i = i + 1 v.Paint = paintFunctions[i % 2] end @@ -218,14 +218,14 @@ local PANEL = {} self.model:setHidden(overrideName) - if (self.lastName != name) then + if (self.lastName ~= name) then self.name:SetText(name) self.lastName = name end local entity = self.model.Entity - if (self.lastDesc != desc) then + if (self.lastDesc ~= desc) then self.desc:SetText(desc) self.lastDesc = desc end @@ -234,7 +234,7 @@ local PANEL = {} return end - if (self.lastModel != model or self.lastSkin != skin) then + if (self.lastModel ~= model or self.lastSkin ~= skin) then self.model:SetModel(client:GetModel(), client:GetSkin()) self.model:SetTooltip(L("sbOptions", client:steamName())) diff --git a/plugins/spawns.lua b/plugins/spawns.lua index dfed9b32..233d4a15 100644 --- a/plugins/spawns.lua +++ b/plugins/spawns.lua @@ -72,7 +72,7 @@ nut.command.add("spawnadd", { end if (info) then - if (class and class != "") then + if (class and class ~= "") then local found = false for k, v in ipairs(nut.class.list) do diff --git a/plugins/stamina/sh_plugin.lua b/plugins/stamina/sh_plugin.lua index c9bfa6a5..ec89b7cc 100644 --- a/plugins/stamina/sh_plugin.lua +++ b/plugins/stamina/sh_plugin.lua @@ -47,7 +47,7 @@ if (SERVER) then local current = client:getLocalVar("stm", 0) local value = math.Clamp(current + offset, 0, 100) - if (current != value) then + if (current ~= value) then client:setLocalVar("stm", value) if (value == 0 and !client:getNetVar("brth", false)) then diff --git a/plugins/storage/sh_plugin.lua b/plugins/storage/sh_plugin.lua index 86e35494..16366618 100644 --- a/plugins/storage/sh_plugin.lua +++ b/plugins/storage/sh_plugin.lua @@ -38,7 +38,7 @@ nut.command.add("storagelock", { if (ent and ent:IsValid()) then local password = table.concat(arguments, " ") - if (password != "") then + if (password ~= "") then ent:setNetVar("locked", true) ent.password = password client:notifyLocalized("storPass", password) diff --git a/plugins/vendor/entities/entities/nut_vendor/shared.lua b/plugins/vendor/entities/entities/nut_vendor/shared.lua index 032d0498..1a1a5164 100644 --- a/plugins/vendor/entities/entities/nut_vendor/shared.lua +++ b/plugins/vendor/entities/entities/nut_vendor/shared.lua @@ -152,7 +152,7 @@ end function ENT:setAnim() for k, v in ipairs(self:GetSequenceList()) do - if (v:lower():find("idle") and v != "idlenoise") then + if (v:lower():find("idle") and v ~= "idlenoise") then return self:ResetSequence(k) end end diff --git a/plugins/vignette.lua b/plugins/vignette.lua index a8a0a653..20269be6 100644 --- a/plugins/vignette.lua +++ b/plugins/vignette.lua @@ -11,7 +11,7 @@ if (SERVER) then return end local vignette = nut.util.getMaterial("nutscript/gui/vignette.png") local vignetteAlphaGoal = 0 local vignetteAlphaDelta = 0 -local hasVignetteMaterial = vignette != "___error" +local hasVignetteMaterial = vignette ~= "___error" local mathApproach = math.Approach timer.Create("nutVignetteChecker", 1, 0, function() From 217599e1de91ca7e2441b981fd38eae298a4536c Mon Sep 17 00:00:00 2001 From: VindoesCompooter <100soundsystem32@gmail.com> Date: Sat, 20 Mar 2021 08:51:39 +0000 Subject: [PATCH 28/56] Added Hook CanDrawDoorInfo gets parsed the entity so that it can be done in specific circumstances --- plugins/doors/cl_plugin.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/doors/cl_plugin.lua b/plugins/doors/cl_plugin.lua index d11f47b2..75ae8be9 100644 --- a/plugins/doors/cl_plugin.lua +++ b/plugins/doors/cl_plugin.lua @@ -17,7 +17,7 @@ local configGet = nut.config.get local teamGetColor = team.GetColor function PLUGIN:DrawEntityInfo(entity, alpha) - if (entity.isDoor(entity) and !entity:getNetVar("hidden") and hook.Run("CanDrawDoorInfo") ~= false) then + if (entity.isDoor(entity) and !entity:getNetVar("hidden") and hook.Run("CanDrawDoorInfo",entity) ~= false) then local position = toScreen(entity.LocalToWorld(entity, entity.OBBCenter(entity))) local x, y = position.x, position.y local owner = entity.GetDTEntity(entity, 0) @@ -35,7 +35,7 @@ function PLUGIN:DrawEntityInfo(entity, alpha) local classData if (class) then classData = nut.class.list[class] - + if (classData) then color = classData.color else From 198ce0cf06c4453df413f3d70f18803a3c5e57d1 Mon Sep 17 00:00:00 2001 From: Zoephix Date: Sat, 20 Mar 2021 09:53:17 +0100 Subject: [PATCH 29/56] Update chatsizediff.lua --- plugins/chatsizediff.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/chatsizediff.lua b/plugins/chatsizediff.lua index d5f1778a..9599797d 100644 --- a/plugins/chatsizediff.lua +++ b/plugins/chatsizediff.lua @@ -2,7 +2,7 @@ PLUGIN.name = "Chat Size Difference" PLUGIN.desc = "Overrides size for different chat types." PLUGIN.author = "Zoephix" -nut.config.add("chatSizeDiff", true, "Whether or not to use different chat sizes.", nil, { +nut.config.add("chatSizeDiff", false, "Whether or not to use different chat sizes.", nil, { category = "chat" }) From 31769a3e20e131f1b6b3c19de7018ae76f1fdac6 Mon Sep 17 00:00:00 2001 From: Zoephix Date: Sat, 20 Mar 2021 10:00:10 +0100 Subject: [PATCH 30/56] Update cl_plugin.lua --- plugins/doors/cl_plugin.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/doors/cl_plugin.lua b/plugins/doors/cl_plugin.lua index 75ae8be9..0476e846 100644 --- a/plugins/doors/cl_plugin.lua +++ b/plugins/doors/cl_plugin.lua @@ -17,7 +17,7 @@ local configGet = nut.config.get local teamGetColor = team.GetColor function PLUGIN:DrawEntityInfo(entity, alpha) - if (entity.isDoor(entity) and !entity:getNetVar("hidden") and hook.Run("CanDrawDoorInfo",entity) ~= false) then + if (entity.isDoor(entity) and !entity:getNetVar("hidden") and hook.Run("CanDrawDoorInfo", entity)) then local position = toScreen(entity.LocalToWorld(entity, entity.OBBCenter(entity))) local x, y = position.x, position.y local owner = entity.GetDTEntity(entity, 0) @@ -90,4 +90,4 @@ netstream.Hook("doorPerm", function(door, client, access) end end end -end) \ No newline at end of file +end) From 4187b71204071d82c291502dfd6910ecb03aa26e Mon Sep 17 00:00:00 2001 From: TovarischPootis <54110479+TovarischPootis@users.noreply.github.com> Date: Sat, 20 Mar 2021 11:10:48 +0200 Subject: [PATCH 31/56] Fix Item Descs Fixes to items to display proper updated descriptions, rather than the default meta desc (stuff like getData in getDesc works properly now) --- entities/entities/nut_item.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/entities/entities/nut_item.lua b/entities/entities/nut_item.lua index a8760f6a..224e85be 100644 --- a/entities/entities/nut_item.lua +++ b/entities/entities/nut_item.lua @@ -57,6 +57,7 @@ if (SERVER) then self:PhysicsInit(SOLID_VPHYSICS) self:SetSolid(SOLID_VPHYSICS) self:setNetVar("id", itemTable.uniqueID) + self:setNetVar("instanceID", itemTable:getID()) self.nutItemID = itemID if (table.Count(itemTable.data) > 0) then @@ -192,11 +193,11 @@ else end function ENT:getItemID() - return self:getNetVar("id", "") + return self:getNetVar("instanceID", "") end function ENT:getItemTable() - return nut.item.list[self:getItemID()] + return nut.item.instances[self:getItemID()] end function ENT:getData(key, default) From 365c8aab9f32bf3f7a05155424ce8398911209d8 Mon Sep 17 00:00:00 2001 From: TovarischPootis <54110479+TovarischPootis@users.noreply.github.com> Date: Sat, 20 Mar 2021 11:11:49 +0200 Subject: [PATCH 32/56] Deprication/whitespaces/consistency --- gamemode/core/derma/cl_inventory.lua | 4 +- gamemode/core/libs/sh_character.lua | 16 ++--- gamemode/core/libs/sh_item.lua | 10 ++-- gamemode/core/libs/sv_database.lua | 4 +- gamemode/core/libs/thirdparty/sh_ease.lua | 71 +++++++++++------------ gamemode/core/meta/sh_character.lua | 12 ++-- plugins/doors/sh_commands.lua | 4 +- plugins/raiseweapons/cl_hooks.lua | 6 +- plugins/vignette.lua | 2 +- 9 files changed, 63 insertions(+), 66 deletions(-) diff --git a/gamemode/core/derma/cl_inventory.lua b/gamemode/core/derma/cl_inventory.lua index 20be1b44..9d1ad015 100644 --- a/gamemode/core/derma/cl_inventory.lua +++ b/gamemode/core/derma/cl_inventory.lua @@ -6,7 +6,7 @@ renderedIcons = renderedIcons or {} -- To make making inventory variant, This must be followed up. function renderNewIcon(panel, itemTable) -- re-render icons - if ((itemTable.iconCam and !renderedIcons[string.lower(itemTable.model)]) or itemTable.forceRender) then + if ((itemTable.iconCam and not renderedIcons[string.lower(itemTable.model)]) or itemTable.forceRender) then local iconCam = itemTable.iconCam iconCam = { cam_pos = iconCam.pos, @@ -14,7 +14,7 @@ function renderNewIcon(panel, itemTable) cam_fov = iconCam.fov, } renderedIcons[string.lower(itemTable.model)] = true - + panel.Icon:RebuildSpawnIconEx( iconCam ) diff --git a/gamemode/core/libs/sh_character.lua b/gamemode/core/libs/sh_character.lua index bff30dd9..8338bd0d 100644 --- a/gamemode/core/libs/sh_character.lua +++ b/gamemode/core/libs/sh_character.lua @@ -105,7 +105,7 @@ do local allowExistNames = nut.config.get("allowExistNames", true) -- Fetch existing character names - if (CLIENT and #nut.char.names < 1 and !allowExistNames) then + if (CLIENT and #nut.char.names < 1 and not allowExistNames) then netstream.Start("nutCharFetchNames") netstream.Hook("nutCharFetchNames", function(data) @@ -114,7 +114,7 @@ do end -- Check whether the chosen character name already exists - if (!nut.config.get("allowExistNames", true)) then + if (not nut.config.get("allowExistNames", true)) then for k, v in pairs(nut.char.names) do if (v == value) then return false, "A character with this name already exists." @@ -161,7 +161,7 @@ do local minLength = nut.config.get("minDescLen", 16) - if (!value or #value:gsub("%s", "") < minLength) then + if (not value or #value:gsub("%s", "") < minLength) then return false, "descMinLen", minLength end end @@ -244,7 +244,7 @@ do local faction = nut.faction.indices[data.faction] if (faction) then - if (!data.model or !faction.models[data.model]) then + if (not data.model or not faction.models[data.model]) then return false, "needModel" end else @@ -337,7 +337,7 @@ do data[key] = value - if (!noReplication and IsValid(client)) then + if (not noReplication and IsValid(client)) then netstream.Start( receiver or client, "charData", @@ -352,7 +352,7 @@ do local data = character.vars.data or {} if (key) then - if (!data) then + if (not data) then return default end @@ -374,7 +374,7 @@ do data[key] = value - if (!noReplication and IsValid(client)) then + if (not noReplication and IsValid(client)) then local id if ( @@ -396,7 +396,7 @@ do local data = character.vars.vars or {} if (key) then - if (!data) then + if (not data) then return default end diff --git a/gamemode/core/libs/sh_item.lua b/gamemode/core/libs/sh_item.lua index 9904f2cb..e88616a1 100644 --- a/gamemode/core/libs/sh_item.lua +++ b/gamemode/core/libs/sh_item.lua @@ -19,7 +19,7 @@ function nut.item.load(path, baseID, isBaseItem) if (uniqueID) then uniqueID = (isBaseItem and "base_" or "")..uniqueID nut.item.register(uniqueID, baseID, isBaseItem, path) - elseif (!path:find(".txt")) then + elseif (not path:find(".txt")) then ErrorNoHalt( "[NutScript] Item at '"..path.."' follows invalid ".. "naming convention!\n" @@ -102,23 +102,23 @@ function nut.item.loadFromDir(directory) files = file.Find(directory.."/base/*.lua", "LUA") - for k, v in ipairs(files) do + for _, v in ipairs(files) do nut.item.load(directory.."/base/"..v, nil, true) end files, folders = file.Find(directory.."/*", "LUA") - for k, v in ipairs(folders) do + for _, v in ipairs(folders) do if (v == "base") then continue end - for k2, v2 in ipairs(file.Find(directory.."/"..v.."/*.lua", "LUA")) do + for _, v2 in ipairs(file.Find(directory.."/"..v.."/*.lua", "LUA")) do nut.item.load(directory.."/"..v .. "/".. v2, "base_"..v) end end - for k, v in ipairs(files) do + for _, v in ipairs(files) do nut.item.load(directory.."/"..v) end end diff --git a/gamemode/core/libs/sv_database.lua b/gamemode/core/libs/sv_database.lua index 14ffb632..1e374b42 100644 --- a/gamemode/core/libs/sv_database.lua +++ b/gamemode/core/libs/sv_database.lua @@ -72,7 +72,7 @@ modules.tmysql4 = { if (result) then result = result[1] - local queryStatus, queryError, affected, lastID, time, data = result.status, result.error, result.affected, result.lastid, result.time, result.data + local queryStatus, queryError, affected, lastID, time, data = result.status, result.error, result.affected, result.lastid, result.time, result.data if (queryStatus and queryStatus == true and callback) then callback(data, lastID) @@ -116,7 +116,7 @@ modules.tmysql4 = { end else ThrowConnectionFault(fault) - end + end end } diff --git a/gamemode/core/libs/thirdparty/sh_ease.lua b/gamemode/core/libs/thirdparty/sh_ease.lua index e7bd680e..0f94db17 100644 --- a/gamemode/core/libs/thirdparty/sh_ease.lua +++ b/gamemode/core/libs/thirdparty/sh_ease.lua @@ -3,7 +3,7 @@ -- check the ease cheatsheet for your neat UI and stuffs! http://easings.net nut.ease = nut.ease or {} - + local pow = math.pow local sin = math.sin local pi = math.pi @@ -11,76 +11,76 @@ local easeIn, easeOut, easeInOut, easeOutIn local easeInBack, easeOutBack, easeInOutBack, easeOutInBack local easeInElastic, easeOutElastic, easeInOutElastic, easeOutInElastic local easeInBounce, easeOutBounce, easeInOutBounce, easeOutInBounce - + function nut.ease.easeIn(t, tMax, start, delta) return start + (delta * easeIn(t / tMax)) end - + function nut.ease.easeOut(t, tMax, start, delta) return start + (delta * easeOut(t / tMax)) end - + function nut.ease.easeInOut(t, tMax, start, delta) return start + (delta * easeInOut(t / tMax)) end - + function nut.ease.easeOutIn(t, tMax, start, delta) return start + (delta * easeOutIn(t / tMax)) end - + function nut.ease.easeInBack(t, tMax, start, delta) return start + (delta * easeInBack(t / tMax)) end - + function nut.ease.easeOutBack(t, tMax, start, delta) return start + (delta * easeOutBack(t / tMax)) end - + function nut.ease.easeInOutBack(t, tMax, start, delta) return start + (delta * easeInOutBack(t / tMax)) end - + function nut.ease.easeOutInBack(t, tMax, start, delta) return start + (delta * easeOutInBack(t / tMax)) end - + function nut.ease.easeInElastic(t, tMax, start, delta) return start + (delta * easeInElastic(t / tMax)) end - + function nut.ease.easeOutElastic(t, tMax, start, delta) return start + (delta * easeOutElastic(t / tMax)) end - + function nut.ease.easeInOutElastic(t, tMax, start, delta) return start + (delta * easeInOutElastic(t / tMax)) end - + function nut.ease.easeOutInElastic(t, tMax, start, delta) return start + (delta * easeOutInElastic(t / tMax)) end - + function nut.ease.easeInBounce(t, tMax, start, delta) return start + (delta * easeInBounce(t / tMax)) end - + function nut.ease.easeOutBounce(t, tMax, start, delta) return start + (delta * easeOutBounce(t / tMax)) end - + function nut.ease.easeInOutBounce(t, tMax, start, delta) return start + (delta * easeInOutBounce(t / tMax)) end - + function nut.ease.easeOutInBounce(t, tMax, start, delta) return start + (delta * easeOutInBounce(t / tMax)) end - + -- local easing functions easeInBounce = function(ratio) return 1.0 - easeOutBounce(1.0 - ratio) end - + easeOutBounce = function(ratio) local s = 7.5625 local p = 2.75 @@ -103,7 +103,7 @@ easeOutBounce = function(ratio) end return l end - + easeInOutBounce = function(ratio) if (ratio < 0.5) then return 0.5 * easeInBounce(ratio * 2.0) @@ -111,7 +111,7 @@ easeInOutBounce = function(ratio) return 0.5 * easeOutBounce((ratio - 0.5) * 2.0) + 0.5 end end - + easeOutInBounce = function(ratio) if (ratio < 0.5) then return 0.5 * easeOutBounce(ratio * 2.0) @@ -119,25 +119,24 @@ easeOutInBounce = function(ratio) return 0.5 * easeInBounce((ratio - 0.5) * 2.0) + 0.5 end end - - + easeInElastic = function(ratio) if ratio == 0 or ratio == 1.0 then return ratio end - + local p = 0.3 local s = p / 4.0 local invRatio = ratio - 1.0 return -1 * pow(2.0, 10.0 * invRatio) * sin((invRatio - s) * 2 * pi / p) end - + easeOutElastic = function(ratio) if ratio == 0 or ratio == 1.0 then return ratio end - + local p = 0.3 local s = p / 4.0 return -1 * pow(2.0, -10.0 * ratio) * sin((ratio + s) * 2 * pi / p) + 1.0 end - + easeInOutElastic = function(ratio) if (ratio < 0.5) then return 0.5 * easeInElastic(ratio * 2.0) @@ -145,7 +144,7 @@ easeInOutElastic = function(ratio) return 0.5 * easeOutElastic((ratio - 0.5) * 2.0) + 0.5 end end - + easeOutInElastic = function(ratio) if (ratio < 0.5) then return 0.5 * easeOutElastic(ratio * 2.0) @@ -153,16 +152,16 @@ easeOutInElastic = function(ratio) return 0.5 * easeInElastic((ratio - 0.5) * 2.0) + 0.5 end end - + easeIn = function(ratio) return ratio * ratio * ratio end - + easeOut = function(ratio) local invRatio = ratio - 1.0 return (invRatio * invRatio * invRatio) + 1.0 end - + easeInOut = function(ratio) if (ratio < 0.5) then return 0.5 * easeIn(ratio * 2.0) @@ -170,7 +169,7 @@ easeInOut = function(ratio) return 0.5 * easeOut((ratio - 0.5) * 2.0) + 0.5 end end - + easeOutIn = function(ratio) if (ratio < 0.5) then return 0.5 * easeOut(ratio * 2.0) @@ -178,18 +177,18 @@ easeOutIn = function(ratio) return 0.5 * easeIn((ratio - 0.5) * 2.0) + 0.5 end end - + easeInBack = function(ratio) local s = 1.70158 return pow(ratio, 2.0) * ((s + 1.0) * ratio - s) end - + easeOutBack = function(ratio) local invRatio = ratio - 1.0 local s = 1.70158 return pow(invRatio, 2.0) * ((s + 1.0) * invRatio + s) + 1.0 end - + easeInOutBack = function(ratio) if (ratio < 0.5) then return 0.5 * easeInBack(ratio * 2.0) @@ -197,7 +196,7 @@ easeInOutBack = function(ratio) return 0.5 * easeOutBack((ratio - 0.5) * 2.0) + 0.5 end end - + easeOutInBack = function(ratio) if (ratio < 0.5) then return 0.5 * easeOutBack(ratio * 2.0) diff --git a/gamemode/core/meta/sh_character.lua b/gamemode/core/meta/sh_character.lua index 05b204c5..7a79834a 100644 --- a/gamemode/core/meta/sh_character.lua +++ b/gamemode/core/meta/sh_character.lua @@ -97,7 +97,7 @@ if (SERVER) then end end - -- Sets up the "appearance" related inforomation for the character. + -- Sets up the "appearance" related information for the character. function CHAR:setup(noNetworking) local client = self:getPlayer() @@ -141,7 +141,7 @@ if (SERVER) then local isCurrentChar = self and self:getID() == id -- Return the player to the character menu. - if (self and self.steamID == steamID) then + if (self and self.steamID == steamID) then netstream.Start(client, "charKick", id, isCurrentChar) if (isCurrentChar) then @@ -200,12 +200,10 @@ function CHAR:getPlayer() else for k, v in ipairs(player.GetAll()) do local char = v:getChar() - if (char) then - if (char:getID() == self:getID()) then - self.player = v + if char and (char:getID() == self:getID()) then + self.player = v - return v - end + return v end end end diff --git a/plugins/doors/sh_commands.lua b/plugins/doors/sh_commands.lua index 9227ca70..c08ad6a2 100644 --- a/plugins/doors/sh_commands.lua +++ b/plugins/doors/sh_commands.lua @@ -406,10 +406,10 @@ nut.command.add("doorsethidden", { -- Validate it is a door. if (IsValid(entity) and entity:isDoor()) then - local hidden = util.tobool(arguments[1] or true) + local hidden = tobool(arguments[1] or true) entity:setNetVar("hidden", hidden) - + PLUGIN:callOnDoorChildren(entity, function(child) child:setNetVar("hidden", hidden) end) diff --git a/plugins/raiseweapons/cl_hooks.lua b/plugins/raiseweapons/cl_hooks.lua index b6784764..90a398fb 100644 --- a/plugins/raiseweapons/cl_hooks.lua +++ b/plugins/raiseweapons/cl_hooks.lua @@ -4,7 +4,7 @@ local LOWERED_ANGLES = Angle(30, -30, -25) function PLUGIN:CalcViewModelView(weapon, viewModel, oldEyePos, oldEyeAngles, eyePos, eyeAngles) if (not IsValid(weapon)) then return end - local vm_origin, vm_angles = eyePos, eyeAngles + local vm_angles = eyeAngles local client = LocalPlayer() local value = 0 @@ -14,11 +14,11 @@ function PLUGIN:CalcViewModelView(weapon, viewModel, oldEyePos, oldEyeAngles, ey local fraction = (client.nutRaisedFrac or 0) / 100 local rotation = weapon.LowerAngles or LOWERED_ANGLES - + if (NUT_CVAR_LOWER2:GetBool() and weapon.LowerAngles2) then rotation = weapon.LowerAngles2 end - + vm_angles:RotateAroundAxis(vm_angles:Up(), rotation.p * fraction) vm_angles:RotateAroundAxis(vm_angles:Forward(), rotation.y * fraction) vm_angles:RotateAroundAxis(vm_angles:Right(), rotation.r * fraction) diff --git a/plugins/vignette.lua b/plugins/vignette.lua index 20269be6..1142cc34 100644 --- a/plugins/vignette.lua +++ b/plugins/vignette.lua @@ -34,7 +34,7 @@ end) function PLUGIN:HUDPaintBackground() local frameTime = FrameTime() - local scrW, scrH = surface.ScreenWidth(), surface.ScreenHeight() + local scrW, scrH = ScrW(), ScrH() if (hasVignetteMaterial and nut.config.get("vignette")) then vignetteAlphaDelta = From 714ff753bfc14161b0ee910a761e8d2ef5485c04 Mon Sep 17 00:00:00 2001 From: TovarischPootis <54110479+TovarischPootis@users.noreply.github.com> Date: Sat, 20 Mar 2021 11:12:24 +0200 Subject: [PATCH 33/56] Ability to use @ and ^ when a chat command needs a character's name input --- gamemode/core/libs/sh_command.lua | 51 ++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/gamemode/core/libs/sh_command.lua b/gamemode/core/libs/sh_command.lua index 67ad3f06..4e0126d0 100644 --- a/gamemode/core/libs/sh_command.lua +++ b/gamemode/core/libs/sh_command.lua @@ -28,10 +28,10 @@ function nut.command.add(command, data) -- Or if we specify a usergroup allowed to use this. elseif (data.group) then -- The group property can be a table of usergroups. - if (type(data.group) == "table") then + if istable(data.group) then data.onCheckAccess = function(client) -- Check if the client's group is allowed. - for k, v in ipairs(data.group) do + for _, v in ipairs(data.group) do if (client:IsUserGroup(v)) then return true end @@ -43,7 +43,7 @@ function nut.command.add(command, data) else data.onCheckAccess = function(client) return client:IsUserGroup(data.group) - end + end end end end @@ -68,11 +68,11 @@ function nut.command.add(command, data) local alias = data.alias if (alias) then - if (type(alias) == "table") then - for k, v in ipairs(alias) do + if istable(alias) then + for _, v in ipairs(alias) do nut.command.list[v:lower()] = data end - elseif (type(alias) == "string") then + elseif isstring(alias) then nut.command.list[alias:lower()] = data end end @@ -144,22 +144,37 @@ end if (SERVER) then -- Finds a player or gives an error notification. function nut.command.findPlayer(client, name) - local target = type(name) == "string" and nut.util.findPlayer(name) or NULL + if isstring(name) then + if name == "^" then -- thank you Hein/Hankshark - Tov + return client + elseif name == "@" then + local trace = client:GetEyeTrace().Entity + if IsValid(trace) and trace:IsPlayer() then + return trace + else + client:notifyLocalized("lookToUseAt") + return + end + end + local target = nut.util.findPlayer(name) or NULL - if (IsValid(target)) then - return target + if (IsValid(target)) then + return target + else + client:notifyLocalized("plyNoExist") + end else - client:notifyLocalized("plyNoExist") + client:notifyLocalized("mustProvideString") end end - + -- Finds a faction based on the uniqueID, and then the name if no such uniqueID exists. function nut.command.findFaction(client, name) if (nut.faction.teams[name]) then return nut.faction.teams[name] end - for k, v in ipairs(nut.faction.indices) do + for _, v in ipairs(nut.faction.indices) do if (nut.util.stringMatches(L(v.name,client), name)) then return v --This interrupt means we don't need an if statement below. end @@ -170,7 +185,7 @@ if (SERVER) then -- Forces a player to run a command. function nut.command.run(client, command, arguments) - local command = nut.command.list[command:lower()] + command = nut.command.list[command:lower()] if (command) then -- Run the command's callback and get the return. @@ -178,7 +193,7 @@ if (SERVER) then local result = results[1] -- If a string is returned, it is a notification. - if (type(result) == "string") then + if isstring(result) then -- Normal player here. if (IsValid(client)) then if (result:sub(1, 1) == "@") then @@ -210,8 +225,8 @@ if (SERVER) then match = post[1]:utf8sub(2, len) end - - local match = match:lower() + + match = match:lower() local command = nut.command.list[match] -- We have a valid, registered command. @@ -252,8 +267,8 @@ if (SERVER) then if ((client.nutNextCmd or 0) < CurTime()) then local arguments2 = {} - for k, v in ipairs(arguments) do - if (type(v) == "string" or type(v) == "number") then + for _, v in ipairs(arguments) do + if (isstring(v) or isnumber(v)) then arguments2[#arguments2 + 1] = tostring(v) end end From c8dcbd59d370a313deb7f5d9c02221e8a0300f5a Mon Sep 17 00:00:00 2001 From: TovarischPootis <54110479+TovarischPootis@users.noreply.github.com> Date: Sat, 20 Mar 2021 11:12:36 +0200 Subject: [PATCH 34/56] Updated Russian localization --- gamemode/languages/sh_english.lua | 6 +++++- gamemode/languages/sh_russian.lua | 36 ++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/gamemode/languages/sh_english.lua b/gamemode/languages/sh_english.lua index 99330dd7..26f10444 100644 --- a/gamemode/languages/sh_english.lua +++ b/gamemode/languages/sh_english.lua @@ -259,5 +259,9 @@ LANGUAGE = { panelAdded = "You have added a 3D panel.", itemOnGround = "Your item has been placed on the ground.", forbiddenActionStorage = "You can't do this action with storaged item.", - cantDropBagHasEquipped = "You can't drop bag that has equipped item." + cantDropBagHasEquipped = "You can't drop bag that has equipped item.", + + -- 2021 patch + lookToUseAt = "You need to be looking at someone to use '@'", + mustProvideString = "You must provide a string for the variable", } diff --git a/gamemode/languages/sh_russian.lua b/gamemode/languages/sh_russian.lua index 99af7f46..b89e7fbc 100644 --- a/gamemode/languages/sh_russian.lua +++ b/gamemode/languages/sh_russian.lua @@ -5,6 +5,7 @@ Shadow Nova (http://steamcommunity.com/profiles/76561197989134302), Schwarz Kruppzo (http://steamcommunity.com/id/schwarzkruppzo), Neon (http://steamcommunity.com/id/ru_neon), kirukiru (https://steamcommunity.com/id/kiruthekillah/) +Tov (https://steamcommunity.com/id/TOVARISCHPOOTIS) --]] NAME = "Русский" @@ -255,5 +256,38 @@ LANGUAGE = { flags = "Флаги", moneyLeft = "Ваши деньги: ", currentMoney = "Осталось денег: ", - moneyGiven = "Вы дали %s" + moneyGiven = "Вы дали %s", + + -- 2021 patch + itemCreated = "Предмет успешно создан.", + flagGiveTitle = "Дать флаги", + flagGiveDesc = "Выдать следующие флаги игроку.", + flagTakeTitle = "Отнять флаги", + flagTakeDesc = "Отнять следующие флаги от игрока.", + limitFaction = "Данная фракция полна. Попробуйте попозже.", + toggleObserverTP = "Переключить телепортирование при наблюдении.", + toggleESPAdvanced = "Переключить расширенный режим ESP", + thirdpersonConfig = "Настройка третьего лица", + ammoLoadAll = "Зарадить всё", + ammoLoadAmount = "Зарадить %s", + ammoLoadCustom = "Зарадить...", + split = "Разделить", + splitHelp = "Введите сумму для разделения.", + splitHalf = "Разделить 1/2", + splitQuarter = "Разделить 1/4", + recognize = "Позволить этому персонажу узнать вашу личность.", + recognized = "Данный персонаж узнал вашу личность.", + already_recognized = "Данный персонаж уже знает вашу личность.", + untying = "Развязывание...", + beingUntied = "Вас развязывают...", + beingTied = "Вас связывают...", + sameOutfitCategory = "Такой вид экипировки на вас уже надет.", + noBusiness = "В данный момент вы не можете ничего купить.", + panelRemoved = "Вы удалили %s 3D панелей.", + panelAdded = "Вы добавили 3D панель.", + itemOnGround = "Вас предмет был положет на землю.", + forbiddenActionStorage = "Действие с хранимым предметом запрещено.", + cantDropBagHasEquipped = "Запрещено бросать сумку с экипированным предметом.", + lookToUseAt = "Необходимо смотреть на игрока для использования '@'", + mustProvideString = "Необходимо предьявить строковую для этой функции", } From f5d03c7b52e873512c3ef4d3b5f8e38c638557bd Mon Sep 17 00:00:00 2001 From: TovarischPootis <54110479+TovarischPootis@users.noreply.github.com> Date: Sat, 20 Mar 2021 11:25:49 +0200 Subject: [PATCH 35/56] 1.2 wip (#40) * Fix Item Descs Fixes to items to display proper updated descriptions, rather than the default meta desc (stuff like getData in getDesc works properly now) * Deprication/whitespaces/consistency * Ability to use @ and ^ when a chat command needs a character's name input * Updated Russian localization --- entities/entities/nut_item.lua | 5 +- gamemode/core/derma/cl_inventory.lua | 4 +- gamemode/core/libs/sh_character.lua | 16 ++--- gamemode/core/libs/sh_command.lua | 51 ++++++++++------ gamemode/core/libs/sh_item.lua | 10 ++-- gamemode/core/libs/sv_database.lua | 4 +- gamemode/core/libs/thirdparty/sh_ease.lua | 71 +++++++++++------------ gamemode/core/meta/sh_character.lua | 12 ++-- gamemode/languages/sh_english.lua | 6 +- gamemode/languages/sh_russian.lua | 36 +++++++++++- plugins/doors/sh_commands.lua | 4 +- plugins/raiseweapons/cl_hooks.lua | 6 +- plugins/vignette.lua | 2 +- 13 files changed, 139 insertions(+), 88 deletions(-) diff --git a/entities/entities/nut_item.lua b/entities/entities/nut_item.lua index a8760f6a..224e85be 100644 --- a/entities/entities/nut_item.lua +++ b/entities/entities/nut_item.lua @@ -57,6 +57,7 @@ if (SERVER) then self:PhysicsInit(SOLID_VPHYSICS) self:SetSolid(SOLID_VPHYSICS) self:setNetVar("id", itemTable.uniqueID) + self:setNetVar("instanceID", itemTable:getID()) self.nutItemID = itemID if (table.Count(itemTable.data) > 0) then @@ -192,11 +193,11 @@ else end function ENT:getItemID() - return self:getNetVar("id", "") + return self:getNetVar("instanceID", "") end function ENT:getItemTable() - return nut.item.list[self:getItemID()] + return nut.item.instances[self:getItemID()] end function ENT:getData(key, default) diff --git a/gamemode/core/derma/cl_inventory.lua b/gamemode/core/derma/cl_inventory.lua index 20be1b44..9d1ad015 100644 --- a/gamemode/core/derma/cl_inventory.lua +++ b/gamemode/core/derma/cl_inventory.lua @@ -6,7 +6,7 @@ renderedIcons = renderedIcons or {} -- To make making inventory variant, This must be followed up. function renderNewIcon(panel, itemTable) -- re-render icons - if ((itemTable.iconCam and !renderedIcons[string.lower(itemTable.model)]) or itemTable.forceRender) then + if ((itemTable.iconCam and not renderedIcons[string.lower(itemTable.model)]) or itemTable.forceRender) then local iconCam = itemTable.iconCam iconCam = { cam_pos = iconCam.pos, @@ -14,7 +14,7 @@ function renderNewIcon(panel, itemTable) cam_fov = iconCam.fov, } renderedIcons[string.lower(itemTable.model)] = true - + panel.Icon:RebuildSpawnIconEx( iconCam ) diff --git a/gamemode/core/libs/sh_character.lua b/gamemode/core/libs/sh_character.lua index bff30dd9..8338bd0d 100644 --- a/gamemode/core/libs/sh_character.lua +++ b/gamemode/core/libs/sh_character.lua @@ -105,7 +105,7 @@ do local allowExistNames = nut.config.get("allowExistNames", true) -- Fetch existing character names - if (CLIENT and #nut.char.names < 1 and !allowExistNames) then + if (CLIENT and #nut.char.names < 1 and not allowExistNames) then netstream.Start("nutCharFetchNames") netstream.Hook("nutCharFetchNames", function(data) @@ -114,7 +114,7 @@ do end -- Check whether the chosen character name already exists - if (!nut.config.get("allowExistNames", true)) then + if (not nut.config.get("allowExistNames", true)) then for k, v in pairs(nut.char.names) do if (v == value) then return false, "A character with this name already exists." @@ -161,7 +161,7 @@ do local minLength = nut.config.get("minDescLen", 16) - if (!value or #value:gsub("%s", "") < minLength) then + if (not value or #value:gsub("%s", "") < minLength) then return false, "descMinLen", minLength end end @@ -244,7 +244,7 @@ do local faction = nut.faction.indices[data.faction] if (faction) then - if (!data.model or !faction.models[data.model]) then + if (not data.model or not faction.models[data.model]) then return false, "needModel" end else @@ -337,7 +337,7 @@ do data[key] = value - if (!noReplication and IsValid(client)) then + if (not noReplication and IsValid(client)) then netstream.Start( receiver or client, "charData", @@ -352,7 +352,7 @@ do local data = character.vars.data or {} if (key) then - if (!data) then + if (not data) then return default end @@ -374,7 +374,7 @@ do data[key] = value - if (!noReplication and IsValid(client)) then + if (not noReplication and IsValid(client)) then local id if ( @@ -396,7 +396,7 @@ do local data = character.vars.vars or {} if (key) then - if (!data) then + if (not data) then return default end diff --git a/gamemode/core/libs/sh_command.lua b/gamemode/core/libs/sh_command.lua index 67ad3f06..4e0126d0 100644 --- a/gamemode/core/libs/sh_command.lua +++ b/gamemode/core/libs/sh_command.lua @@ -28,10 +28,10 @@ function nut.command.add(command, data) -- Or if we specify a usergroup allowed to use this. elseif (data.group) then -- The group property can be a table of usergroups. - if (type(data.group) == "table") then + if istable(data.group) then data.onCheckAccess = function(client) -- Check if the client's group is allowed. - for k, v in ipairs(data.group) do + for _, v in ipairs(data.group) do if (client:IsUserGroup(v)) then return true end @@ -43,7 +43,7 @@ function nut.command.add(command, data) else data.onCheckAccess = function(client) return client:IsUserGroup(data.group) - end + end end end end @@ -68,11 +68,11 @@ function nut.command.add(command, data) local alias = data.alias if (alias) then - if (type(alias) == "table") then - for k, v in ipairs(alias) do + if istable(alias) then + for _, v in ipairs(alias) do nut.command.list[v:lower()] = data end - elseif (type(alias) == "string") then + elseif isstring(alias) then nut.command.list[alias:lower()] = data end end @@ -144,22 +144,37 @@ end if (SERVER) then -- Finds a player or gives an error notification. function nut.command.findPlayer(client, name) - local target = type(name) == "string" and nut.util.findPlayer(name) or NULL + if isstring(name) then + if name == "^" then -- thank you Hein/Hankshark - Tov + return client + elseif name == "@" then + local trace = client:GetEyeTrace().Entity + if IsValid(trace) and trace:IsPlayer() then + return trace + else + client:notifyLocalized("lookToUseAt") + return + end + end + local target = nut.util.findPlayer(name) or NULL - if (IsValid(target)) then - return target + if (IsValid(target)) then + return target + else + client:notifyLocalized("plyNoExist") + end else - client:notifyLocalized("plyNoExist") + client:notifyLocalized("mustProvideString") end end - + -- Finds a faction based on the uniqueID, and then the name if no such uniqueID exists. function nut.command.findFaction(client, name) if (nut.faction.teams[name]) then return nut.faction.teams[name] end - for k, v in ipairs(nut.faction.indices) do + for _, v in ipairs(nut.faction.indices) do if (nut.util.stringMatches(L(v.name,client), name)) then return v --This interrupt means we don't need an if statement below. end @@ -170,7 +185,7 @@ if (SERVER) then -- Forces a player to run a command. function nut.command.run(client, command, arguments) - local command = nut.command.list[command:lower()] + command = nut.command.list[command:lower()] if (command) then -- Run the command's callback and get the return. @@ -178,7 +193,7 @@ if (SERVER) then local result = results[1] -- If a string is returned, it is a notification. - if (type(result) == "string") then + if isstring(result) then -- Normal player here. if (IsValid(client)) then if (result:sub(1, 1) == "@") then @@ -210,8 +225,8 @@ if (SERVER) then match = post[1]:utf8sub(2, len) end - - local match = match:lower() + + match = match:lower() local command = nut.command.list[match] -- We have a valid, registered command. @@ -252,8 +267,8 @@ if (SERVER) then if ((client.nutNextCmd or 0) < CurTime()) then local arguments2 = {} - for k, v in ipairs(arguments) do - if (type(v) == "string" or type(v) == "number") then + for _, v in ipairs(arguments) do + if (isstring(v) or isnumber(v)) then arguments2[#arguments2 + 1] = tostring(v) end end diff --git a/gamemode/core/libs/sh_item.lua b/gamemode/core/libs/sh_item.lua index 9904f2cb..e88616a1 100644 --- a/gamemode/core/libs/sh_item.lua +++ b/gamemode/core/libs/sh_item.lua @@ -19,7 +19,7 @@ function nut.item.load(path, baseID, isBaseItem) if (uniqueID) then uniqueID = (isBaseItem and "base_" or "")..uniqueID nut.item.register(uniqueID, baseID, isBaseItem, path) - elseif (!path:find(".txt")) then + elseif (not path:find(".txt")) then ErrorNoHalt( "[NutScript] Item at '"..path.."' follows invalid ".. "naming convention!\n" @@ -102,23 +102,23 @@ function nut.item.loadFromDir(directory) files = file.Find(directory.."/base/*.lua", "LUA") - for k, v in ipairs(files) do + for _, v in ipairs(files) do nut.item.load(directory.."/base/"..v, nil, true) end files, folders = file.Find(directory.."/*", "LUA") - for k, v in ipairs(folders) do + for _, v in ipairs(folders) do if (v == "base") then continue end - for k2, v2 in ipairs(file.Find(directory.."/"..v.."/*.lua", "LUA")) do + for _, v2 in ipairs(file.Find(directory.."/"..v.."/*.lua", "LUA")) do nut.item.load(directory.."/"..v .. "/".. v2, "base_"..v) end end - for k, v in ipairs(files) do + for _, v in ipairs(files) do nut.item.load(directory.."/"..v) end end diff --git a/gamemode/core/libs/sv_database.lua b/gamemode/core/libs/sv_database.lua index 14ffb632..1e374b42 100644 --- a/gamemode/core/libs/sv_database.lua +++ b/gamemode/core/libs/sv_database.lua @@ -72,7 +72,7 @@ modules.tmysql4 = { if (result) then result = result[1] - local queryStatus, queryError, affected, lastID, time, data = result.status, result.error, result.affected, result.lastid, result.time, result.data + local queryStatus, queryError, affected, lastID, time, data = result.status, result.error, result.affected, result.lastid, result.time, result.data if (queryStatus and queryStatus == true and callback) then callback(data, lastID) @@ -116,7 +116,7 @@ modules.tmysql4 = { end else ThrowConnectionFault(fault) - end + end end } diff --git a/gamemode/core/libs/thirdparty/sh_ease.lua b/gamemode/core/libs/thirdparty/sh_ease.lua index e7bd680e..0f94db17 100644 --- a/gamemode/core/libs/thirdparty/sh_ease.lua +++ b/gamemode/core/libs/thirdparty/sh_ease.lua @@ -3,7 +3,7 @@ -- check the ease cheatsheet for your neat UI and stuffs! http://easings.net nut.ease = nut.ease or {} - + local pow = math.pow local sin = math.sin local pi = math.pi @@ -11,76 +11,76 @@ local easeIn, easeOut, easeInOut, easeOutIn local easeInBack, easeOutBack, easeInOutBack, easeOutInBack local easeInElastic, easeOutElastic, easeInOutElastic, easeOutInElastic local easeInBounce, easeOutBounce, easeInOutBounce, easeOutInBounce - + function nut.ease.easeIn(t, tMax, start, delta) return start + (delta * easeIn(t / tMax)) end - + function nut.ease.easeOut(t, tMax, start, delta) return start + (delta * easeOut(t / tMax)) end - + function nut.ease.easeInOut(t, tMax, start, delta) return start + (delta * easeInOut(t / tMax)) end - + function nut.ease.easeOutIn(t, tMax, start, delta) return start + (delta * easeOutIn(t / tMax)) end - + function nut.ease.easeInBack(t, tMax, start, delta) return start + (delta * easeInBack(t / tMax)) end - + function nut.ease.easeOutBack(t, tMax, start, delta) return start + (delta * easeOutBack(t / tMax)) end - + function nut.ease.easeInOutBack(t, tMax, start, delta) return start + (delta * easeInOutBack(t / tMax)) end - + function nut.ease.easeOutInBack(t, tMax, start, delta) return start + (delta * easeOutInBack(t / tMax)) end - + function nut.ease.easeInElastic(t, tMax, start, delta) return start + (delta * easeInElastic(t / tMax)) end - + function nut.ease.easeOutElastic(t, tMax, start, delta) return start + (delta * easeOutElastic(t / tMax)) end - + function nut.ease.easeInOutElastic(t, tMax, start, delta) return start + (delta * easeInOutElastic(t / tMax)) end - + function nut.ease.easeOutInElastic(t, tMax, start, delta) return start + (delta * easeOutInElastic(t / tMax)) end - + function nut.ease.easeInBounce(t, tMax, start, delta) return start + (delta * easeInBounce(t / tMax)) end - + function nut.ease.easeOutBounce(t, tMax, start, delta) return start + (delta * easeOutBounce(t / tMax)) end - + function nut.ease.easeInOutBounce(t, tMax, start, delta) return start + (delta * easeInOutBounce(t / tMax)) end - + function nut.ease.easeOutInBounce(t, tMax, start, delta) return start + (delta * easeOutInBounce(t / tMax)) end - + -- local easing functions easeInBounce = function(ratio) return 1.0 - easeOutBounce(1.0 - ratio) end - + easeOutBounce = function(ratio) local s = 7.5625 local p = 2.75 @@ -103,7 +103,7 @@ easeOutBounce = function(ratio) end return l end - + easeInOutBounce = function(ratio) if (ratio < 0.5) then return 0.5 * easeInBounce(ratio * 2.0) @@ -111,7 +111,7 @@ easeInOutBounce = function(ratio) return 0.5 * easeOutBounce((ratio - 0.5) * 2.0) + 0.5 end end - + easeOutInBounce = function(ratio) if (ratio < 0.5) then return 0.5 * easeOutBounce(ratio * 2.0) @@ -119,25 +119,24 @@ easeOutInBounce = function(ratio) return 0.5 * easeInBounce((ratio - 0.5) * 2.0) + 0.5 end end - - + easeInElastic = function(ratio) if ratio == 0 or ratio == 1.0 then return ratio end - + local p = 0.3 local s = p / 4.0 local invRatio = ratio - 1.0 return -1 * pow(2.0, 10.0 * invRatio) * sin((invRatio - s) * 2 * pi / p) end - + easeOutElastic = function(ratio) if ratio == 0 or ratio == 1.0 then return ratio end - + local p = 0.3 local s = p / 4.0 return -1 * pow(2.0, -10.0 * ratio) * sin((ratio + s) * 2 * pi / p) + 1.0 end - + easeInOutElastic = function(ratio) if (ratio < 0.5) then return 0.5 * easeInElastic(ratio * 2.0) @@ -145,7 +144,7 @@ easeInOutElastic = function(ratio) return 0.5 * easeOutElastic((ratio - 0.5) * 2.0) + 0.5 end end - + easeOutInElastic = function(ratio) if (ratio < 0.5) then return 0.5 * easeOutElastic(ratio * 2.0) @@ -153,16 +152,16 @@ easeOutInElastic = function(ratio) return 0.5 * easeInElastic((ratio - 0.5) * 2.0) + 0.5 end end - + easeIn = function(ratio) return ratio * ratio * ratio end - + easeOut = function(ratio) local invRatio = ratio - 1.0 return (invRatio * invRatio * invRatio) + 1.0 end - + easeInOut = function(ratio) if (ratio < 0.5) then return 0.5 * easeIn(ratio * 2.0) @@ -170,7 +169,7 @@ easeInOut = function(ratio) return 0.5 * easeOut((ratio - 0.5) * 2.0) + 0.5 end end - + easeOutIn = function(ratio) if (ratio < 0.5) then return 0.5 * easeOut(ratio * 2.0) @@ -178,18 +177,18 @@ easeOutIn = function(ratio) return 0.5 * easeIn((ratio - 0.5) * 2.0) + 0.5 end end - + easeInBack = function(ratio) local s = 1.70158 return pow(ratio, 2.0) * ((s + 1.0) * ratio - s) end - + easeOutBack = function(ratio) local invRatio = ratio - 1.0 local s = 1.70158 return pow(invRatio, 2.0) * ((s + 1.0) * invRatio + s) + 1.0 end - + easeInOutBack = function(ratio) if (ratio < 0.5) then return 0.5 * easeInBack(ratio * 2.0) @@ -197,7 +196,7 @@ easeInOutBack = function(ratio) return 0.5 * easeOutBack((ratio - 0.5) * 2.0) + 0.5 end end - + easeOutInBack = function(ratio) if (ratio < 0.5) then return 0.5 * easeOutBack(ratio * 2.0) diff --git a/gamemode/core/meta/sh_character.lua b/gamemode/core/meta/sh_character.lua index 05b204c5..7a79834a 100644 --- a/gamemode/core/meta/sh_character.lua +++ b/gamemode/core/meta/sh_character.lua @@ -97,7 +97,7 @@ if (SERVER) then end end - -- Sets up the "appearance" related inforomation for the character. + -- Sets up the "appearance" related information for the character. function CHAR:setup(noNetworking) local client = self:getPlayer() @@ -141,7 +141,7 @@ if (SERVER) then local isCurrentChar = self and self:getID() == id -- Return the player to the character menu. - if (self and self.steamID == steamID) then + if (self and self.steamID == steamID) then netstream.Start(client, "charKick", id, isCurrentChar) if (isCurrentChar) then @@ -200,12 +200,10 @@ function CHAR:getPlayer() else for k, v in ipairs(player.GetAll()) do local char = v:getChar() - if (char) then - if (char:getID() == self:getID()) then - self.player = v + if char and (char:getID() == self:getID()) then + self.player = v - return v - end + return v end end end diff --git a/gamemode/languages/sh_english.lua b/gamemode/languages/sh_english.lua index 99330dd7..26f10444 100644 --- a/gamemode/languages/sh_english.lua +++ b/gamemode/languages/sh_english.lua @@ -259,5 +259,9 @@ LANGUAGE = { panelAdded = "You have added a 3D panel.", itemOnGround = "Your item has been placed on the ground.", forbiddenActionStorage = "You can't do this action with storaged item.", - cantDropBagHasEquipped = "You can't drop bag that has equipped item." + cantDropBagHasEquipped = "You can't drop bag that has equipped item.", + + -- 2021 patch + lookToUseAt = "You need to be looking at someone to use '@'", + mustProvideString = "You must provide a string for the variable", } diff --git a/gamemode/languages/sh_russian.lua b/gamemode/languages/sh_russian.lua index 99af7f46..b89e7fbc 100644 --- a/gamemode/languages/sh_russian.lua +++ b/gamemode/languages/sh_russian.lua @@ -5,6 +5,7 @@ Shadow Nova (http://steamcommunity.com/profiles/76561197989134302), Schwarz Kruppzo (http://steamcommunity.com/id/schwarzkruppzo), Neon (http://steamcommunity.com/id/ru_neon), kirukiru (https://steamcommunity.com/id/kiruthekillah/) +Tov (https://steamcommunity.com/id/TOVARISCHPOOTIS) --]] NAME = "Русский" @@ -255,5 +256,38 @@ LANGUAGE = { flags = "Флаги", moneyLeft = "Ваши деньги: ", currentMoney = "Осталось денег: ", - moneyGiven = "Вы дали %s" + moneyGiven = "Вы дали %s", + + -- 2021 patch + itemCreated = "Предмет успешно создан.", + flagGiveTitle = "Дать флаги", + flagGiveDesc = "Выдать следующие флаги игроку.", + flagTakeTitle = "Отнять флаги", + flagTakeDesc = "Отнять следующие флаги от игрока.", + limitFaction = "Данная фракция полна. Попробуйте попозже.", + toggleObserverTP = "Переключить телепортирование при наблюдении.", + toggleESPAdvanced = "Переключить расширенный режим ESP", + thirdpersonConfig = "Настройка третьего лица", + ammoLoadAll = "Зарадить всё", + ammoLoadAmount = "Зарадить %s", + ammoLoadCustom = "Зарадить...", + split = "Разделить", + splitHelp = "Введите сумму для разделения.", + splitHalf = "Разделить 1/2", + splitQuarter = "Разделить 1/4", + recognize = "Позволить этому персонажу узнать вашу личность.", + recognized = "Данный персонаж узнал вашу личность.", + already_recognized = "Данный персонаж уже знает вашу личность.", + untying = "Развязывание...", + beingUntied = "Вас развязывают...", + beingTied = "Вас связывают...", + sameOutfitCategory = "Такой вид экипировки на вас уже надет.", + noBusiness = "В данный момент вы не можете ничего купить.", + panelRemoved = "Вы удалили %s 3D панелей.", + panelAdded = "Вы добавили 3D панель.", + itemOnGround = "Вас предмет был положет на землю.", + forbiddenActionStorage = "Действие с хранимым предметом запрещено.", + cantDropBagHasEquipped = "Запрещено бросать сумку с экипированным предметом.", + lookToUseAt = "Необходимо смотреть на игрока для использования '@'", + mustProvideString = "Необходимо предьявить строковую для этой функции", } diff --git a/plugins/doors/sh_commands.lua b/plugins/doors/sh_commands.lua index 9227ca70..c08ad6a2 100644 --- a/plugins/doors/sh_commands.lua +++ b/plugins/doors/sh_commands.lua @@ -406,10 +406,10 @@ nut.command.add("doorsethidden", { -- Validate it is a door. if (IsValid(entity) and entity:isDoor()) then - local hidden = util.tobool(arguments[1] or true) + local hidden = tobool(arguments[1] or true) entity:setNetVar("hidden", hidden) - + PLUGIN:callOnDoorChildren(entity, function(child) child:setNetVar("hidden", hidden) end) diff --git a/plugins/raiseweapons/cl_hooks.lua b/plugins/raiseweapons/cl_hooks.lua index b6784764..90a398fb 100644 --- a/plugins/raiseweapons/cl_hooks.lua +++ b/plugins/raiseweapons/cl_hooks.lua @@ -4,7 +4,7 @@ local LOWERED_ANGLES = Angle(30, -30, -25) function PLUGIN:CalcViewModelView(weapon, viewModel, oldEyePos, oldEyeAngles, eyePos, eyeAngles) if (not IsValid(weapon)) then return end - local vm_origin, vm_angles = eyePos, eyeAngles + local vm_angles = eyeAngles local client = LocalPlayer() local value = 0 @@ -14,11 +14,11 @@ function PLUGIN:CalcViewModelView(weapon, viewModel, oldEyePos, oldEyeAngles, ey local fraction = (client.nutRaisedFrac or 0) / 100 local rotation = weapon.LowerAngles or LOWERED_ANGLES - + if (NUT_CVAR_LOWER2:GetBool() and weapon.LowerAngles2) then rotation = weapon.LowerAngles2 end - + vm_angles:RotateAroundAxis(vm_angles:Up(), rotation.p * fraction) vm_angles:RotateAroundAxis(vm_angles:Forward(), rotation.y * fraction) vm_angles:RotateAroundAxis(vm_angles:Right(), rotation.r * fraction) diff --git a/plugins/vignette.lua b/plugins/vignette.lua index 20269be6..1142cc34 100644 --- a/plugins/vignette.lua +++ b/plugins/vignette.lua @@ -34,7 +34,7 @@ end) function PLUGIN:HUDPaintBackground() local frameTime = FrameTime() - local scrW, scrH = surface.ScreenWidth(), surface.ScreenHeight() + local scrW, scrH = ScrW(), ScrH() if (hasVignetteMaterial and nut.config.get("vignette")) then vignetteAlphaDelta = From 91f685f0b57b7a54b8160a5dc9a0af82f43cf919 Mon Sep 17 00:00:00 2001 From: Zoephix Date: Sun, 21 Mar 2021 10:40:39 +0100 Subject: [PATCH 36/56] Return default text --- plugins/chatbox/derma/cl_chatbox.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/chatbox/derma/cl_chatbox.lua b/plugins/chatbox/derma/cl_chatbox.lua index c0ea018e..33e51f59 100644 --- a/plugins/chatbox/derma/cl_chatbox.lua +++ b/plugins/chatbox/derma/cl_chatbox.lua @@ -260,7 +260,7 @@ local PANEL = {} text = "" end - text = hook.Run("ChatAddText", text, ...) + text = hook.Run("ChatAddText", text, ...) or text for k, v in ipairs({...}) do if (type(v) == "IMaterial") then From c98e7f98ac43db52b5cf79cf1801022a6181a7b4 Mon Sep 17 00:00:00 2001 From: VindoesCompooter <100soundsystem32@gmail.com> Date: Mon, 29 Mar 2021 11:13:39 +0100 Subject: [PATCH 37/56] Alteration to salary Allows classes to have salaries, as per suggestion by Misfit. Feel this can be useful for different ranks/divisions being paid differently. --- gamemode/core/hooks/sv_hooks.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gamemode/core/hooks/sv_hooks.lua b/gamemode/core/hooks/sv_hooks.lua index 3e6682e7..715807c9 100644 --- a/gamemode/core/hooks/sv_hooks.lua +++ b/gamemode/core/hooks/sv_hooks.lua @@ -722,7 +722,8 @@ function GM:CreateSalaryTimer(client) if (not character) then return end local faction = nut.faction.indices[character:getFaction()] - if (not faction or not isnumber(faction.pay) or faction.pay <= 0) then + local class = nut.class.indices[character:getClass()] + if ((not faction or not isnumber(faction.pay) or faction.pay <= 0) and (not class or not isnumber(class.pay) or class.pay <= 0)) then return end @@ -736,8 +737,7 @@ function GM:CreateSalaryTimer(client) return end - - local pay = hook.Run("GetSalaryAmount", client, faction) or faction.pay + local pay = hook.Run("GetSalaryAmount", client, faction, class) or class.pay or faction.pay character:giveMoney(pay) client:notifyLocalized("salary", nut.currency.get(pay)) end) From 54589adcf33e71b495a06930abb364a1ff142e36 Mon Sep 17 00:00:00 2001 From: VindoesCompooter <100soundsystem32@gmail.com> Date: Mon, 29 Mar 2021 13:20:01 +0100 Subject: [PATCH 38/56] Fixed class commit Fixed class salary commit --- gamemode/core/hooks/sv_hooks.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gamemode/core/hooks/sv_hooks.lua b/gamemode/core/hooks/sv_hooks.lua index 715807c9..4c9d9413 100644 --- a/gamemode/core/hooks/sv_hooks.lua +++ b/gamemode/core/hooks/sv_hooks.lua @@ -721,11 +721,10 @@ function GM:CreateSalaryTimer(client) local character = client:getChar() if (not character) then return end - local faction = nut.faction.indices[character:getFaction()] - local class = nut.class.indices[character:getClass()] - if ((not faction or not isnumber(faction.pay) or faction.pay <= 0) and (not class or not isnumber(class.pay) or class.pay <= 0)) then - return - end + local faction = nut.faction.indices[character:getFaction()] or {} + local class = nut.class.indices[character:getClass()] or {} + + local pay = (class and class.pay) or (faction and faction.pay) or nil --thank you Tov. local timerID = "nutSalary"..client:SteamID() local timerFunc = timer.Exists(timerID) and timer.Adjust or timer.Create @@ -737,9 +736,10 @@ function GM:CreateSalaryTimer(client) return end - local pay = hook.Run("GetSalaryAmount", client, faction, class) or class.pay or faction.pay - character:giveMoney(pay) - client:notifyLocalized("salary", nut.currency.get(pay)) + if (pay) then + character:giveMoney(pay) + client:notifyLocalized("salary", nut.currency.get(pay)) + end end) end From 6c6d297b26fa1116e3eb5ba5219eec566b2c52ad Mon Sep 17 00:00:00 2001 From: VindoesCompooter <100soundsystem32@gmail.com> Date: Mon, 29 Mar 2021 13:21:21 +0100 Subject: [PATCH 39/56] Another quick fix Simplifies the return if there's no money to give. --- gamemode/core/hooks/sv_hooks.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gamemode/core/hooks/sv_hooks.lua b/gamemode/core/hooks/sv_hooks.lua index 4c9d9413..9657eb07 100644 --- a/gamemode/core/hooks/sv_hooks.lua +++ b/gamemode/core/hooks/sv_hooks.lua @@ -725,6 +725,8 @@ function GM:CreateSalaryTimer(client) local class = nut.class.indices[character:getClass()] or {} local pay = (class and class.pay) or (faction and faction.pay) or nil --thank you Tov. + + if !pay then return end local timerID = "nutSalary"..client:SteamID() local timerFunc = timer.Exists(timerID) and timer.Adjust or timer.Create @@ -736,10 +738,8 @@ function GM:CreateSalaryTimer(client) return end - if (pay) then - character:giveMoney(pay) - client:notifyLocalized("salary", nut.currency.get(pay)) - end + character:giveMoney(pay) + client:notifyLocalized("salary", nut.currency.get(pay)) end) end From e2ddc9c0d768c06b9a2e48c91e190c2f90854f2e Mon Sep 17 00:00:00 2001 From: Seamus McGowan <100soundsystem32@gmail.com> Date: Mon, 29 Mar 2021 15:08:27 +0100 Subject: [PATCH 40/56] Update gamemode/core/hooks/sv_hooks.lua Works better in the long run. Co-authored-by: TovarischPootis <54110479+TovarischPootis@users.noreply.github.com> --- gamemode/core/hooks/sv_hooks.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gamemode/core/hooks/sv_hooks.lua b/gamemode/core/hooks/sv_hooks.lua index 9657eb07..e91e2f83 100644 --- a/gamemode/core/hooks/sv_hooks.lua +++ b/gamemode/core/hooks/sv_hooks.lua @@ -724,7 +724,7 @@ function GM:CreateSalaryTimer(client) local faction = nut.faction.indices[character:getFaction()] or {} local class = nut.class.indices[character:getClass()] or {} - local pay = (class and class.pay) or (faction and faction.pay) or nil --thank you Tov. + local pay = hook.Run("GetSalaryAmount", client, faction, class) or (class and class.pay) or (faction and faction.pay) or nil --thank you Tov. if !pay then return end From dd44cd09492ab60ab2eb689732b4b6e102e38ece Mon Sep 17 00:00:00 2001 From: Seamus McGowan <100soundsystem32@gmail.com> Date: Mon, 29 Mar 2021 17:20:31 +0100 Subject: [PATCH 41/56] Update gamemode/core/hooks/sv_hooks.lua Co-authored-by: TovarischPootis <54110479+TovarischPootis@users.noreply.github.com> --- gamemode/core/hooks/sv_hooks.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gamemode/core/hooks/sv_hooks.lua b/gamemode/core/hooks/sv_hooks.lua index e91e2f83..76a97e9a 100644 --- a/gamemode/core/hooks/sv_hooks.lua +++ b/gamemode/core/hooks/sv_hooks.lua @@ -722,7 +722,7 @@ function GM:CreateSalaryTimer(client) if (not character) then return end local faction = nut.faction.indices[character:getFaction()] or {} - local class = nut.class.indices[character:getClass()] or {} + local class = nut.class.indices[character:getClass()] or nil local pay = hook.Run("GetSalaryAmount", client, faction, class) or (class and class.pay) or (faction and faction.pay) or nil --thank you Tov. From c0dcc47a12f06daacf81ea8310a6cf4efb01a6b8 Mon Sep 17 00:00:00 2001 From: Seamus McGowan <100soundsystem32@gmail.com> Date: Mon, 29 Mar 2021 17:20:35 +0100 Subject: [PATCH 42/56] Update gamemode/core/hooks/sv_hooks.lua Co-authored-by: TovarischPootis <54110479+TovarischPootis@users.noreply.github.com> --- gamemode/core/hooks/sv_hooks.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gamemode/core/hooks/sv_hooks.lua b/gamemode/core/hooks/sv_hooks.lua index 76a97e9a..a2d856f7 100644 --- a/gamemode/core/hooks/sv_hooks.lua +++ b/gamemode/core/hooks/sv_hooks.lua @@ -721,7 +721,7 @@ function GM:CreateSalaryTimer(client) local character = client:getChar() if (not character) then return end - local faction = nut.faction.indices[character:getFaction()] or {} + local faction = nut.faction.indices[character:getFaction()] or nil local class = nut.class.indices[character:getClass()] or nil local pay = hook.Run("GetSalaryAmount", client, faction, class) or (class and class.pay) or (faction and faction.pay) or nil --thank you Tov. From 5345385ae9b46cb377a73cdfdf04056371a0e667 Mon Sep 17 00:00:00 2001 From: VindoesCompooter <100soundsystem32@gmail.com> Date: Wed, 31 Mar 2021 18:27:36 +0100 Subject: [PATCH 43/56] Hook to hide players in Scoreboard A very simple hook that hides certain factions in the scoreboard if conditions are met. Good for hiding admin factions or event factions. --- plugins/scoreboard/derma/cl_scoreboard.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/scoreboard/derma/cl_scoreboard.lua b/plugins/scoreboard/derma/cl_scoreboard.lua index 047ea64f..231ee09d 100644 --- a/plugins/scoreboard/derma/cl_scoreboard.lua +++ b/plugins/scoreboard/derma/cl_scoreboard.lua @@ -94,6 +94,12 @@ local PANEL = {} elseif (!visible and amount > 0) then v:SetVisible(true) end + + local faction = nut.faction.indices[k] + + if (hook.Run("HideFactionInScoreboard",faction) == false) then + v:SetVisible(hook.Run("CanSeeHiddenFactions") != false) + end end for k, v in pairs(self.slots) do From cf3733d27a4b862a5f954d8e81bba97c4986cbad Mon Sep 17 00:00:00 2001 From: VindoesCompooter <100soundsystem32@gmail.com> Date: Wed, 31 Mar 2021 18:34:18 +0100 Subject: [PATCH 44/56] Optimization Figured out how to optimize the hiding code. --- plugins/scoreboard/derma/cl_scoreboard.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/plugins/scoreboard/derma/cl_scoreboard.lua b/plugins/scoreboard/derma/cl_scoreboard.lua index 231ee09d..e2113056 100644 --- a/plugins/scoreboard/derma/cl_scoreboard.lua +++ b/plugins/scoreboard/derma/cl_scoreboard.lua @@ -97,9 +97,7 @@ local PANEL = {} local faction = nut.faction.indices[k] - if (hook.Run("HideFactionInScoreboard",faction) == false) then - v:SetVisible(hook.Run("CanSeeHiddenFactions") != false) - end + v:SetVisible(hook.Run("HideFactionInScoreboard",faction) and !LocalPlayer():IsAdmin()) end for k, v in pairs(self.slots) do From 844532b5b276a24cf2e38e912b4dd983169573ac Mon Sep 17 00:00:00 2001 From: VindoesCompooter <100soundsystem32@gmail.com> Date: Wed, 31 Mar 2021 18:52:22 +0100 Subject: [PATCH 45/56] Update cl_scoreboard.lua Another small fix to the code, prevents faction appearing if amount is 0 --- plugins/scoreboard/derma/cl_scoreboard.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/scoreboard/derma/cl_scoreboard.lua b/plugins/scoreboard/derma/cl_scoreboard.lua index e2113056..314a2eaa 100644 --- a/plugins/scoreboard/derma/cl_scoreboard.lua +++ b/plugins/scoreboard/derma/cl_scoreboard.lua @@ -97,7 +97,9 @@ local PANEL = {} local faction = nut.faction.indices[k] - v:SetVisible(hook.Run("HideFactionInScoreboard",faction) and !LocalPlayer():IsAdmin()) + if (amount != 0) then + v:SetVisible(hook.Run("HideFactionInScoreboard",faction) != false or LocalPlayer():IsAdmin()) + end end for k, v in pairs(self.slots) do From 1b24b743a2d24385470050c0907c2cef13798a2d Mon Sep 17 00:00:00 2001 From: Zoephix Date: Wed, 31 Mar 2021 21:05:08 +0200 Subject: [PATCH 46/56] Update sv_hooks.lua --- gamemode/core/hooks/sv_hooks.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gamemode/core/hooks/sv_hooks.lua b/gamemode/core/hooks/sv_hooks.lua index a2d856f7..8c33c76f 100644 --- a/gamemode/core/hooks/sv_hooks.lua +++ b/gamemode/core/hooks/sv_hooks.lua @@ -721,12 +721,12 @@ function GM:CreateSalaryTimer(client) local character = client:getChar() if (not character) then return end - local faction = nut.faction.indices[character:getFaction()] or nil - local class = nut.class.indices[character:getClass()] or nil + local faction = nut.faction.indices[character:getFaction()] + local class = nut.class.indices[character:getClass()] - local pay = hook.Run("GetSalaryAmount", client, faction, class) or (class and class.pay) or (faction and faction.pay) or nil --thank you Tov. + local pay = hook.Run("GetSalaryAmount", client, faction, class) or (class and class.pay) or (faction and faction.pay) or nil - if !pay then return end + if (!pay) then return end local timerID = "nutSalary"..client:SteamID() local timerFunc = timer.Exists(timerID) and timer.Adjust or timer.Create From 03c8139b9a02e9ce5b7f9c8b1c80931b18cc894a Mon Sep 17 00:00:00 2001 From: Zoephix Date: Wed, 31 Mar 2021 21:05:58 +0200 Subject: [PATCH 47/56] Update cl_scoreboard.lua --- plugins/scoreboard/derma/cl_scoreboard.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/scoreboard/derma/cl_scoreboard.lua b/plugins/scoreboard/derma/cl_scoreboard.lua index 314a2eaa..795182b7 100644 --- a/plugins/scoreboard/derma/cl_scoreboard.lua +++ b/plugins/scoreboard/derma/cl_scoreboard.lua @@ -98,7 +98,7 @@ local PANEL = {} local faction = nut.faction.indices[k] if (amount != 0) then - v:SetVisible(hook.Run("HideFactionInScoreboard",faction) != false or LocalPlayer():IsAdmin()) + v:SetVisible(hook.Run("HideFactionInScoreboard", faction) or LocalPlayer():IsAdmin()) end end From e92ca59f76461075c7734c0aa6dd2f27a7d30c23 Mon Sep 17 00:00:00 2001 From: TovarischPootis <54110479+TovarischPootis@users.noreply.github.com> Date: Thu, 1 Apr 2021 18:58:06 +0300 Subject: [PATCH 48/56] Remade Credits. Added surfaceGetURL. Added comments to ease to explain how to use. --- .../core/libs/thirdparty/cl_surfaceGetURL.lua | 57 +++++ gamemode/core/libs/thirdparty/sh_ease.lua | 6 + plugins/f1menu/derma/cl_helps.lua | 168 +++----------- plugins/nscredits.lua | 212 ++++++++++++++++++ 4 files changed, 306 insertions(+), 137 deletions(-) create mode 100644 gamemode/core/libs/thirdparty/cl_surfaceGetURL.lua create mode 100644 plugins/nscredits.lua diff --git a/gamemode/core/libs/thirdparty/cl_surfaceGetURL.lua b/gamemode/core/libs/thirdparty/cl_surfaceGetURL.lua new file mode 100644 index 00000000..0bf88843 --- /dev/null +++ b/gamemode/core/libs/thirdparty/cl_surfaceGetURL.lua @@ -0,0 +1,57 @@ +--[[ +https://github.com/mattkrins/surfaceGetURL + +MIT License + +Copyright (c) 2016 Matt Krins + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +]] + +local WebMaterials = {} +function surface.GetURL(url, w, h, time) + if not url or not w or not h then return Material("error") end + if WebMaterials[url] then return WebMaterials[url] end + local WebPanel = vgui.Create( "HTML" ) + WebPanel:SetAlpha( 0 ) + WebPanel:SetSize( tonumber(w), tonumber(h) ) + WebPanel:OpenURL( url ) + WebPanel.Paint = function(self) + if not WebMaterials[url] and self:GetHTMLMaterial() then + WebMaterials[url] = self:GetHTMLMaterial() + self:Remove() + end + end + timer.Simple( 1 or tonumber(time), function() if IsValid(WebPanel) then WebPanel:Remove() end end ) -- In case we do not render + return Material("error") +end + +--[[ + How to use + + local DPanel = vgui.Create( "DPanel" ) + DPanel:SetSize( 336, 280 ) + DPanel:Center() + DPanel.Paint = function() + local WebMaterial = surface.GetURL("http://www.lipsum.com/images/banners/black_336x280.gif", 336, 280) + surface.SetDrawColor( 255, 255, 255, 255 ) + surface.SetMaterial( WebMaterial ) + surface.DrawTexturedRect( 0, 0, WebMaterial:Width(), WebMaterial:Height() ) + end +]] \ No newline at end of file diff --git a/gamemode/core/libs/thirdparty/sh_ease.lua b/gamemode/core/libs/thirdparty/sh_ease.lua index 0f94db17..3b7cc969 100644 --- a/gamemode/core/libs/thirdparty/sh_ease.lua +++ b/gamemode/core/libs/thirdparty/sh_ease.lua @@ -12,6 +12,12 @@ local easeInBack, easeOutBack, easeInOutBack, easeOutInBack local easeInElastic, easeOutElastic, easeInOutElastic, easeOutInElastic local easeInBounce, easeOutBounce, easeInOutBounce, easeOutInBounce +--[[ +t = timeElapsed +tMax = duration of animation/ending time of animation +start = starting time +delta = change to apply per change ]] + function nut.ease.easeIn(t, tMax, start, delta) return start + (delta * easeIn(t / tMax)) end diff --git a/plugins/f1menu/derma/cl_helps.lua b/plugins/f1menu/derma/cl_helps.lua index a7f5c92f..51166419 100644 --- a/plugins/f1menu/derma/cl_helps.lua +++ b/plugins/f1menu/derma/cl_helps.lua @@ -1,23 +1,11 @@ - surface.CreateFont("nutSmallCredits", { - font = "Roboto", - size = 18, - weight = 400 - }) - - surface.CreateFont("nutBigCredits", { - font = "Roboto", - size = 25, - weight = 600 - }) - local HELP_DEFAULT - hook.Add("CreateMenuButtons", "nutHelpMenu", function(tabs) + hook.Add("CreateMenuButtons", "nutHelpMenu", function(tabs) HELP_DEFAULT = [[
- +
]] .. L"helpDefault" .. [[
@@ -60,21 +48,25 @@ tree.OnNodeSelected = function(this, node) if (node.onGetHTML) then local source = node:onGetHTML() - - if (IsValid(devAvatar)) then + if IsValid(helpPanel) then + print("this triggered") helpPanel:Remove() + end + if nut.gui.creditsPanel then + nut.gui.creditsPanel:Remove() + end - helpPanel = panel:Add("DListView") - helpPanel:Dock(FILL) - helpPanel.Paint = function(this, w, h) - end - - html = helpPanel:Add("DHTML") - html:Dock(FILL) - html:SetHTML(header..HELP_DEFAULT) + helpPanel = panel:Add("DListView") + helpPanel:Dock(FILL) + helpPanel.Paint = function() end + helpPanel:InvalidateLayout(true) + + html = helpPanel:Add("DHTML") + html:Dock(FILL) + html:SetHTML(header..HELP_DEFAULT) - if (source:sub(1, 4) == "http") then + if (source and source:sub(1, 4) == "http") then html:OpenURL(source) else html:SetHTML(header..node:onGetHTML().."") @@ -82,16 +74,17 @@ end end - helpPanel = panel:Add("DListView") - helpPanel:Dock(FILL) - helpPanel.Paint = function(this, w, h) - end - - html = helpPanel:Add("DHTML") - html:Dock(FILL) - html:SetHTML(header..HELP_DEFAULT) + if not IsValid(helpPanel) then + helpPanel = panel:Add("DListView") + helpPanel:Dock(FILL) + helpPanel.Paint = function() + end - local tabs = {} + html = helpPanel:Add("DHTML") + html:Dock(FILL) + html:SetHTML(header..HELP_DEFAULT) + end + tabs = {} hook.Run("BuildHelpMenu", tabs) for k, v in SortedPairs(tabs) do @@ -113,14 +106,14 @@ hook.Add("BuildHelpMenu", "nutBasicHelp", function(tabs) for k, v in SortedPairs(nut.command.list) do local allowed = false - if (v.adminOnly and !LocalPlayer():IsAdmin()or v.superAdminOnly and !LocalPlayer():IsSuperAdmin()) then + if (v.adminOnly and not LocalPlayer():IsAdmin()or v.superAdminOnly and not LocalPlayer():IsSuperAdmin()) then continue end if (v.group) then if (istable(v.group)) then - for k, v in pairs(v.group) do - if (LocalPlayer():IsUserGroup(v)) then + for _, v1 in pairs(v.group) do + if (LocalPlayer():IsUserGroup(v1)) then allowed = true break @@ -168,7 +161,7 @@ hook.Add("BuildHelpMenu", "nutBasicHelp", function(tabs) tabs["plugins"] = function(node) local body = "" - for k, v in SortedPairsByMemberValue(nut.plugin.list, "name") do + for _, v in SortedPairsByMemberValue(nut.plugin.list, "name") do body = (body..[[

%s
@@ -186,103 +179,4 @@ hook.Add("BuildHelpMenu", "nutBasicHelp", function(tabs) return body end - - local authorCredits = { - {desc = "Creator", steamid = "76561198030127257"}, -- Chessnut - {desc = "Co-Creator", steamid = "76561197999893894"}, -- Black Tea - {desc = "Developer", steamid = "76561198060659964"}, -- Zoephix - {desc = "Developer", steamid = "76561198070441753"}, -- TovarischPootis - {desc = "Contributors", button = "View all contributors", url = "https://github.com/NutScript/NutScript/graphs/contributors"} - } - - tabs["Credits"] = function(node) - local body = [[ -

-
- -
NutScript -
-
- ]] - local scrW = ScrW() - local scrH = ScrH() - local offsetW = scrW*0.025 - local offsetH = scrH*0.08 - local offsetC = scrW*0.25 - - local nscredits = helpPanel:Add("DScrollPanel") - nscredits:Dock(FILL) - nscredits:DockMargin(0, scrH*0.32, 0, 0) - nscredits.Paint = function() - end - - for k, v in ipairs(authorCredits) do - local offsetH = k == 1 and 0 or (k*offsetH)-offsetH - - if (v.steamid) then - steamworks.RequestPlayerInfo(v.steamid, function(steamName) - devName = nscredits:Add("DLabel") - devName:SetText(steamName) - devName:SetFont("nutBigCredits") - devName:SetTextColor(Color(255, 255, 255)) - devName:SizeToContents() - end) - -- - -- add custom field - else - devName = nscredits:Add("DLabel") - devName:SetText(v.desc) - devName:SetFont("nutBigCredits") - devName:SetTextColor(Color(255, 255, 255)) - devName:SizeToContents() - end - - if (v.steamid or v.text) then - desc = nscredits:Add("DLabel") - desc:SetText(v.desc) - desc:SetFont("nutSmallCredits") - desc:SetTextColor(Color(255, 255, 255)) - desc:SizeToContents() - elseif (v.button) then - desc = nscredits:Add("DButton") - desc:SetText(v.button) - desc:SizeToContents() - desc.DoClick = function() - surface.PlaySound("buttons/button14.wav") - - gui.OpenURL(v.url) - end - - offsetH = offsetH + 25 - end - - -- fucking end my suffering - -- this shit took me over three hours... - local offsetW2 = string.Explode(" ", v.button and desc:GetSize() or desc:GetTextSize())[1] - local offsetW3 = string.Explode(" ", devName:GetTextSize())[1] - - devName:SetPos(devName:GetPos()+(offsetC-devName:GetPos()), 0) - devName:SetPos(devName:GetPos()-(offsetW3/2), offsetH) - - desc:SetPos(desc:GetPos()+(offsetC-desc:GetPos()), 0) - desc:SetPos(desc:GetPos()-(offsetW2/2), offsetH+(v.button and scrH*0.03 or scrH*0.022)) - - if (v.steamid) then - devAvatar = vgui.Create("AvatarImage", nscredits) - devAvatar:SetPos(devName:GetPos()-(scrW*0.025), offsetH) - devAvatar:SetSteamID(v.steamid, 64) - devAvatar:SetSize(40, 40) - devAvatar.OnCursorEntered = function() - surface.PlaySound("garrysmod/ui_return.wav") - end - devAvatar.OnMousePressed = function() - surface.PlaySound("buttons/button14.wav") - - gui.OpenURL("http://steamcommunity.com/profiles/"..v.steamid) - end - end - end - - return body - end end) diff --git a/plugins/nscredits.lua b/plugins/nscredits.lua new file mode 100644 index 00000000..358070d4 --- /dev/null +++ b/plugins/nscredits.lua @@ -0,0 +1,212 @@ +PLUGIN.name = "Credits Tab" +PLUGIN.desc = "A tab where players can see who made the framework/schema" +PLUGIN.author = "NS Team" + +if SERVER then return end + +local ScrW, ScrH = ScrW(), ScrH() +local logoMat = Material("nutscript/logo.png") +local logoGlowMat = Material("nutscript/logo_glow.png") +local textureID = surface.GetTextureID("models/effects/portalfunnel_sheet") +surface.CreateFont("nutSmallCredits", { + font = "Roboto", + size = 20, + weight = 400 +}) + +surface.CreateFont("nutBigCredits", { + font = "Roboto", + size = 32, + weight = 600 +}) + +local authorCredits = { + {desc = "Creator", steamid = "76561198030127257", color = Color(255, 0, 0)}, -- Chessnut + {desc = "Co-Creator", steamid = "76561197999893894", color = Color(255, 0, 0)}, -- Black Tea + {desc = "Head Developer", steamid = "76561198060659964", color = Color(138,43,226)}, -- Zoephix + {desc = "Head Developer", steamid = "76561198070441753", color = Color(138,43,226)}, -- TovarischPootis + {desc = "Developer", steamid = "76561198036551982", color = Color(34,139,34)}, -- Seamus + {desc = "Developer", steamid = "76561198031437460", color = Color(34,139,34)}, -- Milk +} + +local contributors = {desc = "View All Contributors", url = "https://github.com/NutScript/NutScript/graphs/contributors"} + +local PANEL = {} + +function PANEL:Init() + + self.avatarImage = self:Add("AvatarImage") + self.avatarImage:Dock(LEFT) + self.avatarImage:SetSize(64,64) + + self.name = self:Add("DLabel") + self.name:SetFont("nutBigCredits") + + self.desc = self:Add("DLabel") + self.desc:SetFont("nutSmallCredits") +end + +function PANEL:setAvatarImage(id) + if not self.avatarImage then return end + self.avatarImage:SetSteamID(id, 64) + self.avatarImage.OnCursorEntered = function() + surface.PlaySound("garrysmod/ui_return.wav") + end + + self.avatarImage.OnMousePressed = function() + surface.PlaySound("buttons/button14.wav") + gui.OpenURL("http://steamcommunity.com/profiles/"..id) + end +end + +function PANEL:setName(name, isID, color) + if not self.name then return end + if isID then + steamworks.RequestPlayerInfo(name, function(steamName) + self.name:SetText(steamName or "Loading...") + end) + else + self.name:SetText(name) + end + if color then + self.name:SetTextColor(color) + end + self.name:SizeToContents() + self.name:Dock(TOP) + self.name:DockMargin(ScrW*0.01, 0,0,0) +end + +function PANEL:setDesc(desc) + if not self.desc then return end + self.desc:SetText(desc) + self.desc:SizeToContents() + self.desc:Dock(TOP) + self.desc:DockMargin(ScrW*0.01, 0,0,0) +end + +function PANEL:Paint(w, h) + surface.SetTexture(textureID) + surface.DrawTexturedRect(0, 0, w, h) +end +vgui.Register("CreditsNamePanel", PANEL, "DPanel") + +PANEL = {} + +function PANEL:Init() + self.contButton = self:Add("DButton") + self.contButton:SetFont("nutBigCredits") + self.contButton:SetText(contributors.desc) + self.contButton.DoClick = function() + surface.PlaySound("buttons/button14.wav") + gui.OpenURL(contributors.url) + end + self.contButton.Paint = function() end + self.contButton:Dock(TOP) + self:SizeToChildren(true, true) +end + +function PANEL:Paint() +end + +vgui.Register("CreditsContribPanel", PANEL, "DPanel") + +PANEL = {} + +function PANEL:Init() + +end + +function PANEL:setPerson(data, left) + local id = left and "creditleft" or "creditright" + self[id] = self:Add("CreditsNamePanel") + self[id]:setAvatarImage(data.steamid) + self[id]:setName(data.steamid, true, data.color) + self[id]:setDesc(data.desc) + self[id]:Dock(left and LEFT or RIGHT) + self[id]:InvalidateLayout(true) + self[id]:SizeToChildren(false, true) + self:InvalidateLayout(true) + self[id]:SetWide((self:GetWide()/2)+32) +end + +function PANEL:Paint() +end + +vgui.Register("CreditsCreditsList", PANEL, "DPanel") + +PANEL = {} + +function PANEL:Init() +end + +function PANEL:Paint(w,h) + surface.SetMaterial(logoGlowMat) + surface.DrawTexturedRect((w/2)-128,(h/2)-128,256,256) + surface.SetMaterial(logoMat) + surface.DrawTexturedRect((w/2)-128,(h/2)-128,256,256) +end + +vgui.Register("CreditsLogo", PANEL, "DPanel") + +PANEL = {} + +function PANEL:Init() + if nut.gui.creditsPanel then + nut.gui.creditsPanel:Remove() + end + nut.gui.creditsPanel = self + + self:SetSize(ScrW*0.3, ScrH*0.7) + + self.logo = self:Add("CreditsLogo") + self.logo:SetSize(ScrW*0.4, ScrW*0.1) + self.logo:Dock(TOP) + self.logo:DockMargin(0,0,0,ScrH*0.05) + + self.nsteam = self:Add("DLabel") + self.nsteam:SetFont("nutBigCredits") + self.nsteam:SetText("NutScript Development Team") + self.nsteam:SizeToContents() + self.nsteam:Dock(TOP) + local dockLeft = ScrW*0.15 - (self.nsteam:GetContentSize())/2 + self.nsteam:DockMargin(dockLeft,0,0,ScrH*0.025) + + self.creditPanels = {} + local curNum = 0 + + for k, v in ipairs(authorCredits) do + if k%2 ~= 0 then -- if k is odd + self.creditPanels[k] = self:Add("CreditsCreditsList") + curNum = k + self.creditPanels[curNum]:SetSize(self:GetWide(), ScrH*0.05) + self.creditPanels[curNum]:setPerson(v, true) + --self.creditPanels[curNum]:SizeToChildren(false, true) + self.creditPanels[curNum]:Dock(TOP) + self.creditPanels[curNum]:DockMargin(0,0,0,ScrH*0.01) + else + self.creditPanels[curNum]:setPerson(v, false) + -- self.creditPanels[curNum]:SizeToChildren(false, true) + self.creditPanels[curNum]:Dock(TOP) + self.creditPanels[curNum]:DockMargin(0,0,0,ScrH*0.01) + end + end + self.contribPanel = self:Add("CreditsContribPanel") + self.contribPanel:SizeToChildren(true, true) + self.contribPanel:Dock(TOP) +end + +function PANEL:Paint() +end + +vgui.Register("nutCreditsList", PANEL, "DPanel") + +hook.Add("BuildHelpMenu", "nutCreditsList", function(tabs) + tabs["Credits"] = function() + if helpPanel then + local credits = helpPanel:Add("nutCreditsList") + credits:Dock(TOP) + credits:DockMargin(ScrW*0.1, 0, ScrW*0.1, 0) + end + return "" + end +end) From 3da6614e9b57de60024ce47f17aaf65003847ca8 Mon Sep 17 00:00:00 2001 From: TovarischPootis <54110479+TovarischPootis@users.noreply.github.com> Date: Thu, 1 Apr 2021 19:02:12 +0300 Subject: [PATCH 49/56] Update cl_helps.lua --- plugins/f1menu/derma/cl_helps.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/f1menu/derma/cl_helps.lua b/plugins/f1menu/derma/cl_helps.lua index 51166419..a9e0b4ee 100644 --- a/plugins/f1menu/derma/cl_helps.lua +++ b/plugins/f1menu/derma/cl_helps.lua @@ -49,7 +49,6 @@ if (node.onGetHTML) then local source = node:onGetHTML() if IsValid(helpPanel) then - print("this triggered") helpPanel:Remove() end if nut.gui.creditsPanel then From 84f280923c9e97ebba8d7b85961f9c4a8ffc1e33 Mon Sep 17 00:00:00 2001 From: TovarischPootis <54110479+TovarischPootis@users.noreply.github.com> Date: Thu, 1 Apr 2021 19:03:37 +0300 Subject: [PATCH 50/56] Update nscredits.lua --- plugins/nscredits.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/nscredits.lua b/plugins/nscredits.lua index 358070d4..abf8a404 100644 --- a/plugins/nscredits.lua +++ b/plugins/nscredits.lua @@ -180,12 +180,10 @@ function PANEL:Init() curNum = k self.creditPanels[curNum]:SetSize(self:GetWide(), ScrH*0.05) self.creditPanels[curNum]:setPerson(v, true) - --self.creditPanels[curNum]:SizeToChildren(false, true) self.creditPanels[curNum]:Dock(TOP) self.creditPanels[curNum]:DockMargin(0,0,0,ScrH*0.01) else self.creditPanels[curNum]:setPerson(v, false) - -- self.creditPanels[curNum]:SizeToChildren(false, true) self.creditPanels[curNum]:Dock(TOP) self.creditPanels[curNum]:DockMargin(0,0,0,ScrH*0.01) end From 5787df04270d57d8bbfa79a3f8f6082e74b0f203 Mon Sep 17 00:00:00 2001 From: TovarischPootis <54110479+TovarischPootis@users.noreply.github.com> Date: Thu, 1 Apr 2021 22:14:14 +0300 Subject: [PATCH 51/56] Fixed the autoname for plugin/schema authors --- gamemode/core/hooks/cl_hooks.lua | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/gamemode/core/hooks/cl_hooks.lua b/gamemode/core/hooks/cl_hooks.lua index 28d588fa..e4359592 100644 --- a/gamemode/core/hooks/cl_hooks.lua +++ b/gamemode/core/hooks/cl_hooks.lua @@ -540,18 +540,19 @@ function GM:ScreenResolutionChanged(oldW, oldH) end function GM:NutScriptLoaded() + local namecache = {} for _, PLUGIN in pairs(nut.plugin.list) do - local author64ID = tonumber(PLUGIN.author) - local authorSteamID = string.match(PLUGIN.author, "STEAM_", 1) - - if (author64ID or authorSteamID) then - -- Store the Steam ID - PLUGIN.authorID = author64ID and util.SteamIDFrom64(PLUGIN.author) or PLUGIN.author - - steamworks.RequestPlayerInfo(authorSteamID and util.SteamIDTo64(PLUGIN.author) or PLUGIN.author, function(steamName) - -- Update the author name - PLUGIN.author = steamName - end) + local authorID = (tonumber(PLUGIN.author) and tostring(PLUGIN.author)) or (string.match(PLUGIN.author, "STEAM_") and util.SteamIDTo64(PLUGIN.author)) or nil + if authorID then + if namecache[authorID] ~= nil then + PLUGIN.author = namecache[authorID] + else + steamworks.RequestPlayerInfo(authorID, function(newName) + namecache[authorID] = newName + PLUGIN.author = newName or PLUGIN.author + end) + end end end -end + nut.plugin.namecache = namecache +end \ No newline at end of file From 2b0b60b4f898da1ed2e27a780c29b6f8d06d8d23 Mon Sep 17 00:00:00 2001 From: TovarischPootis <54110479+TovarischPootis@users.noreply.github.com> Date: Thu, 1 Apr 2021 22:46:50 +0300 Subject: [PATCH 52/56] Made the logo of the ns logo in credits pulse a little --- plugins/f1menu/derma/cl_helps.lua | 2 +- plugins/nscredits.lua | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/f1menu/derma/cl_helps.lua b/plugins/f1menu/derma/cl_helps.lua index a9e0b4ee..978facac 100644 --- a/plugins/f1menu/derma/cl_helps.lua +++ b/plugins/f1menu/derma/cl_helps.lua @@ -167,7 +167,7 @@ hook.Add("BuildHelpMenu", "nutBasicHelp", function(tabs) %s: %s
%s: %s - ]]):format(v.name or "Unknown", L"desc", v.desc or L"noDesc", L"author", v.author) + ]]):format(v.name or "Unknown", L"desc", v.desc or L"noDesc", L"author", nut.plugin.namecache[v.author] or v.author) if (v.version) then body = body.."
"..L"version"..": "..v.version diff --git a/plugins/nscredits.lua b/plugins/nscredits.lua index abf8a404..4446d352 100644 --- a/plugins/nscredits.lua +++ b/plugins/nscredits.lua @@ -8,6 +8,7 @@ local ScrW, ScrH = ScrW(), ScrH() local logoMat = Material("nutscript/logo.png") local logoGlowMat = Material("nutscript/logo_glow.png") local textureID = surface.GetTextureID("models/effects/portalfunnel_sheet") +local sin = math.sin surface.CreateFont("nutSmallCredits", { font = "Roboto", size = 20, @@ -141,8 +142,10 @@ end function PANEL:Paint(w,h) surface.SetMaterial(logoGlowMat) + surface.SetDrawColor(255, 255, 255, 64*sin(CurTime())+191) surface.DrawTexturedRect((w/2)-128,(h/2)-128,256,256) surface.SetMaterial(logoMat) + surface.SetDrawColor(255, 255, 255, 255) surface.DrawTexturedRect((w/2)-128,(h/2)-128,256,256) end From ccdff98369f7691a050b7e508bbee417334f7dd5 Mon Sep 17 00:00:00 2001 From: Seamus McGowan <100soundsystem32@gmail.com> Date: Thu, 1 Apr 2021 21:50:42 +0100 Subject: [PATCH 53/56] Update plugins/scoreboard/derma/cl_scoreboard.lua Co-authored-by: TovarischPootis <54110479+TovarischPootis@users.noreply.github.com> --- plugins/scoreboard/derma/cl_scoreboard.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/scoreboard/derma/cl_scoreboard.lua b/plugins/scoreboard/derma/cl_scoreboard.lua index 795182b7..b14caa71 100644 --- a/plugins/scoreboard/derma/cl_scoreboard.lua +++ b/plugins/scoreboard/derma/cl_scoreboard.lua @@ -98,7 +98,7 @@ local PANEL = {} local faction = nut.faction.indices[k] if (amount != 0) then - v:SetVisible(hook.Run("HideFactionInScoreboard", faction) or LocalPlayer():IsAdmin()) + v:SetVisible(hook.Run("HideFactionInScoreboard", faction) ~= false or LocalPlayer():IsAdmin()) end end From 64f86478dce3df6c9eec23e13b61d695f62a6fa5 Mon Sep 17 00:00:00 2001 From: TovarischPootis <54110479+TovarischPootis@users.noreply.github.com> Date: Fri, 2 Apr 2021 00:19:59 +0300 Subject: [PATCH 54/56] Lead/Head, added discord invite button --- plugins/nscredits.lua | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/plugins/nscredits.lua b/plugins/nscredits.lua index 4446d352..a3fd08de 100644 --- a/plugins/nscredits.lua +++ b/plugins/nscredits.lua @@ -24,13 +24,14 @@ surface.CreateFont("nutBigCredits", { local authorCredits = { {desc = "Creator", steamid = "76561198030127257", color = Color(255, 0, 0)}, -- Chessnut {desc = "Co-Creator", steamid = "76561197999893894", color = Color(255, 0, 0)}, -- Black Tea - {desc = "Head Developer", steamid = "76561198060659964", color = Color(138,43,226)}, -- Zoephix - {desc = "Head Developer", steamid = "76561198070441753", color = Color(138,43,226)}, -- TovarischPootis + {desc = "Lead Developer", steamid = "76561198060659964", color = Color(138,43,226)}, -- Zoephix + {desc = "Lead Developer", steamid = "76561198070441753", color = Color(138,43,226)}, -- TovarischPootis {desc = "Developer", steamid = "76561198036551982", color = Color(34,139,34)}, -- Seamus {desc = "Developer", steamid = "76561198031437460", color = Color(34,139,34)}, -- Milk } local contributors = {desc = "View All Contributors", url = "https://github.com/NutScript/NutScript/graphs/contributors"} +local discord = {desc = "Join the NutScript Community Discord", url = "https://discord.gg/ySZY8TY"} local PANEL = {} @@ -103,6 +104,16 @@ function PANEL:Init() end self.contButton.Paint = function() end self.contButton:Dock(TOP) + + self.discordButton = self:Add("DButton") + self.discordButton:SetFont("nutBigCredits") + self.discordButton:SetText(discord.desc) + self.discordButton.DoClick = function() + surface.PlaySound("buttons/button14.wav") + gui.OpenURL(discord.url) + end + self.discordButton.Paint = function() end + self.discordButton:Dock(TOP) self:SizeToChildren(true, true) end From 0846cf9dd9b84a2aae03db073019095ba9ac874f Mon Sep 17 00:00:00 2001 From: Seamus McGowan <100soundsystem32@gmail.com> Date: Fri, 2 Apr 2021 08:12:04 +0100 Subject: [PATCH 55/56] Update plugins/scoreboard/derma/cl_scoreboard.lua Co-authored-by: TovarischPootis <54110479+TovarischPootis@users.noreply.github.com> --- plugins/scoreboard/derma/cl_scoreboard.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/scoreboard/derma/cl_scoreboard.lua b/plugins/scoreboard/derma/cl_scoreboard.lua index b14caa71..fd8a0e36 100644 --- a/plugins/scoreboard/derma/cl_scoreboard.lua +++ b/plugins/scoreboard/derma/cl_scoreboard.lua @@ -98,7 +98,7 @@ local PANEL = {} local faction = nut.faction.indices[k] if (amount != 0) then - v:SetVisible(hook.Run("HideFactionInScoreboard", faction) ~= false or LocalPlayer():IsAdmin()) + v:SetVisible(hook.Run("ShowFactionInScoreboard", faction) ~= false or LocalPlayer():IsAdmin()) end end From 34b6e9b90418a73f9c033d898af6abc9e92c1f82 Mon Sep 17 00:00:00 2001 From: TovarischPootis <54110479+TovarischPootis@users.noreply.github.com> Date: Fri, 2 Apr 2021 18:30:34 +0300 Subject: [PATCH 56/56] Resolve conflict because the commit was done to the 1.2 branch, not 1.2-wip --- gamemode/core/libs/sh_chatbox.lua | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/gamemode/core/libs/sh_chatbox.lua b/gamemode/core/libs/sh_chatbox.lua index fe62a402..1138303f 100644 --- a/gamemode/core/libs/sh_chatbox.lua +++ b/gamemode/core/libs/sh_chatbox.lua @@ -263,14 +263,14 @@ do else local delay = nut.config.get("oocDelay", 10) - -- Admin delay bypass - if (speaker:IsAdmin() and nut.config.get("oocDelayAdmin", false)) then - -- Only need to check the time if they have spoken in OOC chat before. - if (delay > 0 and speaker.nutLastOOC) then - local lastOOC = CurTime() - speaker.nutLastOOC - - -- Use this method of checking time in case the oocDelay config changes. - if (lastOOC <= delay) then + -- Only need to check the time if they have spoken in OOC chat before. + if (delay > 0 and speaker.nutLastOOC) then + local lastOOC = CurTime() - speaker.nutLastOOC + + -- Use this method of checking time in case the oocDelay config changes. + if (lastOOC <= delay) then + -- Admin delay bypass + if (!speaker:IsAdmin() or speaker:IsAdmin() and nut.config.get("oocDelayAdmin", false)) then speaker:notifyLocalized("oocDelay", delay - math.ceil(lastOOC)) return false @@ -321,17 +321,19 @@ do onCanSay = function(speaker, text) local delay = nut.config.get("loocDelay", 0) - -- Admin delay bypass + -- Only need to check the time if they have spoken in LOOC chat before. if (speaker:IsAdmin() and nut.config.get("loocDelayAdmin", false)) then - -- Only need to check the time if they have spoken in OOC chat before. if (delay > 0 and speaker.nutLastLOOC) then local lastLOOC = CurTime() - speaker.nutLastLOOC -- Use this method of checking time in case the oocDelay config changes. if (lastLOOC <= delay) then - speaker:notifyLocalized("loocDelay", delay - math.ceil(lastLOOC)) + -- Admin delay bypass + if (!speaker:IsAdmin() or speaker:IsAdmin() and nut.config.get("oocDelayAdmin", false)) then + speaker:notifyLocalized("oocDelay", delay - math.ceil(lastOOC)) - return false + return false + end end end end