So here is the scoop.
I am trying to identify a ban inside of MySQL database, and then if the Steam Identifier is found, it would Cancel connecting, (or CancelEvent()) and then setReason saying you were banned from the server
What is the issue?
The issue is when calling either Sync or Async in MySQL, I cannot seem to use CancelEvent(), as I can just effortlessly join the server, despite being in the database listed under my banned players table. I have read something on GitHub saying that Sync wouldn’t work with it, so I tried using Async to get it to work, with no avail.
Code
OnPlayerConnecting Fucntion
local function OnPlayerConnecting(name, setReason, deferrals)
checkBan = BanCheck(steamIdentifier, banReason, banAdmin, banTime)
if checkBan == true then
setReason("YOU ARE BANNED FROM PROJECT REALITY")
CancelEvent()
end
end
BanCheck Function w/ MySQL command inside
function BanCheck(steamIdentifier, banReason, banAdmin, banTime)
count = 0
MySQL.Async.fetchAll("SELECT * FROM bans", {}, function(findBan)
for _, __ in pairs(findBan) do
count = count + 1
print(findBan[count].SteamID)
if findBan[count].SteamID == steamIdentifier then
return true
end
end
end)
return false
end
Everything given should hopefully be enough for you to understand whats going on here. Anyway, if there is anything else I absolutely need to add to this post, I will as soon as i can.
Thanks B)