diff --git a/bin/README.txt b/bin/README.txt
deleted file mode 100644
index 9b54097..0000000
--- a/bin/README.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-CitizenMP.Server.exe in bin/ is no longer use.
-
-Please run the executable from the root directory.
\ No newline at end of file
diff --git a/citmp-server.yml b/citmp-server.yml
deleted file mode 100644
index 4ce6080..0000000
--- a/citmp-server.yml
+++ /dev/null
@@ -1,38 +0,0 @@
-ListenPort: 30120
-
-PreParseResources:
- - mapmanager
-
-AutoStartResources:
- - chat
- - spawnmanager
- - fivem-map-skater
- - baseevents
- - rconlog
- - hardcap # prevents the game from breaking
- - scoreboard
-
-# do change
-RconPassword: lovely
-
-# configure this, please
-Hostname: default FiveM server
-
-ScriptDebug: true
-
-DebugLog: true
-
-# set to false to hide from the online server list
-Announce: true
-
-# set to false to require players to be signed in to Steam
-DisableAuth: true
-
-# set to true to disable local script hook plugins
-DisableScriptHook: true
-
-# uncomment and set to the path of an icon to use in the server browser. it should be square.
-#ServerIcon: hello.png
-
-# don't try enabling this
-#UseGameServerV2: true
diff --git a/hello.png b/hello.png
deleted file mode 100644
index dcd524b..0000000
Binary files a/hello.png and /dev/null differ
diff --git a/libuv.dll b/libuv.dll
deleted file mode 100644
index 5e02949..0000000
Binary files a/libuv.dll and /dev/null differ
diff --git a/libuv.so b/libuv.so
deleted file mode 100644
index ee70aa0..0000000
Binary files a/libuv.so and /dev/null differ
diff --git a/mono/System.Runtime.InteropServices.RuntimeInformation.dll b/mono/System.Runtime.InteropServices.RuntimeInformation.dll
deleted file mode 100644
index 8ddc814..0000000
Binary files a/mono/System.Runtime.InteropServices.RuntimeInformation.dll and /dev/null differ
diff --git a/mono/libSystem.Native.so b/mono/libSystem.Native.so
deleted file mode 100644
index 16d40ce..0000000
Binary files a/mono/libSystem.Native.so and /dev/null differ
diff --git a/run.bat b/run.bat
deleted file mode 100644
index 0b06d7a..0000000
--- a/run.bat
+++ /dev/null
@@ -1,2 +0,0 @@
-@echo off
-start CitizenMP.Server.exe %*
\ No newline at end of file
diff --git a/run.sh b/run.sh
deleted file mode 100644
index af1cca6..0000000
--- a/run.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-fx_root=`dirname "$(readlink -f "$0")"`
-
-MONO_PATH=$fx_root/mono/ mono $fx_root/CitizenMP.Server.exe $*
\ No newline at end of file
diff --git a/system/MessagePack.lua b/system/MessagePack.lua
deleted file mode 100644
index 685d8cf..0000000
--- a/system/MessagePack.lua
+++ /dev/null
@@ -1,1205 +0,0 @@
---
--- lua-MessagePack :
---
-
-local r, jit = nil, nil
-
-local SIZEOF_NUMBER = 8
-local NUMBER_INTEGRAL = false
-if not jit then
- -- Lua 5.1 & 5.2
- local loadstring = loadstring or load
- --local luac = string.dump(loadstring "a = 1")
- --local header = { luac:sub(1, 12):byte(1, 12) }
- SIZEOF_NUMBER = 4
- NUMBER_INTEGRAL = 1 == 0
-end
-
---[[local assert = assert
-local error = error
-local pairs = pairs
-local pcall = pcall
-local setmetatable = setmetatable
-local tostring = tostring
-local type = type]]
-local char = string.char
-local floor = function(a) return a end--math.floor
---local frexp = math.frexp
---local ldexp = math.ldexp
-local huge = math.huge
-local tconcat = table.concat
-
---[[ debug only
-local format = require'string'.format
-local function hexadump (s)
- return (s:gsub('.', function (c) return format('%02X ', c:byte()) end))
-end
---]]
-
-local function utf8_to_utf16(s)
- local utf8 = clr.System.Text.Encoding.UTF8
- local bytes : byte[] = clr.System.Byte[#s]
-
- for i = 0, #s - 1 do
- bytes[i] = string.byte(s, i + 1)
- end
-
- return utf8:GetString(bytes)
-end
-
-local function utf16_to_utf8(s)
- local utf8 = clr.System.Text.Encoding.UTF8
- local StringBuilder = clr.System.Text.StringBuilder
- local bytes = utf8:GetBytes(s)
-
- local sb = StringBuilder(bytes.Length)
-
- for i = 0, bytes.Length - 1 do
- sb:Append(cast(char, bytes[i]))
- end
-
- return sb:ToString()
-end
-
-local m = {}
-
---[[ debug only
-m.hexadump = hexadump
---]]
-
-local function argerror (caller, narg, extramsg)
- error("bad argument #" .. tostring(narg) .. " to "
- .. caller .. " (" .. extramsg .. ")")
-end
-
-local function typeerror (caller, narg, arg, tname)
- argerror(caller, narg, tname .. " expected, got " .. type(arg))
-end
-
-local function checktype (caller, narg, arg, tname)
- if type(arg) ~= tname then
- typeerror(caller, narg, arg, tname)
- end
-end
-
---[[local packers = setmetatable({}, {
- __index = function (t, k) error("pack '" .. k .. "' is unimplemented") end
-})]]
-local packers = {}
-m.packers = packers
-
-packers['nil'] = function (buffer)
- buffer[#buffer+1] = char(0xC0) -- nil
-end
-
-packers['boolean'] = function (buffer, bool)
- if bool then
- buffer[#buffer+1] = char(0xC3) -- true
- else
- buffer[#buffer+1] = char(0xC2) -- false
- end
-end
-
-packers['string_compat'] = function (buffer, str)
- str = utf16_to_utf8(str)
-
- local n = #str
- if n <= 0x1F then
- buffer[#buffer+1] = char(0xA0 + n) -- fixstr
- elseif n <= 0xFFFF then
- buffer[#buffer+1] = char(0xDA, -- str16
- (n / 0x100),
- n % 0x100)
- elseif n <= 0xFFFFFFFF then
- buffer[#buffer+1] = char(0xDB, -- str32
- (n / 0x1000000),
- (n / 0x10000) % 0x100,
- (n / 0x100) % 0x100,
- n % 0x100)
- else
- error"overflow in pack 'string_compat'"
- end
- buffer[#buffer+1] = str
-end
-
-packers['_string'] = function (buffer, str)
- str = utf16_to_utf8(str)
-
- local n = #str
- if n <= 0x1F then
- buffer[#buffer+1] = char(0xA0 + n) -- fixstr
- elseif n <= 0xFF then
- buffer[#buffer+1] = char(0xD9, -- str8
- n)
- elseif n <= 0xFFFF then
- buffer[#buffer+1] = char(0xDA, -- str16
- (n / 0x100),
- n % 0x100)
- elseif n <= 0xFFFFFFFF then
- buffer[#buffer+1] = char(0xDB, -- str32
- (n / 0x1000000),
- (n / 0x10000) % 0x100,
- (n / 0x100) % 0x100,
- n % 0x100)
- else
- error"overflow in pack 'string'"
- end
- buffer[#buffer+1] = str
-end
-
-packers['binary'] = function (buffer, str)
- str = utf16_to_utf8(str)
-
- local n = #str
- if n <= 0xFF then
- buffer[#buffer+1] = char(0xC4, -- bin8
- n)
- elseif n <= 0xFFFF then
- buffer[#buffer+1] = char(0xC5, -- bin16
- (n / 0x100),
- n % 0x100)
- elseif n <= 0xFFFFFFFF then
- buffer[#buffer+1] = char(0xC6, -- bin32
- (n / 0x1000000),
- (n / 0x10000) % 0x100,
- (n / 0x100) % 0x100,
- n % 0x100)
- else
- error"overflow in pack 'binary'"
- end
- buffer[#buffer+1] = str
-end
-
-local set_string = function (str)
- if str == 'string_compat' then
- packers['string'] = packers['string_compat']
- elseif str == 'string' then
- packers['string'] = packers['_string']
- elseif str == 'binary' then
- packers['string'] = packers['binary']
- else
- argerror('set_string', 1, "invalid option '" .. str .."'")
- end
-end
-m.set_string = set_string
-
-packers['map'] = function (buffer, tbl, n)
- if n <= 0x0F then
- buffer[#buffer+1] = char(0x80 + n) -- fixmap
- elseif n <= 0xFFFF then
- buffer[#buffer+1] = char(0xDE, -- map16
- (n / 0x100),
- n % 0x100)
- elseif n <= 0xFFFFFFFF then
- buffer[#buffer+1] = char(0xDF, -- map32
- (n / 0x1000000),
- (n / 0x10000) % 0x100,
- (n / 0x100) % 0x100,
- n % 0x100)
- else
- error"overflow in pack 'map'"
- end
- for k, v in pairs(tbl) do
- packers[type(k)](buffer, k)
- packers[type(v)](buffer, v)
- end
-end
-
-packers['array'] = function (buffer, tbl, n)
- if n <= 0x0F then
- buffer[#buffer+1] = char(0x90 + n) -- fixarray
- elseif n <= 0xFFFF then
- buffer[#buffer+1] = char(0xDC, -- array16
- (n / 0x100),
- n % 0x100)
- elseif n <= 0xFFFFFFFF then
- buffer[#buffer+1] = char(0xDD, -- array32
- (n / 0x1000000),
- (n / 0x10000) % 0x100,
- (n / 0x100) % 0x100,
- n % 0x100)
- else
- error"overflow in pack 'array'"
- end
- for i = 1, n do
- local v = tbl[i]
- packers[type(v)](buffer, v)
- end
-end
-
-local set_array = function (array)
- if array == 'without_hole' then
- packers['_table'] = function (buffer, tbl)
- local is_map, n, max = false, 0, 0
- for k in pairs(tbl) do
- if type(k) == 'number' and k > 0 then
- if k > max then
- max = k
- end
- else
- is_map = true
- end
- n = n + 1
- end
- if max ~= n then -- there are holes
- is_map = true
- end
- if is_map then
- return packers['map'](buffer, tbl, n)
- else
- return packers['array'](buffer, tbl, n)
- end
- end
- elseif array == 'with_hole' then
- packers['_table'] = function (buffer, tbl)
- local is_map, n, max = false, 0, 0
- for k in pairs(tbl) do
- if type(k) == 'number' and k > 0 then
- if k > max then
- max = k
- end
- else
- is_map = true
- end
- n = n + 1
- end
- if is_map then
- return packers['map'](buffer, tbl, n)
- else
- return packers['array'](buffer, tbl, max)
- end
- end
- elseif array == 'always_as_map' then
- packers['_table'] = function(buffer, tbl)
- local n = 0
- for k in pairs(tbl) do
- n = n + 1
- end
- return packers['map'](buffer, tbl, n)
- end
- else
- argerror('set_array', 1, "invalid option '" .. array .."'")
- end
-end
-m.set_array = set_array
-
-packers['table'] = function (buffer, tbl)
- return packers['_table'](buffer, tbl)
-end
-
-packers['unsigned'] = function (buffer, n)
- if n >= 0 then
- if n <= 0x7F then
- buffer[#buffer+1] = char(n) -- fixnum_pos
- elseif n <= 0xFF then
- buffer[#buffer+1] = char(0xCC, -- uint8
- n)
- elseif n <= 0xFFFF then
- buffer[#buffer+1] = char(0xCD, -- uint16
- (n / 0x100),
- n % 0x100)
- elseif n <= 0xFFFFFFFF then
- buffer[#buffer+1] = char(0xCE, -- uint32
- (n / 0x1000000),
- (n / 0x10000) % 0x100,
- (n / 0x100) % 0x100,
- n % 0x100)
- else
- buffer[#buffer+1] = char(0xCF, -- uint64
- 0, -- only 53 bits from double
- (n / 0x1000000000000) % 0x100,
- (n / 0x10000000000) % 0x100,
- (n / 0x100000000) % 0x100,
- (n / 0x1000000) % 0x100,
- (n / 0x10000) % 0x100,
- (n / 0x100) % 0x100,
- n % 0x100)
- end
- else
- if n >= -0x20 then
- buffer[#buffer+1] = char(0x100 + n) -- fixnum_neg
- elseif n >= -0x80 then
- buffer[#buffer+1] = char(0xD0, -- int8
- 0x100 + n)
- elseif n >= -0x8000 then
- n = 0x10000 + n
- buffer[#buffer+1] = char(0xD1, -- int16
- (n / 0x100),
- n % 0x100)
- elseif n >= -0x7FFFFFFE then
- n = 0x100000000 + n
- buffer[#buffer+1] = char(0xD2, -- int32
- (n / 0x1000000),
- (n / 0x10000) % 0x100,
- (n / 0x100) % 0x100,
- n % 0x100)
- else
- buffer[#buffer+1] = char(0xD3, -- int64
- 0xFF, -- only 53 bits from double
- (n / 0x1000000000000) % 0x100,
- (n / 0x10000000000) % 0x100,
- (n / 0x100000000) % 0x100,
- (n / 0x1000000) % 0x100,
- (n / 0x10000) % 0x100,
- (n / 0x100) % 0x100,
- n % 0x100)
- end
- end
-end
-
-packers['signed'] = function (buffer, n)
- if n >= 0 then
- if n <= 0x7F then
- buffer[#buffer+1] = char(n) -- fixnum_pos
- elseif n <= 0x7FFF then
- buffer[#buffer+1] = char(0xD1, -- int16
- (n / 0x100),
- n % 0x100)
- elseif n <= 0x7FFFFFFF then
- buffer[#buffer+1] = char(0xD2, -- int32
- (n / 0x1000000),
- (n / 0x10000) % 0x100,
- (n / 0x100) % 0x100,
- n % 0x100)
- else
- buffer[#buffer+1] = char(0xD3, -- int64
- 0, -- only 53 bits from double
- (n / 0x1000000000000) % 0x100,
- (n / 0x10000000000) % 0x100,
- (n / 0x100000000) % 0x100,
- (n / 0x1000000) % 0x100,
- (n / 0x10000) % 0x100,
- (n / 0x100) % 0x100,
- n % 0x100)
- end
- else
- if n >= -0x20 then
- buffer[#buffer+1] = char(0xE0 + 0x20 + n) -- fixnum_neg
- elseif n >= -0x80 then
- buffer[#buffer+1] = char(0xD0, -- int8
- 0x100 + n)
- elseif n >= -0x8000 then
- n = 0x10000 + n
- buffer[#buffer+1] = char(0xD1, -- int16
- (n / 0x100),
- n % 0x100)
- elseif n >= -0x7FFFFFFE then
- n = 0x100000000 + n
- buffer[#buffer+1] = char(0xD2, -- int32
- (n / 0x1000000),
- (n / 0x10000) % 0x100,
- (n / 0x100) % 0x100,
- n % 0x100)
- else
- buffer[#buffer+1] = char(0xD3, -- int64
- 0xFF, -- only 53 bits from double
- (n / 0x1000000000000) % 0x100,
- (n / 0x10000000000) % 0x100,
- (n / 0x100000000) % 0x100,
- (n / 0x1000000) % 0x100,
- (n / 0x10000) % 0x100,
- (n / 0x100) % 0x100,
- n % 0x100)
- end
- end
-end
-
-local set_integer = function (integer)
- if integer == 'unsigned' then
- packers['integer'] = packers['unsigned']
- elseif integer == 'signed' then
- packers['integer'] = packers['signed']
- else
- argerror('set_integer', 1, "invalid option '" .. integer .."'")
- end
-end
-m.set_integer = set_integer
-
-packers['float'] = function (buffer, n)
- local sign = 0
- if n < 0.0 then
- sign = 0x80
- n = -n
- end
- local mant, expo = frexp(n)
- if mant ~= mant then
- buffer[#buffer+1] = char(0xCA, -- nan
- 0xFF, 0x88, 0x00, 0x00)
- elseif mant == huge or expo > 0x80 then
- if sign == 0 then
- buffer[#buffer+1] = char(0xCA, -- inf
- 0x7F, 0x80, 0x00, 0x00)
- else
- buffer[#buffer+1] = char(0xCA, -- -inf
- 0xFF, 0x80, 0x00, 0x00)
- end
- elseif (mant == 0.0 and expo == 0) or expo < -0x7E then
- buffer[#buffer+1] = char(0xCA, -- zero
- sign, 0x00, 0x00, 0x00)
- else
- expo = expo + 0x7E
- mant = (mant * 2.0 - 1.0) * ldexp(0.5, 24)
- buffer[#buffer+1] = char(0xCA,
- sign + (expo / 0x2),
- (expo % 0x2) * 0x80 + (mant / 0x10000),
- (mant / 0x100) % 0x100,
- mant % 0x100)
- end
-end
-
-local mf = function(f)
- local a = math.floor(f)
-
- return a
-end
-
-packers['double'] = function (buffer, n)
- local sign = 0
- if n < 0.0 then
- sign = 0x80
- n = -n
- end
- local mant, expo = frexp(n)
-
- if mant ~= mant then
- buffer[#buffer+1] = char(0xCB, -- nan
- 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
- elseif mant == huge then
- if sign == 0 then
- buffer[#buffer+1] = char(0xCB, -- inf
- 0x7F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
- else
- buffer[#buffer+1] = char(0xCB, -- -inf
- 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
- end
- elseif mant == 0.0 and expo == 0 then
- buffer[#buffer+1] = char(0xCB, -- zero
- sign, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
- else
- expo = expo + 0x3FE
- mant = (mant * 2.0 - 1.0) * ldexp(0.5, 53)
-
- buffer[#buffer+1] = char(0xCB,
- sign + s,
- ff,
- f2,
- f3,
- f4,
- f5,
- f6,
- mant % 0x100)
- end
-end
-
-local set_number = function (number)
- if number == 'integer' then
- packers['number'] = packers['signed']
- elseif number == 'float' then
- packers['number'] = function (buffer, n)
- if math.floor(n) ~= n or n ~= n or n > 3.40282347e+38 or n < -3.40282347e+38 then
- return packers['float'](buffer, n)
- else
- return packers['integer'](buffer, n)
- end
- end
- elseif number == 'double' then
- packers['number'] = function (buffer, n)
- if math.floor(n) ~= n or n ~= n or n == huge or n == -huge then
- return packers['double'](buffer, n)
- else
- return packers['integer'](buffer, n)
- end
- end
- else
- argerror('set_number', 1, "invalid option '" .. number .."'")
- end
-end
-m.set_number = set_number
-
-for k = 0, 4 do
- local n = 2^k
- local fixext = 0xD4 + k
- packers['fixext' .. n] = function (buffer, tag, data)
- assert(#data == n, "bad length for fixext" .. n)
- buffer[#buffer+1] = char(fixext,
- tag < 0 and tag + 0x100 or tag)
- buffer[#buffer+1] = data
- end
-end
-
-packers['ext'] = function (buffer, tag, data)
- local n = #data
- if n <= 0xFF then
- buffer[#buffer+1] = char(0xC7, -- ext8
- n,
- tag < 0 and tag + 0x100 or tag)
- elseif n <= 0xFFFF then
- buffer[#buffer+1] = char(0xC8, -- ext16
- (n / 0x100),
- n % 0x100,
- tag < 0 and tag + 0x100 or tag)
- elseif n <= 0xFFFFFFFF then
- buffer[#buffer+1] = char(0xC9, -- ext&32
- (n / 0x1000000),
- (n / 0x10000) % 0x100,
- (n / 0x100) % 0x100,
- n % 0x100,
- tag < 0 and tag + 0x100 or tag)
- else
- error"overflow in pack 'ext'"
- end
- buffer[#buffer+1] = data
-end
-
-function m.pack (data)
- local buffer = {}
-
- local packer = packers[type(data)]
- packer(buffer, data)
-
- return table.concat(buffer)
-end
-
-
-local types_map = setmetatable({
- [0xC0] = 'nil',
- [0xC2] = 'false',
- [0xC3] = 'true',
- [0xC4] = 'bin8',
- [0xC5] = 'bin16',
- [0xC6] = 'bin32',
- [0xC7] = 'ext8',
- [0xC8] = 'ext16',
- [0xC9] = 'ext32',
- [0xCA] = 'float',
- [0xCB] = 'double',
- [0xCC] = 'uint8',
- [0xCD] = 'uint16',
- [0xCE] = 'uint32',
- [0xCF] = 'uint64',
- [0xD0] = 'int8',
- [0xD1] = 'int16',
- [0xD2] = 'int32',
- [0xD3] = 'int64',
- [0xD4] = 'fixext1',
- [0xD5] = 'fixext2',
- [0xD6] = 'fixext4',
- [0xD7] = 'fixext8',
- [0xD8] = 'fixext16',
- [0xD9] = 'str8',
- [0xDA] = 'str16',
- [0xDB] = 'str32',
- [0xDC] = 'array16',
- [0xDD] = 'array32',
- [0xDE] = 'map16',
- [0xDF] = 'map32',
-}, { __index = function (t, k)
- if k < 0xC0 then
- if k < 0x80 then
- return 'fixnum_pos'
- elseif k < 0x90 then
- return 'fixmap'
- elseif k < 0xA0 then
- return 'fixarray'
- else
- return 'fixstr'
- end
- elseif k > 0xDF then
- return 'fixnum_neg'
- else
- return 'reserved' .. k
- end
-end })
-m.types_map = types_map
-
-local unpackers = setmetatable({}, {
- __index = function (t, k)
- local g = rawget(t, k)
-
- if g then
- return g
- end
-
- error("unpack '" .. k .. "' is unimplemented")
- end
-})
-m.unpackers = unpackers
-
-local function unpack_array (c, n)
- local t = {}
- local decode = unpackers['any']
- for i = 1, n do
- t[i] = decode(c)
- end
- return t
-end
-
-local function unpack_map (c, n)
- local t = {}
- local decode = unpackers['any']
- for i = 1, n do
- local k = decode(c)
- local v = decode(c)
-
- if k then
- t[k] = v
- end
- end
- return t
-end
-
-unpackers['any'] = function (c)
- local s, i, j = c.s, c.i, c.j
- if i > j then
- c:underflow(i)
- s, i, j = c.s, c.i, c.j
- end
- local val = s:sub(i, i):byte()
- c.i = i+1
- return unpackers[types_map[val]](c, val)
-end
-
-unpackers['nil'] = function ()
- return nil
-end
-
-unpackers['false'] = function ()
- return false
-end
-
-unpackers['true'] = function ()
- return true
-end
-
-unpackers['float'] = function (c)
- local s, i, j = c.s, c.i, c.j
- if i+3 > j then
- c:underflow(i+3)
- s, i, j = c.s, c.i, c.j
- end
- local b1, b2, b3, b4 = s:sub(i, i+3):byte(1, 4)
- local sign = b1 > 0x7F
- local expo = (b1 % 0x80) * 0x2 + (b2 / 0x80)
- local mant = ((b2 % 0x80) * 0x100 + b3) * 0x100 + b4
- if sign then
- sign = -1
- else
- sign = 1
- end
- local n
- if mant == 0 and expo == 0 then
- n = sign * 0.0
- elseif expo == 0xFF then
- if mant == 0 then
- n = sign * huge
- else
- n = 0.0/0.0
- end
- else
- n = sign * ldexp(1.0 + mant / 0x800000, expo - 0x7F)
- end
- c.i = i+4
- return n
-end
-
-unpackers['double'] = function (c)
- local s, i, j = c.s, c.i, c.j
- if i+7 > j then
- c:underflow(i+7)
- s, i, j = c.s, c.i, c.j
- end
- local b1, b2, b3, b4, b5, b6, b7, b8 = s:sub(i, i+7):byte(1, 8)
-
- local arr = clr.System.Byte[]{ b8, b7, b6, b5, b4, b3, b2, b1 }
-
- c.i = i+8
-
- return clr.System.BitConverter.ToDouble(arr, 0)
- end
-
-unpackers['fixnum_pos'] = function (c, val)
- return val
-end
-
-unpackers['uint8'] = function (c)
- local s, i, j = c.s, c.i, c.j
- if i > j then
- c:underflow(i)
- s, i, j = c.s, c.i, c.j
- end
- local b1 = s:sub(i, i):byte()
- c.i = i+1
- return b1
-end
-
-unpackers['uint16'] = function (c)
- local s, i, j = c.s, c.i, c.j
- if i+1 > j then
- c:underflow(i+1)
- s, i, j = c.s, c.i, c.j
- end
- local b1, b2 = s:sub(i, i+1):byte(1, 2)
- c.i = i+2
- return b1 * 0x100 + b2
-end
-
-unpackers['uint32'] = function (c)
- local s, i, j = c.s, c.i, c.j
- if i+3 > j then
- c:underflow(i+3)
- s, i, j = c.s, c.i, c.j
- end
- local b1, b2, b3, b4 = s:sub(i, i+3):byte(1, 4)
- c.i = i+4
- return ((b1 * 0x100 + b2) * 0x100 + b3) * 0x100 + b4
-end
-
-unpackers['uint64'] = function (c)
- local s, i, j = c.s, c.i, c.j
- if i+7 > j then
- c:underflow(i+7)
- s, i, j = c.s, c.i, c.j
- end
- local b1, b2, b3, b4, b5, b6, b7, b8 = s:sub(i, i+7):byte(1, 8)
- c.i = i+8
- return ((((((b1 * 0x100 + b2) * 0x100 + b3) * 0x100 + b4) * 0x100 + b5) * 0x100 + b6) * 0x100 + b7) * 0x100 + b8
-end
-
-unpackers['fixnum_neg'] = function (c, val)
- return val - 0x100
-end
-
-unpackers['int8'] = function (c)
- local s, i, j = c.s, c.i, c.j
- if i > j then
- c:underflow(i)
- s, i, j = c.s, c.i, c.j
- end
- local b1 = s:sub(i, i):byte()
- c.i = i+1
- if b1 < 0x80 then
- return b1
- else
- return b1 - 0x100
- end
-end
-
-unpackers['int16'] = function (c)
- local s, i, j = c.s, c.i, c.j
- if i+1 > j then
- c:underflow(i+1)
- s, i, j = c.s, c.i, c.j
- end
- local b1, b2 = s:sub(i, i+1):byte(1, 2)
- c.i = i+2
- if b1 < 0x80 then
- return b1 * 0x100 + b2
- else
- return ((b1 - 0xFF) * 0x100 + (b2 - 0xFF)) - 1
- end
-end
-
-unpackers['int32'] = function (c)
- local s, i, j = c.s, c.i, c.j
- if i+3 > j then
- c:underflow(i+3)
- s, i, j = c.s, c.i, c.j
- end
- local b1, b2, b3, b4 = s:sub(i, i+3):byte(1, 4)
- c.i = i+4
- if b1 < 0x80 then
- return ((b1 * 0x100 + b2) * 0x100 + b3) * 0x100 + b4
- else
- return ((((b1 - 0xFF) * 0x100 + (b2 - 0xFF)) * 0x100 + (b3 - 0xFF)) * 0x100 + (b4 - 0xFF)) - 1
- end
-end
-
-unpackers['int64'] = function (c)
- local s, i, j = c.s, c.i, c.j
- if i+7 > j then
- c:underflow(i+7)
- s, i, j = c.s, c.i, c.j
- end
- local b1, b2, b3, b4, b5, b6, b7, b8 = s:sub(i, i+7):byte(1, 8)
- c.i = i+8
- if b1 < 0x80 then
- return ((((((b1 * 0x100 + b2) * 0x100 + b3) * 0x100 + b4) * 0x100 + b5) * 0x100 + b6) * 0x100 + b7) * 0x100 + b8
- else
- return ((((((((b1 - 0xFF) * 0x100 + (b2 - 0xFF)) * 0x100 + (b3 - 0xFF)) * 0x100 + (b4 - 0xFF)) * 0x100 + (b5 - 0xFF)) * 0x100 + (b6 - 0xFF)) * 0x100 + (b7 - 0xFF)) * 0x100 + (b8 - 0xFF)) - 1
- end
-end
-
-unpackers['fixstr'] = function (c, val)
- local s, i, j = c.s, c.i, c.j
- local n = val % 0x20
- local e = i+n-1
- if e > j then
- c:underflow(e)
- s, i, j = c.s, c.i, c.j
- e = i+n-1
- end
- c.i = i+n
- return utf8_to_utf16(s:sub(i, e))
-end
-
-unpackers['str8'] = function (c)
- local s, i, j = c.s, c.i, c.j
- if i > j then
- c:underflow(i)
- s, i, j = c.s, c.i, c.j
- end
- local n = s:sub(i, i):byte()
- i = i+1
- c.i = i
- local e = i+n-1
- if e > j then
- c:underflow(e)
- s, i, j = c.s, c.i, c.j
- e = i+n-1
- end
- c.i = i+n
- return utf8_to_utf16(s:sub(i, e))
-end
-
-unpackers['str16'] = function (c)
- local s, i, j = c.s, c.i, c.j
- if i+1 > j then
- c:underflow(i+1)
- s, i, j = c.s, c.i, c.j
- end
- local b1, b2 = s:sub(i, i+1):byte(1, 2)
- i = i+2
- c.i = i
- local n = b1 * 0x100 + b2
- local e = i+n-1
-
- if e > j then
- c:underflow(e)
- s, i, j = c.s, c.i, c.j
- e = i+n-1
- end
- c.i = i+n
- return utf8_to_utf16(s:sub(i, e))
-end
-
-unpackers['str32'] = function (c)
- local s, i, j = c.s, c.i, c.j
- if i+3 > j then
- c:underflow(i+3)
- s, i, j = c.s, c.i, c.j
- end
- local b1, b2, b3, b4 = s:sub(i, i+3):byte(1, 4)
- i = i+4
- c.i = i
- local n = ((b1 * 0x100 + b2) * 0x100 + b3) * 0x100 + b4
- local e = i+n-1
- if e > j then
- c:underflow(e)
- s, i, j = c.s, c.i, c.j
- e = i+n-1
- end
- c.i = i+n
- return utf8_to_utf16(s:sub(i, e))
-end
-
-unpackers['bin8'] = unpackers['str8']
-unpackers['bin16'] = unpackers['str16']
-unpackers['bin32'] = unpackers['str32']
-
-unpackers['fixarray'] = function (c, val)
- return unpack_array(c, val % 0x10)
-end
-
-unpackers['array16'] = function (c)
- local s, i, j = c.s, c.i, c.j
- if i+1 > j then
- c:underflow(i+1)
- s, i, j = c.s, c.i, c.j
- end
- local b1, b2 = s:sub(i, i+1):byte(1, 2)
- c.i = i+2
- return unpack_array(c, b1 * 0x100 + b2)
-end
-
-unpackers['array32'] = function (c)
- local s, i, j = c.s, c.i, c.j
- if i+3 > j then
- c:underflow(i+3)
- s, i, j = c.s, c.i, c.j
- end
- local b1, b2, b3, b4 = s:sub(i, i+3):byte(1, 4)
- c.i = i+4
- return unpack_array(c, ((b1 * 0x100 + b2) * 0x100 + b3) * 0x100 + b4)
-end
-
-unpackers['fixmap'] = function (c, val)
- return unpack_map(c, val % 0x10)
-end
-
-unpackers['map16'] = function (c)
- local s, i, j = c.s, c.i, c.j
- if i+1 > j then
- c:underflow(i+1)
- s, i, j = c.s, c.i, c.j
- end
- local b1, b2 = s:sub(i, i+1):byte(1, 2)
- c.i = i+2
- return unpack_map(c, b1 * 0x100 + b2)
-end
-
-unpackers['map32'] = function (c)
- local s, i, j = c.s, c.i, c.j
- if i+3 > j then
- c:underflow(i+3)
- s, i, j = c.s, c.i, c.j
- end
- local b1, b2, b3, b4 = s:sub(i, i+3):byte(1, 4)
- c.i = i+4
- return unpack_map(c, ((b1 * 0x100 + b2) * 0x100 + b3) * 0x100 + b4)
-end
-
-function m.build_ext (tag, data)
- return nil
-end
-
-for k = 0, 4 do
- local n = 2^k
- unpackers['fixext' .. n] = function (c)
- local s, i, j = c.s, c.i, c.j
- if i > j then
- c:underflow(i)
- s, i, j = c.s, c.i, c.j
- end
- local tag = s:sub(i, i):byte()
- i = i+1
- c.i = i
- local e = i+n-1
- if e > j then
- c:underflow(e)
- s, i, j = c.s, c.i, c.j
- e = i+n-1
- end
- c.i = i+n
- return m.build_ext(tag < 0x80 and tag or tag - 0x100, s:sub(i, e))
- end
-end
-
-unpackers['ext8'] = function (c)
- local s, i, j = c.s, c.i, c.j
- if i > j then
- c:underflow(i)
- s, i, j = c.s, c.i, c.j
- end
- local n = s:sub(i, i):byte()
- i = i+1
- c.i = i
- if i > j then
- c:underflow(i)
- s, i, j = c.s, c.i, c.j
- end
- local tag = s:sub(i, i):byte()
- i = i+1
- c.i = i
- local e = i+n-1
- if e > j then
- c:underflow(e)
- s, i, j = c.s, c.i, c.j
- e = i+n-1
- end
- c.i = i+n
- return m.build_ext(tag < 0x80 and tag or tag - 0x100, s:sub(i, e))
-end
-
-unpackers['ext16'] = function (c)
- local s, i, j = c.s, c.i, c.j
- if i+1 > j then
- c:underflow(i+1)
- s, i, j = c.s, c.i, c.j
- end
- local b1, b2 = s:sub(i, i+1):byte(1, 2)
- i = i+2
- c.i = i
- local n = b1 * 0x100 + b2
- if i > j then
- c:underflow(i)
- s, i, j = c.s, c.i, c.j
- end
- local tag = s:sub(i, i):byte()
- i = i+1
- c.i = i
- local e = i+n-1
- if e > j then
- c:underflow(e)
- s, i, j = c.s, c.i, c.j
- e = i+n-1
- end
- c.i = i+n
- return m.build_ext(tag < 0x80 and tag or tag - 0x100, s:sub(i, e))
-end
-
-unpackers['ext32'] = function (c)
- local s, i, j = c.s, c.i, c.j
- if i+3 > j then
- c:underflow(i+3)
- s, i, j = c.s, c.i, c.j
- end
- local b1, b2, b3, b4 = s:sub(i, i+3):byte(1, 4)
- i = i+4
- c.i = i
- local n = ((b1 * 0x100 + b2) * 0x100 + b3) * 0x100 + b4
- if i > j then
- c:underflow(i)
- s, i, j = c.s, c.i, c.j
- end
- local tag = s:sub(i, i):byte()
- i = i+1
- c.i = i
- local e = i+n-1
- if e > j then
- c:underflow(e)
- s, i, j = c.s, c.i, c.j
- e = i+n-1
- end
- c.i = i+n
- return m.build_ext(tag < 0x80 and tag or tag - 0x100, s:sub(i, e))
-end
-
-
-local function cursor_string (str)
- return {
- s = str,
- i = 1,
- j = #str,
- underflow = function (self)
- error "missing bytes"
- end,
- }
-end
-
-local function cursor_loader (ld)
- return {
- s = '',
- i = 1,
- j = 0,
- underflow = function (self, e)
- self.s = self.s:sub(self.i)
- e = e - self.i + 1
- self.i = 1
- self.j = 0
- while e > self.j do
- local chunk = ld()
- if not chunk then
- error "missing bytes"
- end
- self.s = self.s .. chunk
- self.j = #self.s
- end
- end,
- }
-end
-
-function m.unpack (s)
- checktype('unpack', 1, s, 'string')
-
- --[[for i = 1, #s do
- print(s:byte(i))
- end]]
-
- local cursor = cursor_string(s)
- local data = unpackers['any'](cursor)
- if cursor.i < cursor.j then
- --error "extra bytes"
- end
-
- return data
-end
-
-function m.unpacker (src)
- if type(src) == 'string' then
- local cursor = cursor_string(src)
- return function ()
- if cursor.i <= cursor.j then
- return cursor.i, unpackers['any'](cursor)
- end
- end
- elseif type(src) == 'function' then
- local cursor = cursor_loader(src)
- return function ()
- if cursor.i > cursor.j then
- pcall(cursor.underflow, cursor, cursor.i)
- end
- if cursor.i <= cursor.j then
- return true, unpackers['any'](cursor)
- end
- end
- else
- argerror('unpacker', 1, "string or function expected, got " .. type(src))
- end
-end
-
-set_string'string_compat'
-set_integer'signed'
-if NUMBER_INTEGRAL then
- set_number'integer'
-elseif SIZEOF_NUMBER == 4 then
- set_number'float'
-else
- set_number'double'
-end
-set_array'without_hole'
-
-m._VERSION = "0.3.1"
-m._DESCRIPTION = "lua-MessagePack : a pure Lua implementation"
-m._COPYRIGHT = "Copyright (c) 2012-2014 Francois Perrad"
-
-msgpack = m
-
---
--- This library is licensed under the terms of the MIT/X11 license,
--- like Lua itself.
---
-
---
--- CitizenMP extensions follow
---
-
-local EXT_CLOSURE = 1
-
-m.packers['function'] = function(buffer, func)
- local ref, inst, res = GetFuncRef(func)
-
- m.packers['ext'](buffer, EXT_CLOSURE, char(
- (ref / 0x1000000),
- (ref / 0x10000) % 0x100,
- (ref / 0x100) % 0x100,
- ref % 0x100) ..
- char(
- (inst / 0x1000000),
- (inst / 0x10000) % 0x100,
- (inst / 0x100) % 0x100,
- inst % 0x100)
- .. res)
-end
-
-m.packers['userdata'] = function(buffer, udata)
- --[[local ref, res = GetFuncRefByData(udata)
-
- m.packers['ext'](buffer, EXT_CLOSURE, char(
- (ref / 0x1000000),
- (ref / 0x10000) % 0x100,
- (ref / 0x100) % 0x100,
- ref % 0x100) .. res)]]
-
- error('unsupported pending NLua fixes')
-end
-
-m.build_ext = function(tag, data)
- if tag == EXT_CLOSURE then
- local cursor = cursor_string(data)
- local ref = unpackers['int32'](cursor)
- local inst = unpackers['uint32'](cursor)
- local res = data:sub(9)
-
- return GetFuncFromRef(ref, inst, res)
- end
-end
diff --git a/system/dkjson.lua b/system/dkjson.lua
deleted file mode 100644
index 43fac82..0000000
--- a/system/dkjson.lua
+++ /dev/null
@@ -1,709 +0,0 @@
--- Module options:
-local always_try_using_lpeg = true
-local register_global_module_table = true
-local global_module_name = 'json'
-
---[==[
-
-David Kolf's JSON module for Lua 5.1/5.2
-
-Version 2.5
-
-
-For the documentation see the corresponding readme.txt or visit
-.
-
-You can contact the author by sending an e-mail to 'david' at the
-domain 'dkolf.de'.
-
-
-Copyright (C) 2010-2013 David Heiko Kolf
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-
---]==]
-
--- global dependencies:
---local pairs, type, tostring, tonumber, getmetatable, setmetatable, rawset =
--- pairs, type, tostring, tonumber, getmetatable, setmetatable, rawset
---local error, require, pcall, select = error, require, pcall, select
-local floor, huge = math.floor, math.huge
-local strrep, gsub, gsubf, strsub, strbyte, strchar, strfind, strlen, strformat =
- string.rep, gsub, gsubf, ssub, string.byte, string.char,
- sfind, string.len, string.format
-local strmatch = string.match
-local concat = table.concat
-
-local json = { version = "dkjson 2.5" }
-
-if register_global_module_table then
- _G[global_module_name] = json
-end
-
-local _ENV = nil -- blocking globals in Lua 5.2
-
-pcall (function()
- -- Enable access to blocked metatables.
- -- Don't worry, this module doesn't change anything in them.
- local debmeta = require "debug".getmetatable
- if debmeta then getmetatable = debmeta end
-end)
-
-json.null = setmetatable ({}, {
- __tojson = function () return "null" end
-})
-
-local function isarray (tbl)
- local max, n, arraylen = 0, 0, 0
- for k,v in pairs (tbl) do
- if k == 'n' and type(v) == 'number' then
- arraylen = v
- if v > max then
- max = v
- end
- else
- if type(k) ~= 'number' or k < 1 or floor(k) ~= k then
- return false
- end
- if k > max then
- max = k
- end
- n = n + 1
- end
- end
- if max > 10 and max > arraylen and max > n * 2 then
- return false -- don't create an array with too many holes
- end
- return true, max
-end
-
-local escapecodes = {
- ["\""] = "\\\"", ["\\"] = "\\\\", ["\b"] = "\\b", ["\f"] = "\\f",
- ["\n"] = "\\n", ["\r"] = "\\r", ["\t"] = "\\t"
-}
-
-local function escapeutf8 (uchar)
- local value = escapecodes[uchar]
- if value then
- return value
- end
- local a, b, c, d = strbyte (uchar, 1, 4)
- a, b, c, d = a or 0, b or 0, c or 0, d or 0
- if a <= 0x7f then
- value = a
- elseif 0xc0 <= a and a <= 0xdf and b >= 0x80 then
- value = (a - 0xc0) * 0x40 + b - 0x80
- elseif 0xe0 <= a and a <= 0xef and b >= 0x80 and c >= 0x80 then
- value = ((a - 0xe0) * 0x40 + b - 0x80) * 0x40 + c - 0x80
- elseif 0xf0 <= a and a <= 0xf7 and b >= 0x80 and c >= 0x80 and d >= 0x80 then
- value = (((a - 0xf0) * 0x40 + b - 0x80) * 0x40 + c - 0x80) * 0x40 + d - 0x80
- else
- return ""
- end
- if value <= 0xffff then
- return strformat ("\\u%.4x", value)
- elseif value <= 0x10ffff then
- -- encode as UTF-16 surrogate pair
- value = value - 0x10000
- local highsur, lowsur = 0xD800 + floor (value/0x400), 0xDC00 + (value % 0x400)
- return strformat ("\\u%.4x\\u%.4x", highsur, lowsur)
- else
- return ""
- end
-end
-
-local function fsub (str, pattern, repl)
- -- gsub always builds a new string in a buffer, even when no match
- -- exists. First using find should be more efficient when most strings
- -- don't contain the pattern.
- if strfind (str, pattern) then
- if type(repl) == 'function' then
- return gsubf(str, pattern, repl)
- else
- return gsub (str, pattern, repl)
- end
- else
- return str
- end
-end
-
-local function quotestring (value)
- -- based on the regexp "escapable" in https://github.com/douglascrockford/JSON-js
- value = fsub (value, "[%z\1-\31\"\\\127]", escapeutf8)
- if strfind (value, "[\194\216\220\225\226\239]") then
- value = fsub (value, "\194[\128-\159\173]", escapeutf8)
- value = fsub (value, "\216[\128-\132]", escapeutf8)
- value = fsub (value, "\220\143", escapeutf8)
- value = fsub (value, "\225\158[\180\181]", escapeutf8)
- value = fsub (value, "\226\128[\140-\143\168-\175]", escapeutf8)
- value = fsub (value, "\226\129[\160-\175]", escapeutf8)
- value = fsub (value, "\239\187\191", escapeutf8)
- value = fsub (value, "\239\191[\176-\191]", escapeutf8)
- end
- return "\"" .. value .. "\""
-end
-json.quotestring = quotestring
-
-local function replace(str, o, n)
- local i, j = strfind (str, o, 1, true)
- if i then
- return strsub(str, 1, i-1) .. n .. strsub(str, j+1, -1)
- else
- return str
- end
-end
-
--- locale independent num2str and str2num functions
-local decpoint, numfilter
-
-local function updatedecpoint ()
- decpoint = strmatch(tostring(0.5), "([^05+])")
- -- build a filter that can be used to remove group separators
- numfilter = "[^0-9%-%+eE" .. gsub(decpoint, "[%^%$%(%)%%%.%[%]%*%+%-%?]", "%%%0") .. "]+"
-end
-
-updatedecpoint()
-
-local function num2str (num)
- return replace(fsub(tostring(num), numfilter, ""), decpoint, ".")
-end
-
-local function str2num (str)
- local num = tonumber(replace(str, ".", decpoint))
- if not num then
- updatedecpoint()
- num = tonumber(replace(str, ".", decpoint))
- end
- return num
-end
-
-local function addnewline2 (level, buffer, buflen)
- buffer[buflen+1] = "\n"
- buffer[buflen+2] = strrep (" ", level)
- buflen = buflen + 2
- return buflen
-end
-
-function json.addnewline (state)
- if state.indent then
- state.bufferlen = addnewline2 (state.level or 0,
- state.buffer, state.bufferlen or #(state.buffer))
- end
-end
-
-local encode2 -- forward declaration
-
-local function addpair (key, value, prev, indent, level, buffer, buflen, tables, globalorder, state)
- local kt = type (key)
- if kt ~= 'string' and kt ~= 'number' then
- return nil, "type '" .. kt .. "' is not supported as a key by JSON."
- end
- if prev then
- buflen = buflen + 1
- buffer[buflen] = ","
- end
- if indent then
- buflen = addnewline2 (level, buffer, buflen)
- end
- buffer[buflen+1] = quotestring (key)
- buffer[buflen+2] = ":"
- return encode2 (value, indent, level, buffer, buflen + 2, tables, globalorder, state)
-end
-
-local function appendcustom(res, buffer, state)
- local buflen = state.bufferlen
- if type (res) == 'string' then
- buflen = buflen + 1
- buffer[buflen] = res
- end
- return buflen
-end
-
-local function exception(reason, value, state, buffer, buflen, defaultmessage)
- defaultmessage = defaultmessage or reason
- local handler = state.exception
- if not handler then
- return nil, defaultmessage
- else
- state.bufferlen = buflen
- local ret, msg = handler (reason, value, state, defaultmessage)
- if not ret then return nil, msg or defaultmessage end
- return appendcustom(ret, buffer, state)
- end
-end
-
-function json.encodeexception(reason, value, state, defaultmessage)
- return quotestring("<" .. defaultmessage .. ">")
-end
-
-encode2 = function (value, indent, level, buffer, buflen, tables, globalorder, state)
- local valtype = type (value)
- local valmeta = getmetatable (value)
- valmeta = type (valmeta) == 'table' and valmeta -- only tables
- local valtojson = valmeta and valmeta.__tojson
- if valtojson then
- if tables[value] then
- return exception('reference cycle', value, state, buffer, buflen)
- end
- tables[value] = true
- state.bufferlen = buflen
- local ret, msg = valtojson (value, state)
- if not ret then return exception('custom encoder failed', value, state, buffer, buflen, msg) end
- tables[value] = nil
- buflen = appendcustom(ret, buffer, state)
- elseif valtype == 'nil' then
- buflen = buflen + 1
- buffer[buflen] = "null"
- elseif valtype == 'number' then
- local s
- if value ~= value or value >= huge or -value >= huge then
- -- This is the behaviour of the original JSON implementation.
- s = "null"
- else
- s = num2str (value)
- end
- buflen = buflen + 1
- buffer[buflen] = s
- elseif valtype == 'boolean' then
- buflen = buflen + 1
- buffer[buflen] = value and "true" or "false"
- elseif valtype == 'string' then
- buflen = buflen + 1
- buffer[buflen] = quotestring (value)
- elseif valtype == 'table' then
- --[[if tables[value] then
- return exception('reference cycle', value, state, buffer, buflen)
- end
- tables[value] = true]]
- level = level + 1
- local isa, n = isarray (value)
- if n == 0 and valmeta and valmeta.__jsontype == 'object' then
- isa = false
- end
- local msg
- if isa then -- JSON array
- buflen = buflen + 1
- buffer[buflen] = "["
- for i = 1, n do
- buflen, msg = encode2 (value[i], indent, level, buffer, buflen, tables, globalorder, state)
- if not buflen then return nil, msg end
- if i < n then
- buflen = buflen + 1
- buffer[buflen] = ","
- end
- end
- buflen = buflen + 1
- buffer[buflen] = "]"
- else -- JSON object
- local prev = false
- buflen = buflen + 1
- buffer[buflen] = "{"
- local order = valmeta and valmeta.__jsonorder or globalorder
- if order then
- local used = {}
- n = #order
- for i = 1, n do
- local k = order[i]
- local v = value[k]
- if v then
- used[k] = true
- buflen, msg = addpair (k, v, prev, indent, level, buffer, buflen, tables, globalorder, state)
- prev = true -- add a seperator before the next element
- end
- end
- for k,v in pairs (value) do
- if not used[k] then
- buflen, msg = addpair (k, v, prev, indent, level, buffer, buflen, tables, globalorder, state)
- if not buflen then return nil, msg end
- prev = true -- add a seperator before the next element
- end
- end
- else -- unordered
- for k,v in pairs (value) do
- buflen, msg = addpair (k, v, prev, indent, level, buffer, buflen, tables, globalorder, state)
- if not buflen then return nil, msg end
- prev = true -- add a seperator before the next element
- end
- end
- if indent then
- buflen = addnewline2 (level - 1, buffer, buflen)
- end
- buflen = buflen + 1
- buffer[buflen] = "}"
- end
- --tables[value] = nil
- else
- return exception ('unsupported type', value, state, buffer, buflen,
- "type '" .. valtype .. "' is not supported by JSON.")
- end
- return buflen
-end
-
-function json.encode (value, state)
- state = state or {}
- local oldbuffer = state.buffer
- local buffer = oldbuffer or {}
- state.buffer = buffer
- updatedecpoint()
- local ret, msg = encode2 (value, state.indent, state.level or 0,
- buffer, state.bufferlen or 0, state.tables or {}, state.keyorder, state)
- if not ret then
- error (msg, 2)
- elseif oldbuffer == buffer then
- state.bufferlen = ret
- return true
- else
- state.bufferlen = nil
- state.buffer = nil
- return concat (buffer)
- end
-end
-
-local function loc (str, where)
- local line, pos, linepos = 1, 1, 0
- while true do
- pos = strfind (str, "\n", pos, true)
- if pos and pos < where then
- line = line + 1
- linepos = pos
- pos = pos + 1
- else
- break
- end
- end
- return "line " .. line .. ", column " .. (where - linepos)
-end
-
-local function unterminated (str, what, where)
- return nil, strlen (str) + 1, "unterminated " .. what .. " at " .. loc (str, where)
-end
-
-local function scanwhite (str, pos)
- while true do
- pos = strfind (str, "%S", pos)
- if not pos then return nil end
- local sub2 = strsub (str, pos, pos + 1)
- if sub2 == "\239\187" and strsub (str, pos + 2, pos + 2) == "\191" then
- -- UTF-8 Byte Order Mark
- pos = pos + 3
- elseif sub2 == "//" then
- pos = strfind (str, "[\n\r]", pos + 2)
- if not pos then return nil end
- elseif sub2 == "/*" then
- pos = strfind (str, "*/", pos + 2)
- if not pos then return nil end
- pos = pos + 2
- else
- return pos
- end
- end
-end
-
-local escapechars = {
- ["\""] = "\"", ["\\"] = "\\", ["/"] = "/", ["b"] = "\b", ["f"] = "\f",
- ["n"] = "\n", ["r"] = "\r", ["t"] = "\t"
-}
-
-local function unichar (value)
- if value < 0 then
- return nil
- elseif value <= 0x007f then
- return strchar (value)
- elseif value <= 0x07ff then
- return strchar (0xc0 + floor(value/0x40),
- 0x80 + (floor(value) % 0x40))
- elseif value <= 0xffff then
- return strchar (0xe0 + floor(value/0x1000),
- 0x80 + (floor(value/0x40) % 0x40),
- 0x80 + (floor(value) % 0x40))
- elseif value <= 0x10ffff then
- return strchar (0xf0 + floor(value/0x40000),
- 0x80 + (floor(value/0x1000) % 0x40),
- 0x80 + (floor(value/0x40) % 0x40),
- 0x80 + (floor(value) % 0x40))
- else
- return nil
- end
-end
-
-local function scanstring (str, pos)
- local lastpos = pos + 1
- local buffer, n = {}, 0
- while true do
- local nextpos = strfind (str, "[\"\\]", lastpos)
- if not nextpos then
- return unterminated (str, "string", pos)
- end
- if nextpos > lastpos then
- n = n + 1
- buffer[n] = strsub (str, lastpos, nextpos - 1)
- end
- if strsub (str, nextpos, nextpos) == "\"" then
- lastpos = nextpos + 1
- break
- else
- local escchar = strsub (str, nextpos + 1, nextpos + 1)
- local value
- if escchar == "u" then
- value = tonumber (strsub (str, nextpos + 2, nextpos + 5), 16)
- if value then
- local value2
- if 0xD800 <= value and value <= 0xDBff then
- -- we have the high surrogate of UTF-16. Check if there is a
- -- low surrogate escaped nearby to combine them.
- if strsub (str, nextpos + 6, nextpos + 7) == "\\u" then
- value2 = tonumber (strsub (str, nextpos + 8, nextpos + 11), 16)
- if value2 and 0xDC00 <= value2 and value2 <= 0xDFFF then
- value = (value - 0xD800) * 0x400 + (value2 - 0xDC00) + 0x10000
- else
- value2 = nil -- in case it was out of range for a low surrogate
- end
- end
- end
- value = value and unichar (value)
- if value then
- if value2 then
- lastpos = nextpos + 12
- else
- lastpos = nextpos + 6
- end
- end
- end
- end
- if not value then
- value = escapechars[escchar] or escchar
- lastpos = nextpos + 2
- end
- n = n + 1
- buffer[n] = value
- end
- end
- if n == 1 then
- return buffer[1], lastpos
- elseif n > 1 then
- return concat (buffer), lastpos
- else
- return "", lastpos
- end
-end
-
-local scanvalue -- forward declaration
-
-local function scantable (what, closechar, str, startpos, nullval, objectmeta, arraymeta)
- local len = strlen (str)
- local tbl, n = {}, 0
- local pos = startpos + 1
- if what == 'object' then
- setmetatable (tbl, objectmeta)
- else
- setmetatable (tbl, arraymeta)
- end
- while true do
- pos = scanwhite (str, pos)
- if not pos then return unterminated (str, what, startpos) end
- local char = strsub (str, pos, pos)
- if char == closechar then
- return tbl, pos + 1
- end
- local val1, err
- val1, pos, err = scanvalue (str, pos, nullval, objectmeta, arraymeta)
- if err then return nil, pos, err end
- pos = scanwhite (str, pos)
- if not pos then return unterminated (str, what, startpos) end
- char = strsub (str, pos, pos)
- if char == ":" then
- if val1 == nil then
- return nil, pos, "cannot use nil as table index (at " .. loc (str, pos) .. ")"
- end
- pos = scanwhite (str, pos + 1)
- if not pos then return unterminated (str, what, startpos) end
- local val2
- val2, pos, err = scanvalue (str, pos, nullval, objectmeta, arraymeta)
- if err then return nil, pos, err end
- tbl[val1] = val2
- pos = scanwhite (str, pos)
- if not pos then return unterminated (str, what, startpos) end
- char = strsub (str, pos, pos)
- else
- n = n + 1
- tbl[n] = val1
- end
- if char == "," then
- pos = pos + 1
- end
- end
-end
-
-local level = 0
-
-scanvalue = function (str, pos, nullval, objectmeta, arraymeta)
- pos = pos or 1
- pos = scanwhite (str, pos)
- if not pos then
- return nil, strlen (str) + 1, "no valid JSON value (reached the end)"
- end
- local char = strsub (str, pos, pos)
- if char == "{" then
- level = level + 1
-
- return scantable ('object', "}", str, pos, nullval, objectmeta, arraymeta)
- elseif char == "[" then
- return scantable ('array', "]", str, pos, nullval, objectmeta, arraymeta)
- elseif char == "\"" then
- return scanstring (str, pos)
- else
- local pstart, pend = strfind (str, "^%-?[%d%.]+[eE]?[%+%-]?%d*", pos)
- if pstart then
- local number = str2num (strsub (str, pstart, pend))
- if type(number) == 'number' then -- FIXME: change to 'if number then' when neolua bug is fixed
- return number, pend + 1
- end
- end
- pstart, pend = strfind (str, "^%a%w*", pos)
- if pstart then
- local name = strsub (str, pstart, pend)
- if name == "true" then
- return true, pend + 1
- elseif name == "false" then
- return false, pend + 1
- elseif name == "null" then
- return nullval, pend + 1
- end
- end
- return nil, pos, "no valid JSON value at " .. loc (str, pos)
- end
-end
-
-function json.decode (str, pos, nullval, ...)
- local objectmeta, arraymeta = {__jsontype = 'object'}, {__jsontype = 'array'}
- return scanvalue (str, pos, nullval, objectmeta, arraymeta)
-end
-
-function json.use_lpeg ()
- local g = require ("lpeg")
-
- if g.version() == "0.11" then
- error "due to a bug in LPeg 0.11, it cannot be used for JSON matching"
- end
-
- local pegmatch = g.match
- local P, S, R = g.P, g.S, g.R
-
- local function ErrorCall (str, pos, msg, state)
- if not state.msg then
- state.msg = msg .. " at " .. loc (str, pos)
- state.pos = pos
- end
- return false
- end
-
- local function Err (msg)
- return g.Cmt (g.Cc (msg) * g.Carg (2), ErrorCall)
- end
-
- local SingleLineComment = P"//" * (1 - S"\n\r")^0
- local MultiLineComment = P"/*" * (1 - P"*/")^0 * P"*/"
- local Space = (S" \n\r\t" + P"\239\187\191" + SingleLineComment + MultiLineComment)^0
-
- local PlainChar = 1 - S"\"\\\n\r"
- local EscapeSequence = (P"\\" * g.C (S"\"\\/bfnrt" + Err "unsupported escape sequence")) / escapechars
- local HexDigit = R("09", "af", "AF")
- local function UTF16Surrogate (match, pos, high, low)
- high, low = tonumber (high, 16), tonumber (low, 16)
- if 0xD800 <= high and high <= 0xDBff and 0xDC00 <= low and low <= 0xDFFF then
- return true, unichar ((high - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000)
- else
- return false
- end
- end
- local function UTF16BMP (hex)
- return unichar (tonumber (hex, 16))
- end
- local U16Sequence = (P"\\u" * g.C (HexDigit * HexDigit * HexDigit * HexDigit))
- local UnicodeEscape = g.Cmt (U16Sequence * U16Sequence, UTF16Surrogate) + U16Sequence/UTF16BMP
- local Char = UnicodeEscape + EscapeSequence + PlainChar
- local String = P"\"" * g.Cs (Char ^ 0) * (P"\"" + Err "unterminated string")
- local Integer = P"-"^(-1) * (P"0" + (R"19" * R"09"^0))
- local Fractal = P"." * R"09"^0
- local Exponent = (S"eE") * (S"+-")^(-1) * R"09"^1
- local Number = (Integer * Fractal^(-1) * Exponent^(-1))/str2num
- local Constant = P"true" * g.Cc (true) + P"false" * g.Cc (false) + P"null" * g.Carg (1)
- local SimpleValue = Number + String + Constant
- local ArrayContent, ObjectContent
-
- -- The functions parsearray and parseobject parse only a single value/pair
- -- at a time and store them directly to avoid hitting the LPeg limits.
- local function parsearray (str, pos, nullval, state)
- local obj, cont
- local npos
- local t, nt = {}, 0
- repeat
- obj, cont, npos = pegmatch (ArrayContent, str, pos, nullval, state)
- if not npos then break end
- pos = npos
- nt = nt + 1
- t[nt] = obj
- until cont == 'last'
- return pos, setmetatable (t, state.arraymeta)
- end
-
- local function parseobject (str, pos, nullval, state)
- local obj, key, cont
- local npos
- local t = {}
- repeat
- key, obj, cont, npos = pegmatch (ObjectContent, str, pos, nullval, state)
- if not npos then break end
- pos = npos
- t[key] = obj
- until cont == 'last'
- return pos, setmetatable (t, state.objectmeta)
- end
-
- local Array = P"[" * g.Cmt (g.Carg(1) * g.Carg(2), parsearray) * Space * (P"]" + Err "']' expected")
- local Object = P"{" * g.Cmt (g.Carg(1) * g.Carg(2), parseobject) * Space * (P"}" + Err "'}' expected")
- local Value = Space * (Array + Object + SimpleValue)
- local ExpectedValue = Value + Space * Err "value expected"
- ArrayContent = Value * Space * (P"," * g.Cc'cont' + g.Cc'last') * g.Cp()
- local Pair = g.Cg (Space * String * Space * (P":" + Err "colon expected") * ExpectedValue)
- ObjectContent = Pair * Space * (P"," * g.Cc'cont' + g.Cc'last') * g.Cp()
- local DecodeValue = ExpectedValue * g.Cp ()
-
- function json.decode (str, pos, nullval, ...)
- local state = {}
- state.objectmeta, state.arraymeta = optionalmetatables(...)
- local obj, retpos = pegmatch (DecodeValue, str, pos, nullval, state)
- if state.msg then
- return nil, state.pos, state.msg
- else
- return obj, retpos
- end
- end
-
- -- use this function only once:
- json.use_lpeg = function () return json end
-
- json.using_lpeg = true
-
- return json -- so you can get the module using json = require "dkjson".use_lpeg()
-end
-
-return json
diff --git a/system/resource_init.lua b/system/resource_init.lua
deleted file mode 100644
index 349ff87..0000000
--- a/system/resource_init.lua
+++ /dev/null
@@ -1,289 +0,0 @@
--- local resource init stuff (similar to client resource_init)
-RegisterInitHandler(function(initScript, isPreParse)
- local env = {
- _VERSION = _VERSION,
- assert = assert,
- error = error,
- getmetatable = getmetatable,
- ipairs = ipairs,
- next = next,
- pairs = pairs,
- pcall = pcall,
- print = print,
- rawequal = rawequal,
- rawget = rawget,
- rawlen = rawlen,
- rawset = rawset,
- select = select,
- setmetatable = setmetatable,
- tonumber = tonumber,
- tostring = tostring,
- type = type,
- xpcall = xpcall,
- bit32 = {
- arshift = bit32.arshift,
- band = bit32.band,
- bnot = bit32.bnot,
- bor = bit32.bor,
- btest = bit32.btest,
- bxor = bit32.bxor,
- extract = bit32.extract,
- lrotate = bit32.lrotate,
- lshift = bit32.lshift,
- replace = bit32.replace,
- rrotate = bit32.rrotate,
- rshift = bit32.rshift
- },
- coroutine = {
- create = coroutine.create,
- resume = coroutine.resume,
- running = coroutine.running,
- status = coroutine.status,
- wrap = coroutine.wrap,
- yield = coroutine.yield
- },
- math = {
- abs = math.abs,
- acos = math.acos,
- asin = math.asin,
- atan = math.atan,
- atan2 = math.atan2,
- ceil = math.ceil,
- cos = math.cos,
- cosh = math.cosh,
- deg = math.deg,
- exp = math.exp,
- floor = math.floor,
- fmod = math.fmod,
- frexp = math.frexp,
- huge = math.huge,
- ldexp = math.ldexp,
- log = math.log,
- max = math.max,
- min = math.min,
- modf = math.modf,
- pi = math.pi,
- pow = math.pow,
- rad = math.rad,
- random = math.random,
- randomseed = math.randomseed,
- sin = math.sin,
- sinh = math.sinh,
- sqrt = math.sqrt,
- tan = math.tan,
- tanh = math.tanh
- },
- string = {
- byte = string.byte,
- char = string.char,
- dump = string.dump,
- find = string.find,
- format = string.format,
- gmatch = string.gmatch,
- gsub = string.gsub,
- len = string.len,
- lower = string.lower,
- match = string.match,
- rep = string.rep,
- reverse = string.reverse,
- sub = string.sub,
- upper = string.upper
- },
- table = {
- concat = table.concat,
- insert = table.insert,
- pack = table.pack,
- remove = table.remove,
- sort = table.sort,
- unpack = table.unpack
- }
- }
-
- TriggerEvent('getResourceInitFuncs', isPreParse, function(key, cb)
- env[key] = cb
- end)
-
- local pr = print
-
- if not isPreParse then
- env.server_scripts = function(n)
- if type(n) == 'string' then
- n = { n }
- end
-
- for _, d in ipairs(n) do
- AddServerScript(d)
- end
- end
-
- env.server_script = env.server_scripts
- else
- -- and add our native items
- env.solution = function(n)
- SetResourceInfo('clr_solution', n)
- end
-
- env.description = function(n)
- SetResourceInfo('description', n)
- end
-
- env.version = function(n)
- SetResourceInfo('version', n)
- end
-
- env.client_scripts = function(n)
- if type(n) == 'string' then
- n = { n }
- end
-
- for _, d in ipairs(n) do
- AddClientScript(d)
- end
- end
-
- env.client_script = env.client_scripts
-
- env.files = function(n)
- if type(n) == 'string' then
- n = { n }
- end
-
- for _, d in ipairs(n) do
- AddAuxFile(d)
- end
- end
-
- env.file = env.files
-
- env.dependencies = function(n)
- if type(n) == 'string' then
- n = { n }
- end
-
- for _, d in ipairs(n) do
- AddResourceDependency(d)
- end
- end
-
- env.dependency = env.dependencies
- end
-
- local rawget_ = rawget
- local print_ = print
-
- local mt = {
- __index = function(t, k) : object
- if env[k] ~= nil then
- return env[k]
- end
-
- if rawget_(t, k) ~= nil then
- return rawget_(t, k)
- end
-
- -- as we're not going to return nothing here (to allow unknown directives to be ignored)
- local f = function()
- return f
- end
-
- return function() return f end
- end
- }
-
- for k, v in pairs(env) do
- if type(v) == 'function' then
- env[k] = function(...)
- _G.__metatable = nil
-
- local rv = v(...)
-
- _G.__metatable = mt
-
- return rv
- end
- end
- end
-
- _G.__metatable = mt
- --setmetatable(env, mt)
- --setfenv(initScript, env)
-
- initScript()
-
- --env = nil
-
- --setfenv(initScript, _G)
-
- _G.__metatable = nil
-
--- print('rc', findallpaths(rt))
-end)
-
--- nothing, yet
-
--- TODO: cleanup RPC environment stuff on coroutine end/error
-local function RunRPCFunction(f, env)
- local co = coroutine.create(f)
- env.__co = client
-
- local success, err = coroutine.resume(co)
-
- if success then
- env.SendEvents()
- else
- print(err)
- end
-end
-
-local rpcIdx = 1
-local rpcEnvironments = {}
-
-function CreateRPCContext(cl, f)
- local idx = rpcIdx
- rpcIdx = rpcIdx + 1
-
- local key = cl .. '_' .. idx
-
- local env = {
- getIdx = function()
- return idx
- end,
- getSource = function()
- return cl
- end
- }
-
- local lastEnv = _ENV
-
- setmetatable(env, {__index = _G})
-
- local _ENV = env
- rpcEnvironments[key] = env
-
- setfenv(f, env)
-
- local fRun = f()
-
- local virtenv_init = loadfile('system/virtenv_init.lua', 't', env)
- virtenv_init()
-
- _ENV = lastEnv
-
- RunRPCFunction(fRun, env)
-end
-
-RegisterServerEvent('svRpc:results')
-
-AddEventHandler('svRpc:results', function(results)
- if not results.idx then
- return
- end
-
- local key = source .. '_' .. results.idx
-
- if not rpcEnvironments[key] then
- return
- end
-
- rpcEnvironments[key].HandleResults(results)
-end)
diff --git a/system/virtenv_init.lua b/system/virtenv_init.lua
deleted file mode 100644
index 998a755..0000000
--- a/system/virtenv_init.lua
+++ /dev/null
@@ -1,99 +0,0 @@
-local execQueue = {}
-local execQueueArgNum = 1
-local execResults = {}
-local curRoutine
-
-_i = { _a = '_i' }
-_f = { _a = '_f' }
-
-function GetResult(argNum)
- if not execResults[argNum] then
- if #execQueue > 0 then
- execQueue.idx = getIdx()
-
- curRoutine = coroutine.running()
- coroutine.yield()
-
- execQueue = {}
- end
- end
-
- local r = execResults[argNum]
- execResults[argNum] = nil
-
- return r
-end
-
-function HandleResults(results)
- for k, v in pairs(results) do
- execResults[k] = v
- end
-
- if coroutine.status(curRoutine) == 'dead' then
- return
- end
-
- local success, err = coroutine.resume(curRoutine)
-
- if success then
- SendEvents({ getSource = getSource })
- else
- print(err)
- end
-end
-
-function SendEvents(env)
- TriggerClientEvent('svRpc:run', getSource(), 10, execQueue)
-end
-
-function CallNative(hash, ...)
- local arguments = {}
- local returns = {}
-
- local arg = {...}
-
- for i, v in ipairs(arg) do
- local a = v
-
- if type(v) == 'table' then
- if v._a then
- if v._a == '_i' or v._a == '_f' then
- a._i = execQueueArgNum
- execQueueArgNum = execQueueArgNum + 1
-
- local fakeRetVal = {
- _a = '_z',
- _i = a._i
- }
-
- -- this will only work in Lua 5.2+; as metamethod yielding got added there
- setmetatable(fakeRetVal, {
- __call = function()
- if not fakeRetVal._value then
- fakeRetVal._value = GetResult(fakeRetVal._i)
- end
-
- return fakeRetVal._value
- end
- })
-
- table.insert(returns, fakeRetVal)
- end
- end
- end
-
- table.insert(arguments, a)
- end
-
- table.insert(execQueue, {
- h = hash,
- a = arguments
- })
-
- return table.unpack(returns)
-end
-
-function PrintStringWithLiteralString(...) return CallNative(0x3F89280B, ...) end
-function PrintStringWithLiteralStringNow(...) return CallNative(0xCA539D6, ...) end
-function GetCharCoordinates(...) return CallNative(0x2B5C06E6, ...) end
-function GetPlayerChar(...) return CallNative(0x511454A9, ...) end