Papeles Posted March 12, 2017 Share Posted March 12, 2017 How can i make a script that kick players if the serial is not preset? Link to comment
Ayush Rathore Posted March 12, 2017 Share Posted March 12, 2017 28 minutes ago, Papeles said: How can i make a script that kick players if the serial is not preset? tell me first where the serial is present Link to comment
Fist Posted March 12, 2017 Share Posted March 12, 2017 (edited) you can kick them like this addCommandHandler("kickserial",function(source,cmd,serial,reason) for _,v in ipairs(getElementsByType("player") do local playerSerial = getPlayerSerial(v); if (serial == playerSerial) then kickPlayer(v,source,reason); end end end); then just do /kickserial serial reason Edited March 12, 2017 by Fist Link to comment
3aGl3 Posted March 12, 2017 Share Posted March 12, 2017 If I understand you correctly you want to kick a player without a serial, so that would be: function checkConnectingSerial( nick, ip, serial, iVersion, sVersion ) if not serial or string.len( serial ) ~= 32 then cancelEvent( true, "Invalid serial number." ) end end addEventHandler( "onPlayerConnect", root, checkConnectingSerial ) Link to comment
Papeles Posted March 12, 2017 Author Share Posted March 12, 2017 35 minutes ago, 3aGl3 said: If I understand you correctly you want to kick a player without a serial, so that would be: function checkConnectingSerial( nick, ip, serial, iVersion, sVersion ) if not serial or string.len( serial ) ~= 32 then cancelEvent( true, "Invalid serial number." ) end end addEventHandler( "onPlayerConnect", root, checkConnectingSerial ) Not that, i want to create a table with few serials of players who are only able to access the server. Just get the serial and check if it is on the table, if not kick it else put a welcome message Link to comment
Ayush Rathore Posted March 12, 2017 Share Posted March 12, 2017 do this local serial = {} serial["your serial"] = true serial["ypur serial"] = true function checkConnectingSerial( nick, ip, ser, iVersion, sVersion ) if not serial[ser] then cancelEvent( true, "Invalid serial number." ) end end addEventHandler( "onPlayerConnect", root, checkConnectingSerial ) 23 minutes ago, Papeles said: Not that, i want to create a table with few serials of players who are only able to access the server. Just get the serial and check if it is on the table, if not kick it else put a welcome message Link to comment
Mr.Loki Posted March 12, 2017 Share Posted March 12, 2017 (edited) local serial = { ["your_serial"] = true, ["your_serial"] = true, } function checkConnectingSerial( nick, ip, name, ser, iVersion, sVersion ) if not serial[ser] then cancelEvent( true, "Your serial is not on the whitelist." ) end end addEventHandler( "onPlayerConnect", root, checkConnectingSerial ) 2 hours ago, Ayush Rathore said: do this Not saying that your method is wrong but you can create the table with the serials already in them and you forgot the username parameter before serial. From the WIKI: string playerNick, string playerIP, string playerUsername, string playerSerial, int playerVersionNumber, string playerVersionString Edited March 12, 2017 by Mr.Loki Link to comment
Ayush Rathore Posted March 12, 2017 Share Posted March 12, 2017 3 minutes ago, Mr.Loki said: local serial = { ["your_serial"] = true, ["your_serial"] = true, } function checkConnectingSerial( nick, ip, name, ser, iVersion, sVersion ) if not serial[ser] then cancelEvent( true, "Your serial is not on the whitelist." ) end end addEventHandler( "onPlayerConnect", root, checkConnectingSerial ) Not saying that your method is wrong but you can create the table with the serials already in them and you forgot the username parameter before serial. From the WIKI: string playerNick, string playerIP, string playerUsername, string playerSerial, int playerVersionNumber, string playerVersionString My bad i just copied Papeles code sorry . Link to comment
Papeles Posted March 12, 2017 Author Share Posted March 12, 2017 But just adding that cancelEvent will kick the player, or i should add the kickPlayer? Link to comment
Addlibs Posted March 12, 2017 Share Posted March 12, 2017 (edited) cancelEvent(true, str) on onPlayerConnect will reject the connection with error message "Disconnected: server refused the connection" (or the reason specified as str) Edited March 12, 2017 by MrTasty Link to comment
Papeles Posted March 12, 2017 Author Share Posted March 12, 2017 (edited) Okay, thanks you all guys! SOLVED Edited March 12, 2017 by Papeles 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