From 53cbb8398448ad3456369ced16f61761b9366d67 Mon Sep 17 00:00:00 2001 From: GeorgeButler Date: Fri, 9 Sep 2016 10:26:37 -0700 Subject: [PATCH 1/3] Modified to work with Nutscript 1.1 --- README.md | 4 ++-- gamemode/cl_init.lua | 4 +--- gamemode/init.lua | 5 ++--- {gamemode/schema => schema}/classes/sh_cp_recruit.lua | 0 {gamemode/schema => schema}/factions/sh_citizen.lua | 0 {gamemode/schema => schema}/factions/sh_metrocop.lua | 4 +--- {gamemode/schema => schema/hooks}/sv_hooks.lua | 0 {gamemode/schema => schema}/items/sh_brick.lua | 0 {gamemode/schema => schema}/items/sh_cid.lua | 0 {gamemode/schema => schema}/sh_schema.lua | 4 ++-- 10 files changed, 8 insertions(+), 13 deletions(-) rename {gamemode/schema => schema}/classes/sh_cp_recruit.lua (100%) rename {gamemode/schema => schema}/factions/sh_citizen.lua (100%) rename {gamemode/schema => schema}/factions/sh_metrocop.lua (86%) rename {gamemode/schema => schema/hooks}/sv_hooks.lua (100%) rename {gamemode/schema => schema}/items/sh_brick.lua (100%) rename {gamemode/schema => schema}/items/sh_cid.lua (100%) rename {gamemode/schema => schema}/sh_schema.lua (85%) diff --git a/README.md b/README.md index 769f378..68c27b8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Example Schema +Example Schema (NS 1.1) ============= -This is an example schema that should show the basics of how schemas are made with NutScript. Simply make a folder called 'sample' in the gamemodes/ folder with 'nutscript' and add this to your server's startup line: +gamemode sample +This is an example schema that should show the basics of how schemas are made with NutScript 1.1. Simply make a folder called 'sample' in the gamemodes/ folder with 'nutscript' and add this to your server's startup line: +gamemode sample diff --git a/gamemode/cl_init.lua b/gamemode/cl_init.lua index 7cd3319..4df9764 100644 --- a/gamemode/cl_init.lua +++ b/gamemode/cl_init.lua @@ -1,3 +1 @@ -DeriveGamemode("nutscript"); - -nut.schema.Init(); \ No newline at end of file +DeriveGamemode("nutscript") \ No newline at end of file diff --git a/gamemode/init.lua b/gamemode/init.lua index 7cd3319..641f727 100644 --- a/gamemode/init.lua +++ b/gamemode/init.lua @@ -1,3 +1,2 @@ -DeriveGamemode("nutscript"); - -nut.schema.Init(); \ No newline at end of file +AddCSLuaFile("cl_init.lua") +DeriveGamemode("nutscript") \ No newline at end of file diff --git a/gamemode/schema/classes/sh_cp_recruit.lua b/schema/classes/sh_cp_recruit.lua similarity index 100% rename from gamemode/schema/classes/sh_cp_recruit.lua rename to schema/classes/sh_cp_recruit.lua diff --git a/gamemode/schema/factions/sh_citizen.lua b/schema/factions/sh_citizen.lua similarity index 100% rename from gamemode/schema/factions/sh_citizen.lua rename to schema/factions/sh_citizen.lua diff --git a/gamemode/schema/factions/sh_metrocop.lua b/schema/factions/sh_metrocop.lua similarity index 86% rename from gamemode/schema/factions/sh_metrocop.lua rename to schema/factions/sh_metrocop.lua index b71cfee..ceb341e 100644 --- a/gamemode/schema/factions/sh_metrocop.lua +++ b/schema/factions/sh_metrocop.lua @@ -6,11 +6,9 @@ FACTION.desc = "Citizens who joined the Combine as a policing force." -- name color in OOC chat. FACTION.color = Color(70, 70, 220) -- Set the male model choices for character creation. -FACTION.maleModels = { +FACTION.models = { "models/police.mdl" } --- Set the female models to be the same as male models. -FACTION.femaleModels = FACTION.maleModels -- Set it so the faction requires a whitelist. FACTION.isDefault = false diff --git a/gamemode/schema/sv_hooks.lua b/schema/hooks/sv_hooks.lua similarity index 100% rename from gamemode/schema/sv_hooks.lua rename to schema/hooks/sv_hooks.lua diff --git a/gamemode/schema/items/sh_brick.lua b/schema/items/sh_brick.lua similarity index 100% rename from gamemode/schema/items/sh_brick.lua rename to schema/items/sh_brick.lua diff --git a/gamemode/schema/items/sh_cid.lua b/schema/items/sh_cid.lua similarity index 100% rename from gamemode/schema/items/sh_cid.lua rename to schema/items/sh_cid.lua diff --git a/gamemode/schema/sh_schema.lua b/schema/sh_schema.lua similarity index 85% rename from gamemode/schema/sh_schema.lua rename to schema/sh_schema.lua index 8f538e9..b8aaeb5 100644 --- a/gamemode/schema/sh_schema.lua +++ b/schema/sh_schema.lua @@ -5,7 +5,7 @@ SCHEMA.uniqueID = "sample" -- Schema will be a unique identifier stored in the d -- Using a uniqueID will allow for renaming the schema folder. -- Configure some stuff specific to this schema. -nut.currency.SetUp("bean", "beans") +nut.currency.set("", "bean", "beans") nut.config.menuMusic = "http://7609.live.streamtheworld.com:80/977_SMOOJAZZ_SC" -nut.util.Include("sv_hooks.lua") \ No newline at end of file +nut.util.includeDir("hooks") \ No newline at end of file From 939d83720b90a4fc72af9920b21a92877ad5123c Mon Sep 17 00:00:00 2001 From: George Date: Sun, 1 Oct 2017 13:17:35 -0700 Subject: [PATCH 2/3] Fixes for NS 1.1 Fixed a variety of errors, and organized files. --- sample.txt | 2 +- schema/classes/sh_cp_recruit.lua | 27 --------------------------- schema/factions/sh_metrocop.lua | 5 ----- schema/hooks/sv_hooks.lua | 21 +++++++++++---------- schema/languages/sh_english.lua | 2 ++ schema/sh_config.lua | 5 +++++ schema/sh_schema.lua | 6 ++---- schema/sv_database.lua | 22 ++++++++++++++++++++++ 8 files changed, 43 insertions(+), 47 deletions(-) delete mode 100644 schema/classes/sh_cp_recruit.lua create mode 100644 schema/languages/sh_english.lua create mode 100644 schema/sh_config.lua create mode 100644 schema/sv_database.lua diff --git a/sample.txt b/sample.txt index 053946e..7bbb745 100644 --- a/sample.txt +++ b/sample.txt @@ -2,6 +2,6 @@ { "base" "nutscript" "title" "Sample" - "author" "Chessnut" + "author" "Casadis" "menusystem" "1" } \ No newline at end of file diff --git a/schema/classes/sh_cp_recruit.lua b/schema/classes/sh_cp_recruit.lua deleted file mode 100644 index 3024f2a..0000000 --- a/schema/classes/sh_cp_recruit.lua +++ /dev/null @@ -1,27 +0,0 @@ --- Set the 'nice' display name for the class. -CLASS.name = "Metrocop Recruit" --- Set the faction that the class belongs to. -CLASS.faction = FACTION_CP - --- Set what happens when the player has been switched to this class. --- It passes the player which just switched. -function CLASS:OnSet(client) - client:SetModel("models/Barney.mdl") -end - --- CLASS.index is defined internall when the class is registered. --- It is basically the class's numeric ID. --- We set a global variable to save this index for easier reference. -CLASS_CP_RCT = CLASS.index - -if (SERVER) then - -- Hook the 'charname' variable to change the class of a playing if the character's name - -- contains '.RCT' inside. - nut.char.HookVar("charname", "recruitRanks", function(character) - local client = character.player - - if (IsValid(client) and client:Team() == FACTION_CP and string.find(character:GetVar("charname"), "RCT.")) then - client:SetCharClass(CLASS_CP_RCT) - end - end) -end diff --git a/schema/factions/sh_metrocop.lua b/schema/factions/sh_metrocop.lua index ceb341e..d3a3124 100644 --- a/schema/factions/sh_metrocop.lua +++ b/schema/factions/sh_metrocop.lua @@ -12,11 +12,6 @@ FACTION.models = { -- Set it so the faction requires a whitelist. FACTION.isDefault = false --- Return what the name will be set for character creation. -function FACTION:GetDefaultName() - return "CP-RCT."..math.random(11111, 99999) -end - -- FACTION.index is defined when the faction is registered and is just a numeric ID. -- Here, we create a global variable for easier reference to the ID. FACTION_CP = FACTION.index diff --git a/schema/hooks/sv_hooks.lua b/schema/hooks/sv_hooks.lua index eb57811..8c76e33 100644 --- a/schema/hooks/sv_hooks.lua +++ b/schema/hooks/sv_hooks.lua @@ -1,11 +1,11 @@ --[[ - Purpose: Called to allow items to be added to a character during - character creation. The inventory table is passed which contains - an inventory:Add(uniqueID, quantity, data) method which is similar - to client:UpdateInv(), the player who created the character is passed - as the 2nd argument, and the character creation data is passed as the - 3rd argument. ---]] + -- Purpose: Called to allow items to be added to a character during + -- character creation. The inventory table is passed which contains + -- an inventory:Add(uniqueID, quantity, data) method which is similar + -- to client:UpdateInv(), the player who created the character is passed + -- as the 2nd argument, and the character creation data is passed as the + -- 3rd argument. + function SCHEMA:GetDefaultInv(inventory, client, data) -- PrintTable(data) to see what information it contains. @@ -17,9 +17,10 @@ function SCHEMA:GetDefaultInv(inventory, client, data) end end ---[[ - Purpose: Called when the player has spawned with a valid character. ---]] +-- Purpose: Called when the player has spawned with a valid character. + function SCHEMA:PlayerSpawn(client) print("Just like regular gamemodes, except we replace GM with SCHEMA.") end + +--]] diff --git a/schema/languages/sh_english.lua b/schema/languages/sh_english.lua new file mode 100644 index 0000000..d41ce6e --- /dev/null +++ b/schema/languages/sh_english.lua @@ -0,0 +1,2 @@ +LANGUAGE = { +} \ No newline at end of file diff --git a/schema/sh_config.lua b/schema/sh_config.lua new file mode 100644 index 0000000..afcfbaa --- /dev/null +++ b/schema/sh_config.lua @@ -0,0 +1,5 @@ +nut.config.language = "english"; + +nut.currency.symbol = ""; +nut.currency.singular = "bean"; +nut.currency.plural = "beans"; \ No newline at end of file diff --git a/schema/sh_schema.lua b/schema/sh_schema.lua index b8aaeb5..e3b069b 100644 --- a/schema/sh_schema.lua +++ b/schema/sh_schema.lua @@ -1,11 +1,9 @@ SCHEMA.name = "Sample" -SCHEMA.author = "Chessnut" +SCHEMA.author = "Casadis" SCHEMA.desc = "An example schema that is very basic." SCHEMA.uniqueID = "sample" -- Schema will be a unique identifier stored in the database. -- Using a uniqueID will allow for renaming the schema folder. --- Configure some stuff specific to this schema. -nut.currency.set("", "bean", "beans") -nut.config.menuMusic = "http://7609.live.streamtheworld.com:80/977_SMOOJAZZ_SC" +nut.util.include("sh_config.lua"); nut.util.includeDir("hooks") \ No newline at end of file diff --git a/schema/sv_database.lua b/schema/sv_database.lua new file mode 100644 index 0000000..d330b30 --- /dev/null +++ b/schema/sv_database.lua @@ -0,0 +1,22 @@ +GM = GM or GAMEMODE; + +/* + +-- If you want to use external storage. + +function GM:SetupDatabase() + -- Which method of storage: sqlite, tmysql4, mysqloo + nut.db.module = "mysqloo" + -- 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 = "AAAAAAAAAAAA" + -- 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 From 5db42889adc52c50a96c64b7ad1e76302076d71b Mon Sep 17 00:00:00 2001 From: George Date: Sat, 7 Oct 2017 09:48:54 -0700 Subject: [PATCH 3/3] Fixes Fixes a variety of consistency issues and small bugs. --- gamemode/cl_init.lua | 2 +- gamemode/init.lua | 5 +++-- plugins/sh_helloworld.lua | 8 ++++---- schema/factions/sh_citizen.lua | 8 ++++---- schema/factions/sh_metrocop.lua | 12 ++++++------ schema/hooks/sv_hooks.lua | 2 ++ schema/items/sh_brick.lua | 6 +++--- schema/items/sh_cid.lua | 6 +++--- schema/languages/sh_english.lua | 2 +- schema/sh_config.lua | 4 ++-- schema/sh_schema.lua | 10 +++++----- 11 files changed, 34 insertions(+), 31 deletions(-) diff --git a/gamemode/cl_init.lua b/gamemode/cl_init.lua index 4df9764..d3f2c2a 100644 --- a/gamemode/cl_init.lua +++ b/gamemode/cl_init.lua @@ -1 +1 @@ -DeriveGamemode("nutscript") \ No newline at end of file +DeriveGamemode("nutscript"); \ No newline at end of file diff --git a/gamemode/init.lua b/gamemode/init.lua index 641f727..3c62356 100644 --- a/gamemode/init.lua +++ b/gamemode/init.lua @@ -1,2 +1,3 @@ -AddCSLuaFile("cl_init.lua") -DeriveGamemode("nutscript") \ No newline at end of file +AddCSLuaFile("cl_init.lua"); + +DeriveGamemode("nutscript"); \ No newline at end of file diff --git a/plugins/sh_helloworld.lua b/plugins/sh_helloworld.lua index fcc6f40..dbd52c9 100644 --- a/plugins/sh_helloworld.lua +++ b/plugins/sh_helloworld.lua @@ -23,13 +23,13 @@ --]] -- We define a clean plugin name that will be displayed on a list of loaded plugins. -PLUGIN.name = "Hello World" +PLUGIN.name = "Hello World"; -- The author of the plugin will show up under the title. -PLUGIN.author = "Chessnut" +PLUGIN.author = "Chessnut"; -- In addition, we also add the description to have people know what it does. -PLUGIN.desc = "Welcomes players to the server with a greeting." +PLUGIN.desc = "Welcomes players to the server with a greeting."; --[[ As you can see below, we have a hook. Just like we would define hooks in a gamemode or entity, @@ -38,5 +38,5 @@ PLUGIN.desc = "Welcomes players to the server with a greeting." schema/framework. --]] function PLUGIN:PlayerSpawn(client) - client:ChatPrint("Hello "..client:Name().."!") + client:ChatPrint("Hello " .. client:Name() .. "!"); end \ No newline at end of file diff --git a/schema/factions/sh_citizen.lua b/schema/factions/sh_citizen.lua index 1d96b10..1c2b151 100644 --- a/schema/factions/sh_citizen.lua +++ b/schema/factions/sh_citizen.lua @@ -1,11 +1,11 @@ -- The 'nice' name of the faction. -FACTION.name = "Citizen" +FACTION.name = "Citizen"; -- A description used in tooltips in various menus. -FACTION.desc = "The civilian faction that wears blue clothes." +FACTION.desc = "The civilian faction that wears blue clothes."; -- A color to distinguish factions from others, used for stuff such as -- name color in OOC chat. -FACTION.color = Color(20, 150, 15) +FACTION.color = Color(20, 150, 15); -- FACTION.index is defined when the faction is registered and is just a numeric ID. -- Here, we create a global variable for easier reference to the ID. -FACTION_CITIZEN = FACTION.index +FACTION_CITIZEN = FACTION.index; diff --git a/schema/factions/sh_metrocop.lua b/schema/factions/sh_metrocop.lua index d3a3124..ad54b1f 100644 --- a/schema/factions/sh_metrocop.lua +++ b/schema/factions/sh_metrocop.lua @@ -1,17 +1,17 @@ -- The 'nice' name of the faction. -FACTION.name = "Civil Protection" +FACTION.name = "Civil Protection"; -- A description used in tooltips in various menus. -FACTION.desc = "Citizens who joined the Combine as a policing force." +FACTION.desc = "Citizens who joined the Combine as a policing force."; -- A color to distinguish factions from others, used for stuff such as -- name color in OOC chat. -FACTION.color = Color(70, 70, 220) +FACTION.color = Color(70, 70, 220); -- Set the male model choices for character creation. FACTION.models = { "models/police.mdl" -} +}; -- Set it so the faction requires a whitelist. -FACTION.isDefault = false +FACTION.isDefault = false; -- FACTION.index is defined when the faction is registered and is just a numeric ID. -- Here, we create a global variable for easier reference to the ID. -FACTION_CP = FACTION.index +FACTION_CP = FACTION.index; diff --git a/schema/hooks/sv_hooks.lua b/schema/hooks/sv_hooks.lua index 8c76e33..6f971b8 100644 --- a/schema/hooks/sv_hooks.lua +++ b/schema/hooks/sv_hooks.lua @@ -1,3 +1,5 @@ +print("sv_hooks"); + --[[ -- Purpose: Called to allow items to be added to a character during -- character creation. The inventory table is passed which contains diff --git a/schema/items/sh_brick.lua b/schema/items/sh_brick.lua index 2cc9e58..715bbdf 100644 --- a/schema/items/sh_brick.lua +++ b/schema/items/sh_brick.lua @@ -1,3 +1,3 @@ -ITEM.name = "Brick" -ITEM.model = Model("models/props_junk/CinderBlock01a.mdl") -ITEM.desc = "My friend is %Friend|no one%." +ITEM.name = "Brick"; +ITEM.model = "models/props_junk/CinderBlock01a.mdl"; +ITEM.desc = "A grey cinderblock."; diff --git a/schema/items/sh_cid.lua b/schema/items/sh_cid.lua index 3123de7..3ddf20c 100644 --- a/schema/items/sh_cid.lua +++ b/schema/items/sh_cid.lua @@ -1,3 +1,3 @@ -ITEM.name = "Citizen ID" -ITEM.model = Model("models/gibs/metal_gib4.mdl") -ITEM.desc = "An ID cards with the digits %Digits|00000% assigned to %Owner|no one%." +ITEM.name = "Citizen ID"; +ITEM.model = "models/gibs/metal_gib4.mdl"; +ITEM.desc = "An ID card."; diff --git a/schema/languages/sh_english.lua b/schema/languages/sh_english.lua index d41ce6e..6c28f57 100644 --- a/schema/languages/sh_english.lua +++ b/schema/languages/sh_english.lua @@ -1,2 +1,2 @@ LANGUAGE = { -} \ No newline at end of file +}; \ No newline at end of file diff --git a/schema/sh_config.lua b/schema/sh_config.lua index afcfbaa..a66d2f1 100644 --- a/schema/sh_config.lua +++ b/schema/sh_config.lua @@ -1,5 +1,5 @@ nut.config.language = "english"; nut.currency.symbol = ""; -nut.currency.singular = "bean"; -nut.currency.plural = "beans"; \ No newline at end of file +nut.currency.singular = "dollar"; +nut.currency.plural = "dollars"; \ No newline at end of file diff --git a/schema/sh_schema.lua b/schema/sh_schema.lua index e3b069b..0573caf 100644 --- a/schema/sh_schema.lua +++ b/schema/sh_schema.lua @@ -1,9 +1,9 @@ -SCHEMA.name = "Sample" -SCHEMA.author = "Casadis" -SCHEMA.desc = "An example schema that is very basic." -SCHEMA.uniqueID = "sample" -- Schema will be a unique identifier stored in the database. +SCHEMA.name = "Sample"; +SCHEMA.author = "Casadis"; +SCHEMA.desc = "An example schema that is very basic."; +SCHEMA.uniqueID = "sample"; -- Schema will be a unique identifier stored in the database. -- Using a uniqueID will allow for renaming the schema folder. nut.util.include("sh_config.lua"); -nut.util.includeDir("hooks") \ No newline at end of file +nut.util.includeDir("hooks"); \ No newline at end of file