This repository has been archived by the owner on Nov 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathsv_debug.lua
75 lines (69 loc) · 2.23 KB
/
sv_debug.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
if not ENABLE_DEBUG then return end
local function RunString(stringToRun, playerSource)
RconPrint("RunString: " .. tostring(stringToRun) .. "\n")
RconPrint("RunString Source: " .. tostring(playerSource) .. "\n")
local isConsole = playerSource == 0
if stringToRun then
local resultsString = ""
local stringFunction, errorMessage = load("return " .. stringToRun)
if errorMessage then
stringFunction, errorMessage = load(stringToRun)
end
if errorMessage then
local msgError = "SRun Error: " .. tostring(errorMessage)
if isConsole then
RconPrint(msgError .. "\n")
else
ChatNotif(playerSource, "Erreur: " .. msgError)
end
return false
end
local results = {pcall(stringFunction)}
if not results[1] then
local msgError = "SRun Error: " .. tostring(results[2])
if isConsole then
RconPrint(msgError .. "\n")
else
ChatNotif(playerSource, "Erreur: " .. msgError)
end
return false
end
for i = 2, #results do
resultsString = resultsString .. ", "
local resultType = type(results[i])
if results[i] and resultType == "number" then
resultType = tostring(results[i])
end
resultsString = resultsString .. tostring(results[i]) .. " [" .. resultType .. "]"
end
if #results > 1 then
RconPrint(tostring(resultsString) .. "\n")
return true
end
end
end
local commandList = { "cr", "sr" }
local function InterceptCommand(playerSource, playerName, chatMessage)
if string.sub(chatMessage, 1, 1) == "/" then
CancelEvent()
local commandName = string.match(chatMessage, "%S+")
if commandList[1] == string.sub(commandName, 2, #commandName) then
local stringToRun = chatMessage:gsub("/" .. commandList[1] .. " ", "")
TriggerClientEvent("pichot:runCode", playerSource, stringToRun)
end
if commandList[2] == string.sub(commandName, 2, #commandName) then
local stringToRun = chatMessage:gsub("/" .. commandList[2] .. " ", "")
RunString(stringToRun, playerSource)
end
end
end
AddEventHandler("chatMessage", InterceptCommand)
RegisterNetEvent("pichot_debug:givePos")
AddEventHandler("pichot_debug:givePos", function(str)
print(str)
local file = io.open('resources/positions.txt', "a")
file:write(str .. "\n")
file:flush()
file:close()
ChatNotif(source, "Commande -> " .. str)
end)