After sending a report or message to discord using /report or /message the cooldown timer stacks and never allows a player to use these again. I tried setting the cooldown to 0 but still has the same issue.
Player reporting / message cooldown stack
+1 - The cooldowns are broken and this needs patched.
I am having the same issue, you can send a message once.. after that every try adds to the timer. 62,000 seconds to use the command again. I even set it to 0 and -10 to test. =0(
Same issue for me.
Happens with me as well. anyone got a fix or an earlier version?
ekhem +1, please fix it :(
Still happening, patch please?
i am having the same issue but i found a workaround, just comment these lines and it will work fine.
//if ( OnCooldown( player, CooldownType.ReportCooldown, out secondsRemaining ) )
//{
//SendMessage( player, GetLang( "Cooldown", player.Id, secondsRemaining.ToString() ) );
//return;
//}
deadalivei am having the same issue but i found a workaround, just comment these lines and it will work fine.
//if ( OnCooldown( player, CooldownType.ReportCooldown, out secondsRemaining ) ) //{ //SendMessage( player, GetLang( "Cooldown", player.Id, secondsRemaining.ToString() ) ); //return; //}
This does not fix the issue on Rust it still keeps stacking. It would be nice if the Plugin Dev would fix this issue as changing the cooldown to null in the data file is annoying.
Manual Patch For v2.1.8:
I had the time and was capable so I cooked this solution up for those who may need it. Make backup copies of all files before attempting any adjustments!
Find this function:
private bool OnCooldown( IPlayer player, CooldownType type, out int secondsRemaining )
{
secondsRemaining = 0;
PlayerData data;
if ( !_data.Players.TryGetValue( player.Id, out data ) )
{
return false;
}
switch ( type )
{
case CooldownType.MessageCooldown:
{
if ( !data.MessageCooldown.HasValue )
{
return false;
}
secondsRemaining = (int)(DateTime.UtcNow - data.MessageCooldown.Value.AddSeconds( GetFeatureConfig<Configuration.Message>( FeatureType.Message ).Cooldown )).TotalSeconds;
return secondsRemaining > 0;
}
case CooldownType.ReportCooldown:
{
if ( !data.ReportCooldown.HasValue )
{
return false;
}
secondsRemaining = (int)(DateTime.UtcNow - data.ReportCooldown.Value.AddSeconds( GetFeatureConfig<Configuration.Report>( FeatureType.Report ).Cooldown )).TotalSeconds;
return secondsRemaining > 0;
}
default:
return false;
}
}
Replace the entire function with this instead:
private bool OnCooldown(IPlayer player, CooldownType type) //Psyche - Replacement
{
if (_data.Players.ContainsKey(player.Id))
{
PlayerData playerData = _data.Players[player.Id];
switch (type)
{
case CooldownType.MessageCooldown:
{
if (playerData.MessageCooldown.HasValue) return playerData.MessageCooldown.Value.AddSeconds(GetFeatureConfig<Configuration.Message>(FeatureType.Message).Cooldown) > DateTime.UtcNow;
break;
}
case CooldownType.ReportCooldown:
{
if (playerData.ReportCooldown.HasValue) return playerData.ReportCooldown.Value.AddSeconds(GetFeatureConfig<Configuration.Report>(FeatureType.Report).Cooldown) > DateTime.UtcNow;
break;
}
}
}
return false;
}
Find every occurance of this function (there are multiple in the .cs file):
int secondsRemaining;
if ( OnCooldown( player, CooldownType.MessageCooldown, out secondsRemaining ) )
{
SendMessage( player, GetLang( "Cooldown", player.Id, secondsRemaining.ToString() ));
return;
}
Replace each occurance with this instead:
if (OnCooldown(player, CooldownType.MessageCooldown)) //Psyche - Replacement
{
var messageCooldown = _data.Players[player.Id].MessageCooldown;
if (messageCooldown != null)
SendMessage(player,
GetLang("Cooldown", player.Id,
(messageCooldown.Value.AddSeconds(messageConfig.Cooldown) -
DateTime.UtcNow).Seconds));
return;
}
Save the .cs file and reload the plugin > oxide.reload DiscordMessages
You're welcome.
-Psyche
Psyche
Manual Patch For v2.1.8:
I had the time and was capable so I cooked this solution up for those who may need it. Make backup copies of all files before attempting any adjustments!
Find this function:
private bool OnCooldown( IPlayer player, CooldownType type, out int secondsRemaining ) { secondsRemaining = 0; PlayerData data; if ( !_data.Players.TryGetValue( player.Id, out data ) ) { return false; } switch ( type ) { case CooldownType.MessageCooldown: { if ( !data.MessageCooldown.HasValue ) { return false; } secondsRemaining = (int)(DateTime.UtcNow - data.MessageCooldown.Value.AddSeconds( GetFeatureConfig<Configuration.Message>( FeatureType.Message ).Cooldown )).TotalSeconds; return secondsRemaining > 0; } case CooldownType.ReportCooldown: { if ( !data.ReportCooldown.HasValue ) { return false; } secondsRemaining = (int)(DateTime.UtcNow - data.ReportCooldown.Value.AddSeconds( GetFeatureConfig<Configuration.Report>( FeatureType.Report ).Cooldown )).TotalSeconds; return secondsRemaining > 0; } default: return false; } }
Replace the entire function with this instead:
private bool OnCooldown(IPlayer player, CooldownType type) //Psyche - Replacement { if (_data.Players.ContainsKey(player.Id)) { PlayerData playerData = _data.Players[player.Id]; switch (type) { case CooldownType.MessageCooldown: { if (playerData.MessageCooldown.HasValue) return playerData.MessageCooldown.Value.AddSeconds(GetFeatureConfig<Configuration.Message>(FeatureType.Message).Cooldown) > DateTime.UtcNow; break; } case CooldownType.ReportCooldown: { if (playerData.ReportCooldown.HasValue) return playerData.ReportCooldown.Value.AddSeconds(GetFeatureConfig<Configuration.Report>(FeatureType.Report).Cooldown) > DateTime.UtcNow; break; } } } return false; }
Find every occurance of this function (there are multiple in the .cs file):
int secondsRemaining; if ( OnCooldown( player, CooldownType.MessageCooldown, out secondsRemaining ) ) { SendMessage( player, GetLang( "Cooldown", player.Id, secondsRemaining.ToString() )); return; }
Replace each occurance with this instead:
if (OnCooldown(player, CooldownType.MessageCooldown)) //Psyche - Replacement { var messageCooldown = _data.Players[player.Id].MessageCooldown; if (messageCooldown != null) SendMessage(player, GetLang("Cooldown", player.Id, (messageCooldown.Value.AddSeconds(messageConfig.Cooldown) - DateTime.UtcNow).Seconds)); return; }
Save the .cs file and reload the plugin > oxide.reload DiscordMessages
You're welcome.
-Psyche
Error while compiling: DiscordMessages.cs(888,42): error CS0103: The name `messageConfig' does not exist in the current context
oxide.reload DiscordMessages
Unable to load DiscordMessages. DiscordMessages.cs(888,42): error CS0103: The name `messageConfig' does not exist in the current context
tjhooker73ps3Error while compiling: DiscordMessages.cs(888,42): error CS0103: The name `messageConfig' does not exist in the current context
oxide.reload DiscordMessages
Unable to load DiscordMessages. DiscordMessages.cs(888,42): error CS0103: The name `messageConfig' does not exist in the current context
I don't know what to tell ya, maybe we are working with different versions of the file. I'm not the maintainer. Restore your previous version and use an alternative fix.
I'm using the latest version direct download from the umod page.Psyche
I don't know what to tell ya, maybe we are working with different versions of the file. I'm not the maintainer. Restore your previous version and use an alternative fix.
tjhooker73ps3I'm using the latest version direct download from the umod page.
Yes, we are running different versions of this file. I posted the above in a hurry without thinking about it, but I am running a custom version on my server which is why my changes are not going to work for you. I must have some more code included on my end that is not in the latest version, and I don't have the patience to download the old file and dig through to sort out what the issue is. Your best bet is to discard my post, revert to the latest version here on UMod and wait for an official patch to the issue.
@ctv Could you please fix this issue
- 1
- 2