From e676c86f22c2634856d71fcc2680175d2f004d13 Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Mon, 2 May 2016 19:01:36 -0400 Subject: Fixed chat command parseing to work with quotes and spaces --- gamemode/chatcommands.lua | 28 +++++++++++++++++++++++++++- gamemode/server/database.lua | 1 + 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 gamemode/server/database.lua diff --git a/gamemode/chatcommands.lua b/gamemode/chatcommands.lua index 9989054..39260a3 100644 --- a/gamemode/chatcommands.lua +++ b/gamemode/chatcommands.lua @@ -1,6 +1,32 @@ function GM:PlayerSay( ply, text, teamonly ) - local args = string.Explode( " ", text ) + local args = {} + args[1] = "" + local parsestring = string.ToTable(text) + local inquote = false + local argpart = 1 + print("Parseing: " .. text) + for k,v in pairs(parsestring) do + print("at " .. k .. ":" .. v) + if(v == " ") then + print("Hit delimiter") + if(inquote) then + args[argpart] = args[argpart] .. v + else + argpart = argpart + 1 + args[argpart] = "" + end + elseif(v == "\"") then + print("Hit quote") + inquote = !inquote + else + print("Adding to string") + args[argpart] = args[argpart] .. v + end + end + print("Finished, args:") + PrintTable(args) + --local args = string.Explode( " ", text ) if ( args == nil ) then args = {} end if ( teamonly ) then diff --git a/gamemode/server/database.lua b/gamemode/server/database.lua new file mode 100644 index 0000000..5ebce8e --- /dev/null +++ b/gamemode/server/database.lua @@ -0,0 +1 @@ +--Provides an interface to store data in a database of some kind -- cgit v1.2.3-70-g09d2