diff options
Diffstat (limited to 'gamemode/server')
| -rw-r--r-- | gamemode/server/sv_config.lua | 1 | ||||
| -rw-r--r-- | gamemode/server/sv_database.lua | 29 | ||||
| -rw-r--r-- | gamemode/server/sv_loadplayer.lua | 3 |
3 files changed, 14 insertions, 19 deletions
diff --git a/gamemode/server/sv_config.lua b/gamemode/server/sv_config.lua index 918f196..cb365a6 100644 --- a/gamemode/server/sv_config.lua +++ b/gamemode/server/sv_config.lua @@ -6,6 +6,7 @@ ART.defaults = {} ART.defaults.starting_inventory = '{"Backpacks":[[[[false,false,false,false,false],[false,false,false,false,false],[false,false,false,false,false],[false,false,false,false,false],[false,false,false,false,false]],[5,5],"Rucksack"]],"Equiped":{"Gloves":false,"Left":false,"Head":false,"Legs":false,"Right":false,"Body":false,"Boots":false}}' ART.defaults.starting_skills = "[]" ART.defaults.starting_quests = "[]" +ART.defaults.starting_prayers = "[]" ART.defaults.starting_position = "185 310 524" ART.defaults.starting_world = "0.0.0.0:27015" diff --git a/gamemode/server/sv_database.lua b/gamemode/server/sv_database.lua index 357d868..55c5346 100644 --- a/gamemode/server/sv_database.lua +++ b/gamemode/server/sv_database.lua @@ -4,9 +4,9 @@ require("mysqloo") local createplayerquery local createplayerprepare = [[ -INSERT INTO playerdata (`SteamID`, `PlayerName`,`Inventory`, `Skills`,`Quests`,`WorldPosition`,`World`) VALUES(?, ?, ?, ?, ?, ?, ?)]] +INSERT INTO playerdata (`SteamID`, `PlayerName`,`Inventory`, `Skills`,`Quests`, `Prayers`,`WorldPosition`,`World`) VALUES(?, ?, ?, ?, ?, ?, ?, ?)]] local createtablequery = [[ -create table if not exists playerdata(SteamID bigint primary key, PlayerName text, Inventory json, Skills json, Quests json, WorldPosition text, World text)]] +create table if not exists playerdata(SteamID bigint primary key, PlayerName text, Inventory json, Skills json, Quests json, Prayers json, WorldPosition text, World text)]] local function connectToDatabase() if ART.database ~= nil then return end @@ -72,8 +72,9 @@ local function loadQueries() createplayerquery:setString(3,ART.defaults.starting_inventory) createplayerquery:setString(4,ART.defaults.starting_skills) createplayerquery:setString(5,ART.defaults.starting_quests) - createplayerquery:setString(6,ART.defaults.starting_position) - createplayerquery:setString(7,ART.defaults.starting_world) + createplayerquery:setString(6,ART.defaults.starting_prayers) + createplayerquery:setString(7,ART.defaults.starting_position) + createplayerquery:setString(8,ART.defaults.starting_world) function createplayerquery:onSuccess(data) print("Created player entry successfully!") end @@ -91,7 +92,7 @@ function ART.loadPlayerData(ply) local steamid = ply:SteamID64() local db = ART.database local q = db:query([[ -select Inventory, Skills, Quests, WorldPosition, World from playerdata where SteamID="]] .. steamid .. "\"") +select Inventory, Skills, Quests, Prayers, WorldPosition, World from playerdata where SteamID="]] .. steamid .. "\"") function q:onSuccess(data) if #data == 0 then --Player does not have an entry, make one! print("Player does not have entry!") @@ -127,9 +128,15 @@ select Inventory, Skills, Quests, WorldPosition, World from playerdata where Ste return end --Otherwise, we're in the right world, load our data + print("Loading inventory...") ply:LoadInventory(inv) + print("Loading skills...") ply.Skills = util.JSONToTable(data[1].Skills) + print("Loading quests...") ply.Quests = util.JSONToTable(data[1].Quests) + print("Loading prayers...") + ply.Prayers = util.JSONToTable(data[1].Prayers) + print("Loading player's worldpos") local postbl = string.Explode(" ", worldpos) local posvec = Vector(postbl[1],postbl[2],postbl[3]) print("Setting player pos to:") @@ -145,15 +152,3 @@ select Inventory, Skills, Quests, WorldPosition, World from playerdata where Ste end q:start() end - ---A randomly assigned model based on a player's UniqueID, so it should always stay the same. - ---[[ -hook.Add("PlayerInitialSpawn","ArteryPlayerInit",function(ply) - local modelnum = ply:UniqueID() % (#models) - print("Setting player model") - ply:SetModel(models[modelnum]) - print("Loading data") - ART.loadPlayerData(ply) -end) -]] diff --git a/gamemode/server/sv_loadplayer.lua b/gamemode/server/sv_loadplayer.lua index cfbc265..86673a7 100644 --- a/gamemode/server/sv_loadplayer.lua +++ b/gamemode/server/sv_loadplayer.lua @@ -17,11 +17,10 @@ end hook.Add("PlayerInitialSpawn","ArteryPlayerLoad",function(pl) local modelnum = pl:UniqueID() % (#models) - timer.Simple(5,function() + timer.Simple(1,function() delayplayerload(pl) end) pl:SetModel(models[modelnum]) - --pl:Give("weapon_pistol") pl:Give("hands") pl:SelectWeapon("hands") end) |
