Snow-Man Posted December 23, 2016 Share Posted December 23, 2016 hey can you help me to fix my ban system? bansTable = {} function addBanPlayer(admin, player, reason, time) if not admin or not player or type(reason) ~= "string" or type(time) ~= "number" then return false end timer = math.floor(time) if (timer < 0 and timer ~= -1) then return false end for _, v in pairs(bansTable) do if (v[1] == admin) then return false end local timer = getRealTime().timestamp+timer exports.USCsql:exec("INSERT INTO `bans` (`admin`, `player`, `reason`, `duration`, `IP`) VALUES (?, ?, ?, ?)", admin, player, reason, timer, getPlayerIP(player) ) table.insert(bansTable, {admin, player, reason, timer, ip}) end end Link to comment
pa3ck Posted December 23, 2016 Share Posted December 23, 2016 What is wrong with it? What has to be fixed? Link to comment
Snow-Man Posted December 23, 2016 Author Share Posted December 23, 2016 when i ban someone it doesn't work, i mean when someone join to server function checkPIFBanned() if isPlayerBanned(getPlayerIP(source)) then local ban = exports.USCsql:queryData("SELECT `admin`,`player`,`reason`,`duration` FROM `bans` WHERE `IP`=?", getPlayerSerial(source)) triggerClientEvent(source, "drawDXBanScreen", source, ban.admin, ban.player, ban.reason, ban.duration) end end addEventHandler("onPlayerJoin", root, checkPIFBanned) Link to comment
Best-Killer Posted December 23, 2016 Share Posted December 23, 2016 (edited) i'm not sure but try this function checkPIFBanned() if isPlayerBanned(getPlayerIP(source)) then local ban = exports.USCsql:queryData("SELECT `admin`,`player`,`reason`,`duration` FROM `bans` WHERE `IP`=?", getPlayerSerial(source)) for i, v in ipairs(ban) do triggerClientEvent(source, "drawDXBanScreen", source, {v["admin"], v["player"], v["reason"], v["duration"]}) end end end addEventHandler("onPlayerJoin", root, checkPIFBanned) Edited December 23, 2016 by Best-Killer Link to comment
Snow-Man Posted December 23, 2016 Author Share Posted December 23, 2016 the same thing doesn't work and there's no debug message Link to comment
Best-Killer Posted December 23, 2016 Share Posted December 23, 2016 post the client side ( drawDXBanScreen ) and check the server side that i gived you !!! cuz i edited it Link to comment
Snow-Man Posted December 23, 2016 Author Share Posted December 23, 2016 (edited) i know man, i made client side before because to draw ban if player banned with events addEvent, addEventHandler, and event "onClientRender" for dx texts Edited December 23, 2016 by Snow-Man Link to comment
pa3ck Posted December 24, 2016 Share Posted December 24, 2016 Post your whole server/client scripts for the ban resource. Link to comment
Risk Posted December 24, 2016 Share Posted December 24, 2016 dbQuery returns a table like this: result = { { key = value } } even if you get a single row use result[1]. In your case it would be ban[1]. However, that's just a guess. Why are you using the column name IP and you store player's serial in it? I'd recommend to rename the column to serial so people know what's stored inside it. Link to comment
Snow-Man Posted December 28, 2016 Author Share Posted December 28, 2016 On Saturday, December 24, 2016 at 10:01 PM, pa3ck said: Post your whole server/client scripts for the ban resource. The Rest Server Side Is Exports And About Client I Have Added Dxtext To Draw Ban Link to comment
Snow-Man Posted December 28, 2016 Author Share Posted December 28, 2016 5 minutes ago, MR.GRAND said: i have made function to check if player banned or no is it incorrect idea about coding? Link to comment
MR.GRAND Posted December 28, 2016 Share Posted December 28, 2016 (edited) 8 minutes ago, Snow-Man said: i have made function to check if player banned or no is it incorrect idea about coding? At the top you inserted player ip in this column so why you check the serial instead of ip if u used that before ? Edited December 28, 2016 by MR.GRAND Link to comment
Snow-Man Posted December 28, 2016 Author Share Posted December 28, 2016 i just want to get if player banned then draw text and cancel login Link to comment
MR.GRAND Posted December 28, 2016 Share Posted December 28, 2016 3 minutes ago, Snow-Man said: i just want to get if player banned then draw text and cancel login Try this function checkPIFBanned() if isPlayerBanned(getPlayerIP(source)) then local ban = exports.USCsql:queryData("SELECT `admin`,`player`,`reason`,`duration` FROM `bans` WHERE `IP`=?", getPlayerIP(source)) triggerClientEvent(source, "drawDXBanScreen", source, ban[1]['admin'], ban[1]['player'], ban[1]['reason'], ban[1]['duration']) end end addEventHandler("onPlayerJoin", root, checkPIFBanned) Link to comment
Snow-Man Posted January 2, 2017 Author Share Posted January 2, 2017 On 12/28/2016 at 10:09 PM, MR.GRAND said: Try this function checkPIFBanned() if isPlayerBanned(getPlayerIP(source)) then local ban = exports.USCsql:queryData("SELECT `admin`,`player`,`reason`,`duration` FROM `bans` WHERE `IP`=?", getPlayerIP(source)) triggerClientEvent(source, "drawDXBanScreen", source, ban[1]['admin'], ban[1]['player'], ban[1]['reason'], ban[1]['duration']) end end addEventHandler("onPlayerJoin", root, checkPIFBanned) thank you, that's works 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now