Assistance with banning via non-active warnings.

hevaa

New Member
Member
#1
First of all I want to say its great and I'm not rushing for a reply, I was just interested in what you had to say, and if I could get guidance at all.
I'm not definite over if you've said this can be done, from your config I don't see an easy way of doing it as its based on active warns. I would be interested in having a seperate system to the active warning punishments, reasons being because I want the active period to be short so that getting 3 warns in 2 hours for example is meaningful and deserves punishment. But also, getting a high amount of warns and abusing the system to not get kicked/banned can also be punishable.

Thanks for reading, I think this is key to how I want to run my server.
I'm not really sure if this is something you would like to give guidance on/you think I'm being naive/you don't want to do it due to it being an active warning addon.

But thanks anyway,
Hevaa
 

mrpresident

Administrator
Administrator
Moderator
Member
#2
You could do this with a plugin if you want. I'll even write it for you.

Code:
lifetime_limit_warns = 20
hook.Add( "AWarnPlayerWarned", "BanTotalWarnsAwarn", function(target_ply, admin_ply, reason )
    if target_ply.totalwarnings >= lifetime_limit_warns then
        awarn_ban( target_ply, 0, "Banned for exceeding the total allowed warnings" )
    end
end )
The above code would ban a player if they get warned and have 20 or more TOTAL warnings.
You would need to place this code in a file inside your awarn2/lua/awarn/modules folder.
 

mrpresident

Administrator
Administrator
Moderator
Member
#3
In a future update, I will add the ability to have total warning punishments in addition to active warning punishments, but this will work for you, for now.
 

hevaa

New Member
Member
#4
Hey man this is great thank you.
I'm interested in this and I'm thinking of making multiple thresholds of total warns so that players get banned (e.g) for 3 days for reaching 30 warns, and then when they return and reach a higher amount of warns they can get banned for longer. I know I can do this with slight changes to what you've sent me which is fine, however one problem I think I will have is that
if target_ply.totalwarnings == lifetime_limit_warns
then when they rejoin they will again get banned. I was wondering if you had your own fix for this, or knew more than me and could help out. I had a possible idea of automatically giving them an extra warn ie: 'Banned for reaching 30 warns threshold' via console and then they have 31 warns and no longer passes the above condition.

Thanks again, no worries if you're too busy.
Hevaa
 

mrpresident

Administrator
Administrator
Moderator
Member
#5
I'm on vacation for the next 2 weeks. This can be done. Just put the code you need I. that hook. If you can't do it yourself, I'll help you but not until iget home.
 

hevaa

New Member
Member
#6
Hello, I would like to bump this: we tried to write the code ourselves as I said where

if target_ply.totalwarnings == lifetime_limit_warns
rather than
if target_ply.totalwarnings >= lifetime_limit_warns then

it worked so when the player reached 5 warns for example they were banned but then when rejoined could continue till reaching 7 warns e.g and then rebanned. This is perfect bc it means they reach the total threshold then they get banned and can rejoin even though ofcourse they still == the threshold which would ban them temporarily.

HOWEVER, this was a problem - not sure if due to the code not properly being finished as the players still == total warns for ban or what but:
the 'total warns' were actually banning based on active warns, so when they reached 5 total warns (active warns also 5 due to consecutive) however when I retested this via reducing active warns, it didn't work - we continued the test where warns reached 10 (so now had 5 active warns e.g) and the ban occured, so fully working due to active warns.

I would appreciate advice.
 
#8
Hi,

We have something like the following:

Code:
lifetime_limit_1 = 10
lifetime_limit_2 = 20
lifetime_limit_3 = 30

hook.Add( "AWarnPlayerWarned", "BanTotalWarnsAwarn", function(target_ply, admin_ply, reason )
    if target_ply.totalwarnings > lifetime_limit_1 then
        awarn_ban( target_ply, 1, "Banned for 24 hours for reaching 2 warns!" )
   
    elseif target_ply.totalwarnings > lifetime_limit_2 then
        awarn_ban( target_ply, 2, "Banned for 48 hours for reaching 4 warns!" )
   
    elseif target_ply.totalwarnings > lifetime_limit_3 then
        awarn_ban( target_ply, 3, "Banned for 96 hours for reaching 6 warns!" )
    end  
end )
After some testing it doesn't seem that the totalwarnings is accounting for the total warnings of a player and rather taking into account some of the active warnings too in some way but not 100% sure how.
 

mrpresident

Administrator
Administrator
Moderator
Member
#9
Hi,

We have something like the following:

Code:
lifetime_limit_1 = 10
lifetime_limit_2 = 20
lifetime_limit_3 = 30

hook.Add( "AWarnPlayerWarned", "BanTotalWarnsAwarn", function(target_ply, admin_ply, reason )
    if target_ply.totalwarnings > lifetime_limit_1 then
        awarn_ban( target_ply, 1, "Banned for 24 hours for reaching 2 warns!" )
 
    elseif target_ply.totalwarnings > lifetime_limit_2 then
        awarn_ban( target_ply, 2, "Banned for 48 hours for reaching 4 warns!" )
 
    elseif target_ply.totalwarnings > lifetime_limit_3 then
        awarn_ban( target_ply, 3, "Banned for 96 hours for reaching 6 warns!" )
    end
end )
After some testing it doesn't seem that the totalwarnings is accounting for the total warnings of a player and rather taking into account some of the active warnings too in some way but not 100% sure how.

Your logic is wrong. The way you have your if statement set up the first condition will always be true and the elseifs will never happen.
 
#10
Sorry for the confusion, this is the code we wrote after our original failed to work. I had forgotten that we didn't change it back to send it to you.

Code:
lifetime_limit_1 = 10
lifetime_limit_2 = 20
lifetime_limit_3 = 30

hook.Add( "AWarnPlayerWarned", "BanTotalWarnsAwarn", function(target_ply, admin_ply, reason )
    if target_ply.totalwarnings == lifetime_limit_1 then
        awarn_ban( target_ply, 1, "Banned for 24 hours for reaching 2 warns!" )
 
    elseif target_ply.totalwarnings == lifetime_limit_2 then
        awarn_ban( target_ply, 2, "Banned for 48 hours for reaching 4 warns!" )
 
    elseif target_ply.totalwarnings == lifetime_limit_3 then
        awarn_ban( target_ply, 3, "Banned for 96 hours for reaching 6 warns!" )
    end
end )
This is the original code we had tried in which it didn't work. Thanks
 

mrpresident

Administrator
Administrator
Moderator
Member
#11
ply.totalwarnings (for me right now in my testing) is only returning the player's amount of total warnings. If you delete a warning.. it will be removed from their total count. Maybe I'm not totally sure what your problem is.