From d317751a1010db654b84084017539a897968508b Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Tue, 8 Sep 2020 18:55:13 +0100 Subject: [PATCH] Added play time and maps played check --- config/expcore/roles.lua | 18 ++++++++++++++---- locale/en/expcore.cfg | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/config/expcore/roles.lua b/config/expcore/roles.lua index 92aa1d4e..e28ac848 100644 --- a/config/expcore/roles.lua +++ b/config/expcore/roles.lua @@ -2,6 +2,8 @@ -- @config Roles local Roles = require 'expcore.roles' --- @dep expcore.roles +local PlayerData = require 'expcore.player_data' --- @dep expcore.player_data +local Statistics = PlayerData.Statistics --- Role flags that will run when a player changes roles Roles.define_flag_trigger('is_admin',function(player,state) @@ -166,6 +168,7 @@ Roles.new_role('Partner','Part') 'command/unjail' } +local hours10, hours250 = 10*216000, 250*60 Roles.new_role('Veteran','Vet') :set_permission_group('Trusted') :set_custom_color{r=140,g=120,b=200} @@ -174,9 +177,12 @@ Roles.new_role('Veteran','Vet') 'command/chat-bot', } :set_auto_assign_condition(function(player) - game.print('Checked auto assign vet') - if player.online_time > 10*216000 then + if player.online_time >= hours10 then return true + else + local stats = Statistics:get(player, {}) + local playTime, afkTime, mapCount = stats.Playtime or 0, stats.AfkTime or 0, stats.MapsPlayed or 0 + return playTime - afkTime >= hours250 and mapCount >= 25 end end) @@ -193,6 +199,7 @@ Roles.new_role('Member','Mem') 'command/save-quickbar' } +local hours3, hours15 = 3*216000, 15*60 Roles.new_role('Regular','Reg') :set_permission_group('Standard') :set_custom_color{r=79,g=155,b=163} @@ -205,9 +212,12 @@ Roles.new_role('Regular','Reg') 'standard-decon' } :set_auto_assign_condition(function(player) - game.print('Checked auto assign reg') - if player.online_time > 3*216000 then + if player.online_time >= hours3 then return true + else + local stats = Statistics:get(player, {}) + local playTime, afkTime, mapCount = stats.Playtime or 0, stats.AfkTime or 0, stats.MapsPlayed or 0 + return playTime - afkTime >= hours15 and mapCount >= 5 end end) diff --git a/locale/en/expcore.cfg b/locale/en/expcore.cfg index e5fc44df..3c3280d6 100644 --- a/locale/en/expcore.cfg +++ b/locale/en/expcore.cfg @@ -25,7 +25,7 @@ command-error-log-format=[ERROR] command/__1__ :: __2__ [expcore-roles] error-log-format-flag=[ERROR] roleFlag/__1__ :: __2__ -error-log-format-promote=[ERROR] rolePromote/__1__ :: __2__ +error-log-format-assign=[ERROR] rolePromote/__1__ :: __2__ game-message-assign=__1__ has been assigned to __2__ by __3__ game-message-unassign=__1__ has been unassigned from __2__ by __3__ reject-role=Invalid Role Name.