Jump to content

[Help] Kick with serials


Papeles

Recommended Posts

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 by Fist
Link to comment

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
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

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
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 by Mr.Loki
Link to comment
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 :D O.o sorry .

 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...