Makaveli15 Posted October 23, 2017 Posted October 23, 2017 (edited) Hello guys, how can i make my script able to ban someone who tried to ban me on server?for example somebody tries to ban me, but gets ban instead of me and for me nothing happens here's the undone one, which blocks to ban all admins function onBan ( _, Player ) for _, ban in ipairs( getBans() )do if isObjectInACLGroup ( "user."..getAccountName(getPlayerAccount(source)),aclGetGroup("Admin")) then if getPlayerName ( source ) == getBanNick( ban ) then if ( removeBan ( ban ) ) then outputChatBox("This is a bad idea. :)",Player , 255, 255, 255, true) end end end end end addEventHandler ( "onPlayerBan", root, onBan ) Edited October 23, 2017 by OsO.cp
Forum Administrators Lpsd Posted October 23, 2017 Forum Administrators Posted October 23, 2017 I don't get what you're trying to do. Players shouldn't have access to ban - why would admins be getting banned?
Makaveli15 Posted October 23, 2017 Author Posted October 23, 2017 1 minute ago, LopSided_ said: I don't get what you're trying to do. Players shouldn't have access to ban - why would admins be getting banned? because i have special type of server, there is a lot of supermoderators
Forum Administrators Lpsd Posted October 23, 2017 Forum Administrators Posted October 23, 2017 (edited) This isn't a problem you should initially be trying to solve with code. You shouldn't be giving people permissions on your server if you can't trust them. However, something like this might help. If anyone tries to ban an admin the action will be blocked and they'll get banned them-self (Serial and IP ban). function verifyBan(banPointer, responsiblePlayer) if getElementType(responsiblePlayer) ~= "player" then return false end if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then cancelEvent() --Cancel the ban on admin addBan(getPlayerIP(responsiblePlayer), nil, getPlayerSerial(responsiblePlayer), root, "Banning other admins") --Ban the offending moderator outputChatBox (getPlayerName(responsiblePlayer).." has been banned for banning admins!", getRootElement(), 255, 0, 0) -- Output the ban. end end addEventHandler ( "onPlayerBan", getRootElement(), verifyBan ) Not tested, try it out and see if it works. Edited October 23, 2017 by LopSided_
Makaveli15 Posted October 23, 2017 Author Posted October 23, 2017 10 minutes ago, LopSided_ said: This isn't a problem you should initially be trying to solve with code. You shouldn't be giving people permissions on your server if you can't trust them. However, something like this might help. If anyone tries to ban an admin the action will be blocked and they'll get banned them-self (Serial and IP ban). function verifyBan(banPointer, responsiblePlayer) if getElementType(responsiblePlayer) ~= "player" then return false end if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then cancelEvent() --Cancel the ban on admin addBan(getPlayerIP(responsiblePlayer), nil, getPlayerSerial(responsiblePlayer), root, "Banning other admins") --Ban the offending moderator outputChatBox (getPlayerName(responsiblePlayer).." has been banned for banning admins!", getRootElement(), 255, 0, 0) -- Output the ban. end end addEventHandler ( "onPlayerBan", getRootElement(), verifyBan ) Not tested, try it out and see if it works. just tested, doesnt work
Forum Administrators Lpsd Posted October 23, 2017 Forum Administrators Posted October 23, 2017 (edited) I assume you used debugscript? Can you tell me what the errors are, or what exactly it is that doesn't work? Edited October 23, 2017 by LopSided_
Makaveli15 Posted October 23, 2017 Author Posted October 23, 2017 5 minutes ago, LopSided_ said: I assume you used debugscript? Can you tell me what the errors are, or what exactly it is that doesn't work? check out the pic: https://ibb.co/kBemqm
King12 Posted October 23, 2017 Posted October 23, 2017 (edited) It would be better to modify the admin panel. Go to admin/server/ and open admin_server.lua search for this: at line ~855 elseif ( action == "ban" ) then and add this line after it: elseif ( action == "ban" ) then if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then outputChatBox( getPlayerName(source).."#ff0000 tried to ban you.", player, 255, 0, 0, true) return false end Same goes for kick, if you want to. if ( action == "kick" ) then if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then outputChatBox( getPlayerName(source).."#ff0000 tried to ban you.", player, 255, 0, 0, true) return false end Note: this works with admin commands too. Edited October 23, 2017 by King12
Makaveli15 Posted October 23, 2017 Author Posted October 23, 2017 (edited) 9 minutes ago, King12 said: It would be better to modify the admin panel. Go to admin/server/ and open admin_server.lua search for this: at line ~855 elseif ( action == "ban" ) then and add this line after it: elseif ( action == "ban" ) then if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then outputChatBox( getPlayerName(source).."#ff0000 tried to ban you.", player, 255, 0, 0, true) return false end Same goes for kick, if you want to. if ( action == "kick" ) then if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then outputChatBox( getPlayerName(source).."#ff0000 tried to ban you.", player, 255, 0, 0, true) return false end Note: this works with admin commands too. tbh, i would like to have it as separate script, but i will check out this one 21 minutes ago, King12 said: It would be better to modify the admin panel. Go to admin/server/ and open admin_server.lua search for this: at line ~855 elseif ( action == "ban" ) then and add this line after it: elseif ( action == "ban" ) then if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then outputChatBox( getPlayerName(source).."#ff0000 tried to ban you.", player, 255, 0, 0, true) return false end Same goes for kick, if you want to. if ( action == "kick" ) then if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then outputChatBox( getPlayerName(source).."#ff0000 tried to ban you.", player, 255, 0, 0, true) return false end Note: this works with admin commands too. that works, but what sense if it doesnt ban somebody who tried to ban me Edited October 23, 2017 by OsO.cp
King12 Posted October 23, 2017 Posted October 23, 2017 14 minutes ago, OsO.cp said: tbh, i would like to have it as separate script, but i will check out this one I believe that is impossible, because onPlayerBan is triggered once the ban is added to the banlist. 1
Makaveli15 Posted October 23, 2017 Author Posted October 23, 2017 Just now, King12 said: I believe that is impossible, because onPlayerBan is triggered once the ban is added to the banlist. what's about counter-ban?
King12 Posted October 23, 2017 Posted October 23, 2017 1 minute ago, OsO.cp said: what's about counter-ban? remove the ban after it's added.
Makaveli15 Posted October 23, 2017 Author Posted October 23, 2017 (edited) 4 minutes ago, King12 said: remove the ban after it's added. noo, i just meant a function like: a guy which tried to ban me to gets banned instead of me Edited October 23, 2017 by OsO.cp
King12 Posted October 23, 2017 Posted October 23, 2017 (edited) function outputBan ( banPointer, responsibleElement ) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then for _,ban in ipairs(getBans()) do if getBanSerial(ban) == getPlayerSerial(source) then setTimer ( function() removeBan (ban) end, 1000, 1 ) local banner = getPlayerSerial ( responsibleElement ) or nil if banner then addBan ( nil, nil, banner , root, "You were banned for banning a staff member") outputChatBox(getPlayerName(banner).." has been banned for banning a staff member") else return end else return end end else return end end addEventHandler ( "onPlayerBan", getRootElement(), outputBan ) Other than that, is impossible. Edited October 23, 2017 by King12
Makaveli15 Posted October 23, 2017 Author Posted October 23, 2017 4 minutes ago, King12 said: function outputBan ( banPointer, responsibleElement ) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then for _,ban in ipairs(getBans()) do if getBanSerial(ban) == getPlayerSerial(source) then setTimer ( function() removeBan (ban) end, 1000, 1 ) local banner = getPlayerSerial ( responsibleElement ) or nil if banner then addBan ( nil, nil, banner , root, "You were banned for banning a staff member") outputChatBox(getPlayerName(banner).." has been banned for banning a staff member") else return end else return end end else return end end addEventHandler ( "onPlayerBan", getRootElement(), outputBan ) Other than that, is impossible. i should apply this to the first one you wrote? elseif ( action == "ban" ) then if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then outputChatBox( getPlayerName(source).."#ff0000 tried to ban you.", player, 255, 0, 0, true) return false end
King12 Posted October 23, 2017 Posted October 23, 2017 Just now, OsO.cp said: i should apply this to the first one you wrote? elseif ( action == "ban" ) then if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then outputChatBox( getPlayerName(source).."#ff0000 tried to ban you.", player, 255, 0, 0, true) return false end correct.
Makaveli15 Posted October 23, 2017 Author Posted October 23, 2017 well, it doesnt work, if i've done everythin correctly elseif ( action == "ban" ) then if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then outputChatBox( getPlayerName(source).."#ff0000 tried to ban you.", player, 255, 0, 0, true) return false end function outputBan ( banPointer, responsibleElement ) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then for _,ban in ipairs(getBans()) do if getBanSerial(ban) == getPlayerSerial(source) then setTimer ( function() removeBan (ban) end, 1000, 1 ) local banner = getPlayerSerial ( responsibleElement ) or nil if banner then addBan ( nil, nil, banner , root, "You were banned for banning a staff member") outputChatBox(getPlayerName(banner).." has been banned for banning a staff member") else return end else return end end else return end end addEventHandler ( "onPlayerBan", getRootElement(), outputBan ) local reason = data or ""
King12 Posted October 23, 2017 Posted October 23, 2017 (edited) 6 minutes ago, OsO.cp said: well, it doesnt work, if i've done everythin correctly elseif ( action == "ban" ) then if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then outputChatBox( getPlayerName(source).."#ff0000 tried to ban you.", player, 255, 0, 0, true) return false end function outputBan ( banPointer, responsibleElement ) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then for _,ban in ipairs(getBans()) do if getBanSerial(ban) == getPlayerSerial(source) then setTimer ( function() removeBan (ban) end, 1000, 1 ) local banner = getPlayerSerial ( responsibleElement ) or nil if banner then addBan ( nil, nil, banner , root, "You were banned for banning a staff member") outputChatBox(getPlayerName(banner).." has been banned for banning a staff member") else return end else return end end else return end end addEventHandler ( "onPlayerBan", getRootElement(), outputBan ) local reason = data or "" You don't have to use the 2nd code [the latest], you just have to add this under elseif (action == "ban" ) then elseif ( action == "ban" ) then if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then outputChatBox( getPlayerName(source).."#ff0000 tried to ban you.", player, 255, 0, 0, true) addBan ( nil, nil, source , root, "You were banned for banning a staff member") return false end local reason = data or "" -- etc.. Edited October 23, 2017 by King12
Makaveli15 Posted October 23, 2017 Author Posted October 23, 2017 elseif ( action == "ban" ) then function outputBan ( banPointer, responsibleElement ) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then for _,ban in ipairs(getBans()) do if getBanSerial(ban) == getPlayerSerial(source) then setTimer ( function() removeBan (ban) end, 1000, 1 ) local banner = getPlayerSerial ( responsibleElement ) or nil if banner then addBan ( nil, nil, banner , root, "You were banned for banning a staff member") outputChatBox(getPlayerName(banner).." has been banned for banning a staff member") else return end else return end end else return end end addEventHandler ( "onPlayerBan", getRootElement(), outputBan ) local reason = data or "" now its just bans the admin maybe its would be easier if u would add me on skype? because its kinda worse to talk like this
King12 Posted October 23, 2017 Posted October 23, 2017 Code should be like this: elseif ( action == "ban" ) then if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then outputChatBox( getPlayerName(source):gsub("#%x%x%x%x%x%x","").." has tried to ban you.", player, 255, 0, 0) local banner = getPlayerSerial (source) outputChatBox( getPlayerName(source):gsub("#%x%x%x%x%x%x","").." has been banned. [Reason: trying to ban staff member]", root, 255, 0, 0) setTimer ( function () addBan ( nil, nil, banner , root, "You were banned for trying to ban a staff member") end, 500, 1) return false end local reason = data or "" local seconds = tonumber(additional) and tonumber(additional) > 0 and tonumber(additional) local bUseSerial = additional2 local isAnonAdmin = getElementData(source, "AnonAdmin") -- etc..
Makaveli15 Posted October 23, 2017 Author Posted October 23, 2017 (edited) 5 minutes ago, King12 said: Code should be like this: elseif ( action == "ban" ) then if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin")) then outputChatBox( getPlayerName(source):gsub("#%x%x%x%x%x%x","").." has tried to ban you.", player, 255, 0, 0) local banner = getPlayerSerial (source) outputChatBox( getPlayerName(source):gsub("#%x%x%x%x%x%x","").." has been banned. [Reason: trying to ban staff member]", root, 255, 0, 0) setTimer ( function () addBan ( nil, nil, banner , root, "You were banned for trying to ban a staff member") end, 500, 1) return false end local reason = data or "" local seconds = tonumber(additional) and tonumber(additional) > 0 and tonumber(additional) local bUseSerial = additional2 local isAnonAdmin = getElementData(source, "AnonAdmin") -- etc.. THAT FUKCING WORKS, Thank you so much, fam! Edited October 23, 2017 by OsO.cp
King12 Posted October 23, 2017 Posted October 23, 2017 1 minute ago, OsO.cp said: THAT FUKCING WORKS, Thank you so much, fam! You are welcome.
Makaveli15 Posted October 23, 2017 Author Posted October 23, 2017 Just now, King12 said: You are welcome. ah forgot smth. the last question Is it possible to change the group from Admin to anything else?Or it won't work
King12 Posted October 23, 2017 Posted October 23, 2017 (edited) 14 minutes ago, OsO.cp said: ah forgot smth. the last question Is it possible to change the group from Admin to anything else?Or it won't work It's possible. You can even use two groups. elseif ( action == "ban" ) then if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin") ) or isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Console") ) then Edited October 23, 2017 by King12
Makaveli15 Posted October 23, 2017 Author Posted October 23, 2017 (edited) 3 minutes ago, King12 said: It's possible. You can even use two groups. elseif ( action == "ban" ) then if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Admin") ) or isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("Console") ) then Thanks ya again!im so happy Edited October 23, 2017 by OsO.cp
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