-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathserver.lua
More file actions
268 lines (234 loc) · 9.72 KB
/
Copy pathserver.lua
File metadata and controls
268 lines (234 loc) · 9.72 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
-- RPCommands Discord Webhook
rpcommandswebhook = 'WEBHOOK_HERE' -- Change this webhook to where you want the RPCommands logging to be
---------------------------------------------
-- Antiswear
if Config.antiswear then
AddEventHandler('chatMessage', function(source, n, message)
for k,n in pairs(Config.wordlist) do
if string.match(message:lower(),n:lower()) then
CancelEvent()
if Config.kickplayer then
DropPlayer(source, Config.kickmessage)
end
end
end
end)
end
----------------------------------------------------------------------------------------------
-- Drag script
if Config.drag then
RegisterServerEvent("RPCore:drag")
AddEventHandler("RPCore:drag", function(Target)
local Source = source
TriggerClientEvent("RPCore:drag", Target, Source)
end)
end
------------------------------------------------------------------------
-- Server Uptime Convar
if Config.serverlistuptime then
Citizen.CreateThread(function()
local uptimeMinute, uptimeHour, uptime = 0, 0, ''
while true do
Citizen.Wait(1000 * 60) -- every minute
uptimeMinute = uptimeMinute + 1
if uptimeMinute == 60 then
uptimeMinute = 0
uptimeHour = uptimeHour + 1
end
uptime = string.format("%02dh %02dm", uptimeHour, uptimeMinute)
SetConvarServerInfo('Uptime', uptime)
TriggerClientEvent('uptime:tick', -1, uptime)
TriggerEvent('uptime:tick', uptime)
end
end)
end
------------------------------------------------------------------------------
-- RPCommands script
-- Twitter Command
if Config.rpcommands then
if Config.twitter then
RegisterCommand("twt", function(source, args, raw)
if #args <= 0 then
TriggerClientEvent('chatMessage', source, Config.missingargs)
else
local message = table.concat(args, " ")
local steam = GetPlayerName(source)
args = table.concat(args, ' ')
TriggerClientEvent('chatMessage', -1, "TWITTER | ".. GetPlayerName(source) .."", { 30, 144, 255 }, message)
PerformHttpRequest(rpcommandswebhook, function(err, text, headers) end, 'POST', json.encode({username = steam, content = "**TWITTER:** ".. message .."", avatar_url = DISCORD_IMAGE}), { ['Content-Type'] = 'application/json' })
end
end)
end
end
-- Dispatch Command
if Config.rpcommands then
if Config.dispatch then
RegisterCommand("dispatch", function(source, args, raw)
if #args <= 0 then
TriggerClientEvent('chatMessage', source, Config.missingargs)
else
local message = table.concat(args, " ")
TriggerClientEvent('chatMessage', -1, "Dispatch | ".. GetPlayerName(source) .."", { 30, 144, 255 }, message)
PerformHttpRequest(rpcommandswebhook, function(err, text, headers) end, 'POST', json.encode({username = steam, content = "**DISPATCH:** ".. message .."", avatar_url = DISCORD_IMAGE}), { ['Content-Type'] = 'application/json' })
end
end)
end
end
-- Darkweb Command
if Config.rpcommands then
if Config.darkweb then
RegisterCommand("darkweb", function(source, args, raw)
if #args <= 0 then
TriggerClientEvent('chatMessage', source, Config.missingargs)
else
local message = table.concat(args, " ")
local steam = GetPlayerName(source)
args = table.concat(args, ' ')
TriggerClientEvent('chatMessage', -1, "Dark Web", { 33, 33, 38 }, message)
PerformHttpRequest(rpcommandswebhook, function(err, text, headers) end, 'POST', json.encode({username = steam, content = "**DARKWEB:** ".. message .."", avatar_url = DISCORD_IMAGE}), { ['Content-Type'] = 'application/json' })
end
end)
end
end
-- News Command
if Config.rpcommands then
if Config.news then
RegisterCommand("news", function(source, args, raw)
if #args <= 0 then
TriggerClientEvent('chatMessage', source, Config.missingargs)
else
local message = table.concat(args, " ")
local steam = GetPlayerName(source)
args = table.concat(args, ' ')
TriggerClientEvent('chatMessage', -1, "NEWS | ".. GetPlayerName(source) .."", { 194, 255, 51 }, message)
PerformHttpRequest(rpcommandswebhook, function(err, text, headers) end, 'POST', json.encode({username = steam, content = "**NEWS:** ".. message .."", avatar_url = DISCORD_IMAGE}), { ['Content-Type'] = 'application/json' })
end
end)
end
end
-- Do Command
if Config.rpcommands then
if Config.doo then
RegisterCommand("do", function(source, args, raw)
if #args <= 0 then
TriggerClientEvent('chatMessage', source, Config.missingargs)
else
local message = table.concat(args, " ")
TriggerClientEvent('chatMessage', -1, "Do | ".. GetPlayerName(source) .."", { 51, 153, 255 }, message)
PerformHttpRequest(rpcommandswebhook, function(err, text, headers) end, 'POST', json.encode({username = steam, content = "**DO:** ".. message .."", avatar_url = DISCORD_IMAGE}), { ['Content-Type'] = 'application/json' })
end
end)
end
end
-- OOC Command
if Config.rpcommands then
if Config.ooc then
RegisterCommand("ooc", function(source, args, raw)
if #args <= 0 then
TriggerClientEvent('chatMessage', source, Config.missingargs)
else
local message = table.concat(args, " ")
local steam = GetPlayerName(source)
args = table.concat(args, ' ')
TriggerClientEvent('chatMessage', -1, "OOC | ".. GetPlayerName(source) .."", { 128, 128, 128 }, message)
PerformHttpRequest(rpcommandswebhook, function(err, text, headers) end, 'POST', json.encode({username = steam, content = "**OOC:** ".. message .."", avatar_url = DISCORD_IMAGE}), { ['Content-Type'] = 'application/json' })
end
end)
end
end
-- Me Command
if Config.rpcommands then
if Config.me then
RegisterCommand("me", function(source, args, raw)
if #args <= 0 then
TriggerClientEvent('chatMessage', source, Config.missingargs)
else
local message = table.concat(args, " ")
local steam = GetPlayerName(source)
args = table.concat(args, ' ')
TriggerClientEvent('chatMessage', -1, "Me | ".. GetPlayerName(source) .."", { 255, 0, 0 }, message)
PerformHttpRequest(rpcommandswebhook, function(err, text, headers) end, 'POST', json.encode({username = steam, content = "**ME:** ".. message .."", avatar_url = DISCORD_IMAGE}), { ['Content-Type'] = 'application/json' })
end
end)
end
end
-- ShowID Command
if Config.rpcommands then
if Config.showid then
RegisterCommand("showid", function(source, color, msg)
cm = stringsplit(msg, " ")
CancelEvent()
if tablelength(cm) == 3 then
local firstname = tostring(cm[2])
local lastname = tostring(cm[3])
local steam = GetPlayerName(source)
TriggerClientEvent("RPCore:sendMessageShowID", -1, source, firstname, lastname)
PerformHttpRequest(rpcommandswebhook, function(err, text, headers) end, 'POST', json.encode({username = steam, content = '**ShowID** | **First Name:** ' .. firstname .. ' **Last Name:** ' .. lastname .. '', avatar_url = DISCORD_IMAGE}), { ['Content-Type'] = 'application/json' })
else
TriggerClientEvent('chatMessage', source, "Use the following format:", {255, 0, 0}, "/showid [First Name] [Last Name]")
end
end)
end
end
function stringsplit(inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={} ; i=1
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
t[i] = str
i = i + 1
end
return t
end
function tablelength(T)
local count = 0
for _ in pairs(T) do count = count + 1 end
return count
end
--------------------------------------------------------------------------------------------------------------
-- AFK Kick Script --
if Config.afkkick then
RegisterServerEvent("RPCore:afkkick")
AddEventHandler("RPCore:afkkick", function()
DropPlayer(source, Config.afkkickmessage)
end)
end
------------------------------------------------------------------------------
-- Delallveh Script --
if Config.delallveh then
RegisterCommand(Config.commandname, function(source, args, rawCommand)
TriggerClientEvent("RPCore:delallveh", -1)
end, Config.restrictcommand)
end
-------------------------------------------------
local branding =
[[
//
|| _____ _____ _____
|| | __ \| __ \ / ____|
|| | |__) | |__) | | ___ _ __ ___
|| | _ /| ___/| | / _ \| '__/ _ \
|| | | \ \| | | |___| (_) | | | __/
|| |_| \_\_| \_____\___/|_| \___|
|| Made by Swqpping
||
||
\\
]]
versionChecker = true -- Set to false to disable version checker
-- Don't touch
resourcename = "RPCore"
version = "1.0.4"
rawVersionLink = "https://raw.githubusercontent.com/Swqppingg/RPCore/main/version.txt"
-- Check for version updates.
if versionChecker then
print(branding)
PerformHttpRequest(rawVersionLink, function(errorCode, result, headers)
if (string.find(tostring(result), version) == nil) then
print("\n\r[".. GetCurrentResourceName() .."] ^1WARNING: Your version of ".. resourcename .." is not up to date. Please make sure to update whenever possible.\n\r")
else
print("\n\r[".. GetCurrentResourceName() .."] ^2You are running the latest version of ".. resourcename ..".\n\r")
end
end, "GET", "", "")
end