lolman Posted July 12, 2015 Share Posted July 12, 2015 (edited) Hello, I want that if a player enters the server, the players IP will be printed out on the chatbox and only admins are able to see it. And how could you match the players IP if e.g. the player is banned serial but connects with other PC, if it matchs the player IP should be outputted with a red color on the chatbox if not then white. If someone could help me out, I'd appreciate it. Edited July 12, 2015 by Guest Link to comment
Sasu Posted July 12, 2015 Share Posted July 12, 2015 There is no necessary to use table.concat because the nicknames haven't got spaces. If you want only admins can use the command you can use isObjectInACLGroup(see example). And I want that if a player enters the server, the players IP will be printed out on the chatbox and only admins are able to see it. Use onPlayerJoin event with a for-loop and the function I mentioned before. Link to comment
lolman Posted July 12, 2015 Author Share Posted July 12, 2015 I've fixed the first code, but now im stuck on the second part... I don't really know how to show it to a player which is admin... Link to comment
lolman Posted July 12, 2015 Author Share Posted July 12, 2015 function getip(thePlayer) outputChatBox("* " ..getPlayerName(source).. "has joined the server", root, 155, 155, 0) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then outputChatBox("** " ..getPlayerName(source).."'s IP:" ..getPlayerIP(source), thePlayer, 0, 255, 0) end end addEventHandler("onPlayerLogin", getRootElement(), getip) error : attempt to concatenate local accName (a boolean value) someone help? Link to comment
Dealman Posted July 12, 2015 Share Posted July 12, 2015 And how is thePlayer defined? You would need to get all active players using getElementsByType and then loop through them all, check their accounts and whether they're an admin or not. If they're an admin, output the message containing the IP. If not, output the has joined the server message. accName probably returns false because thePlayer was nil - thus, it can't get the account name and returns false. Link to comment
Gr0x Posted July 12, 2015 Share Posted July 12, 2015 function getip() outputChatBox("* " ..getPlayerName(source).. " has joined the server", root, 155, 155, 0) for _,thePlayer in pairs(getElementsByType("player")) do if not isGuestAccount(getPlayerAccount(thePlayer)) then if isObjectInACLGroup ("user.".. getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) then outputChatBox("** " ..getPlayerName(source).."'s IP:" ..getPlayerIP(source), thePlayer, 0, 255, 0) end end end end addEventHandler("onPlayerLogin", getRootElement(), getip) Link to comment
lolman Posted July 12, 2015 Author Share Posted July 12, 2015 And how is thePlayer defined? You would need to get all active players using getElementsByType and then loop through them all, check their accounts and whether they're an admin or not.If they're an admin, output the message containing the IP. If not, output the has joined the server message. accName probably returns false because thePlayer was nil - thus, it can't get the account name and returns false. Wow, dude... You're amazing ! worked !! But I now I want that if someone banned by serial as example and he comes back with an another pc, how could it show the ip adress then with a red color? What should I use? Link to comment
lolman Posted July 12, 2015 Author Share Posted July 12, 2015 elseif getBanIP(source) == getBanSerial then outputChatBox("** " ..getPlayerName(source).."'s IP:" ..getPlayerIP(source), player, 255, 0, 0) I made this but is this good? Link to comment
Dealman Posted July 12, 2015 Share Posted July 12, 2015 That won't work because; 1. Source would be the player that logged in. getBanIP requires a ban pointer where as source in this case would be a player element. 2. You didn't specify getBanSerial as a function, but rather a variable. You'd need to add the parenthesis. You'll need to get all bans using getBans and yet again, loop through them all. Then you can use the example on that page to check if it matches with getBanIP instead of getBanNick. Link to comment
lolman Posted July 12, 2015 Author Share Posted July 12, 2015 Well, you're right. I tried something like this... I don't know if this one is good or not. function catchbannedguy() for i, player in ipairs(getElementsByType("player")) do local accName = getAccountName (getPlayerAccount(player)) if isObjectInACLGroup("user."..accName, aclGetGroup("Admin")) then local banList = getBans() for banID, ban in ipairs ( banList ) do local bannedAccIP = getBanIP(source) local bannedAccSerial = getBanSerial(source) if (bannedAccIP == bannedAccSerial) then outputChatBox("** " ..getPlayerName(source).."'s IP:" ..getPlayerIP(source), player, 255, 0, 0) end end end end end addEventHandler("onPlayerJoin", getRootElement(), catchbannedguy) Link to comment
Dealman Posted July 12, 2015 Share Posted July 12, 2015 I assume you'd need something like this, but I haven't used these functions before so it might be wrong; function catchBannedGuy() for index, player in ipairs(getElementsByType("player")) do local accName = getAccountName(getPlayerAccount(player)) if(isObjectInACLGroup("user."..accName, aclGetGroup("Admin")) then local banList = getBans() for banID, ban in ipairs(banList) do local sourceIP = getPlayerIP(source) -- This gets the IP of the player that joined local checkForIPBan = getBanIP(ban) -- As I said before, getBanIP needs a ban pointer - not a player element. if(checkForIPBan == sourceIP) then -- Check if the IP matches(strings) -- This IP is already banned -- Do whatever you want here, ban him through serial or whatever end end end end end addEventHandler("onPlayerJoin", root, catchBannedGuy) Link to comment
lolman Posted July 12, 2015 Author Share Posted July 12, 2015 Thank you man, I'll try it out once I have the option to do so 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