From b8c4eaa63f982a552ed02414acf0c49037656613 Mon Sep 17 00:00:00 2001 From: AlmTech Date: Wed, 11 Sep 2019 19:37:27 +0200 Subject: [PATCH] Added character system ( BASE ) --- gamemode/core/server/sv_player_character.lua | 49 ++++++++++++++++++++ gamemode/core/server/sv_player_init.lua | 2 + gamemode/settings/sv_settings.lua | 4 ++ 3 files changed, 55 insertions(+) create mode 100644 gamemode/core/server/sv_player_character.lua diff --git a/gamemode/core/server/sv_player_character.lua b/gamemode/core/server/sv_player_character.lua new file mode 100644 index 0000000..e305954 --- /dev/null +++ b/gamemode/core/server/sv_player_character.lua @@ -0,0 +1,49 @@ +-- __ _ _______ _ __ +-- / / /\ | | |__ __| | | \ \ +-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \ +-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > > +-- \ \ / ____ \| | | | | | | | __/ (__| | | | / / +-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ + +Quantum.Server.Char = {} +Quantum.Server.Char.Players = {} + +function Quantum.Server.Char.CreateCharTable( args ) + return { + name = args.name || "UNKNOWN", + model = args.model || "models/player.mdl", + money = args.money || Quantum.Server.Settings.StarterMoney, + jobs = args.jobs || { + [1] = { title = "Hobo", level = -1 }, + }, + skills = args.skills || { + crafting = 0, + cooking = 0, + combat = 0, + science = 0 + }, + } +end + +function Quantum.Server.Char.Create( pl, index, tbl ) + local id = pl:SteamID() .. ":" .. index + if( Quantum.Server.Char.Players[ id ] ~= nil ) then + Quantum.Server.Char.Players[ id ] = tbl + Quantum.Debug( "Created character (" .. id .. ")" ) + else + Quantum.Error( "Tried to duplicate character! Index already used. (" .. id .. ")" ) + end +end + +function Quantum.Server.Char.Remove( pl, index ) + local id = pl:SteamID() .. ":" .. index + if( Quantum.Server.Char.Players[id] ~= nil ) then + Quantum.Server.Char.Players[id] = nil + Quantum.Debug( "Removed character (" .. id .. ")" ) + end +end + +function Quantum.Server.Char.GetCurrentCharacter( pl ) + if( pl.character == nil ) then Quantum.Error( tostring( pl ) .. " doesn't have a character! Unable to get current character table." ) end + return pl.character +end \ No newline at end of file diff --git a/gamemode/core/server/sv_player_init.lua b/gamemode/core/server/sv_player_init.lua index 01eec40..2952f17 100644 --- a/gamemode/core/server/sv_player_init.lua +++ b/gamemode/core/server/sv_player_init.lua @@ -5,6 +5,8 @@ -- \ \ / ____ \| | | | | | | | __/ (__| | | | / / -- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ +Quantum.Server.Player = {} + local ply = FindMetaTable( "Player" ) function GM:PlayerInitialSpawn( ply ) diff --git a/gamemode/settings/sv_settings.lua b/gamemode/settings/sv_settings.lua index 8a2b1b6..6cdd4ea 100644 --- a/gamemode/settings/sv_settings.lua +++ b/gamemode/settings/sv_settings.lua @@ -9,6 +9,10 @@ Quantum.Server.Settings.VoiceChatRange = 400 +Quantum.Server.Settings.MaxJobLevel = 250 +Quantum.Server.Settings.MaxJobSlots = 2 +Quantum.Server.Settings.MaxSkillLevel = 100 + Quantum.Server.Settings.SpawnLocations = { ["rp_truenorth_v1a_livin"] = {