diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2016-05-02 19:01:36 -0400 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2016-05-02 19:01:36 -0400 |
| commit | e676c86f22c2634856d71fcc2680175d2f004d13 (patch) | |
| tree | e8e5ace85e78cd1b3b0a4d2cba9cc286fb437e49 /gamemode | |
| parent | dc0cbf255e975c1b6df796f511194a0321e43e1d (diff) | |
| download | gmstranded-e676c86f22c2634856d71fcc2680175d2f004d13.tar.gz gmstranded-e676c86f22c2634856d71fcc2680175d2f004d13.tar.bz2 gmstranded-e676c86f22c2634856d71fcc2680175d2f004d13.zip | |
Fixed chat command parseing to work with quotes and spaces
Diffstat (limited to 'gamemode')
| -rw-r--r-- | gamemode/chatcommands.lua | 28 | ||||
| -rw-r--r-- | gamemode/server/database.lua | 1 |
2 files changed, 28 insertions, 1 deletions
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 |
