Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
4 changes: 1 addition & 3 deletions gamemode/cl_init.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
DeriveGamemode("nutscript");

nut.schema.Init();
DeriveGamemode("nutscript");
4 changes: 2 additions & 2 deletions gamemode/init.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
DeriveGamemode("nutscript");
AddCSLuaFile("cl_init.lua");

nut.schema.Init();
DeriveGamemode("nutscript");
27 changes: 0 additions & 27 deletions gamemode/schema/classes/sh_cp_recruit.lua

This file was deleted.

3 changes: 0 additions & 3 deletions gamemode/schema/items/sh_brick.lua

This file was deleted.

3 changes: 0 additions & 3 deletions gamemode/schema/items/sh_cid.lua

This file was deleted.

11 changes: 0 additions & 11 deletions gamemode/schema/sh_schema.lua

This file was deleted.

25 changes: 0 additions & 25 deletions gamemode/schema/sv_hooks.lua

This file was deleted.

8 changes: 4 additions & 4 deletions plugins/sh_helloworld.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
2 changes: 1 addition & 1 deletion sample.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
{
"base" "nutscript"
"title" "Sample"
"author" "Chessnut"
"author" "Casadis"
"menusystem" "1"
}
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -1,24 +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.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

-- Return what the name will be set for character creation.
function FACTION:GetDefaultName()
return "CP-RCT."..math.random(11111, 99999)
end
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;
28 changes: 28 additions & 0 deletions schema/hooks/sv_hooks.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
print("sv_hooks");

--[[
-- 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.

if (data.faction == FACTION_CITIZEN) then
inventory:Add("cid", 1, {
Digits = math.random(11111, 99999),
Owner = data.charname
})
end
end

-- 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

--]]
3 changes: 3 additions & 0 deletions schema/items/sh_brick.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ITEM.name = "Brick";
ITEM.model = "models/props_junk/CinderBlock01a.mdl";
ITEM.desc = "A grey cinderblock.";
3 changes: 3 additions & 0 deletions schema/items/sh_cid.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ITEM.name = "Citizen ID";
ITEM.model = "models/gibs/metal_gib4.mdl";
ITEM.desc = "An ID card.";
2 changes: 2 additions & 0 deletions schema/languages/sh_english.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
LANGUAGE = {
};
5 changes: 5 additions & 0 deletions schema/sh_config.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
nut.config.language = "english";

nut.currency.symbol = "";
nut.currency.singular = "dollar";
nut.currency.plural = "dollars";
9 changes: 9 additions & 0 deletions schema/sh_schema.lua
Original file line number Diff line number Diff line change
@@ -0,0 +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.
-- Using a uniqueID will allow for renaming the schema folder.

nut.util.include("sh_config.lua");

nut.util.includeDir("hooks");
22 changes: 22 additions & 0 deletions schema/sv_database.lua
Original file line number Diff line number Diff line change
@@ -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

*/