chore: initial commit

This commit is contained in:
Romain Lanz
2017-09-14 22:58:01 +02:00
commit e544c17fb3
9 changed files with 783 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
function displayPermissionIssue ()
TriggerClientEvent('chatMessage', source, 'SYSTEM', { 255, 0, 0 }, 'Insufficienct permissions!')
end
TriggerEvent('es:addGroupCommand', 'whitelist:load', 'admin', function (source, args, user)
loadWhiteList()
end, function (source, args, user)
displayPermissionIssue(source)
end, { help = _U('help_whitelist_load') })
TriggerEvent('es:addGroupCommand', 'whitelist:add', 'admin', function (source, args, user)
local steamID = 'steam:' .. args[2]
MySQL.Async.execute(
'INSERT INTO whitelist (identifier) VALUES (@identifier)',
{ ['@identifier'] = tostring(steamID) },
function ()
loadWhiteList()
end
)
end, function (source, args, user)
displayPermissionIssue(source)
end, { help = _U('help_whitelist_add'), params = { steam = 'SteamID', help = 'SteamID formated to hex' }})
+42
View File
@@ -0,0 +1,42 @@
WhiteList = {}
function loadWhiteList ()
MySQL.Async.fetchAll(
'SELECT * FROM whitelist',
{},
function (identifiers)
for i=1, #identifiers, 1 do
table.insert(WhiteList, tostring(identifiers[i].identifier))
end
end
)
end
MySQL.ready(function ()
loadWhiteList()
end)
AddEventHandler('playerConnecting', function (playerName, setKickReason)
if (WhiteList == {}) then
Citizen.Wait(1000)
end
local whitelisted = false
local steamID = GetPlayerIdentifiers(source)[1] or false
if steamID == false then
setKickReason(_U('steamid_error'))
CancelEvent()
end
for i = 1, #WhiteList, 1 do
if (tostring(WhiteList[i]) == tostring(steamID)) then
whitelisted = true
end
end
if whitelisted == false then
setKickReason(_U('not_whitelisted'))
CancelEvent()
end
end)