đź“–
Wiki Nova Life
  • Bienvenue !
  • Discord MOD
  • Serveur
    • Introduction
    • L'hĂ©bergeur
    • La configuration
    • Ajouter des plugins
  • Plugins
    • Introduction
    • Informations pour dĂ©buter
    • Aides
      • ModKit
      • Base d'un plugin
      • CenterText
      • Config JSON
      • Commande
      • Cooldown individuel
      • Cooldown global
      • ÉvĂ©nements
      • Points
      • Panels
      • Webhook (Embed)
      • Webhook (Message)
  • Flocages
    • Introduction
    • Informations pour dĂ©buter
    • Flocage de vĂŞtement
    • Flocage de vĂ©hicule
    • Flocage de panneau
Propulsé par GitBook
Sur cette page
  1. Plugins
  2. Aides

Cooldown global

Voici le code pour créer un cooldown global :

public static long cooldownDuration = 60; // Durée du cooldown en secondes
public static long lastActionTime = 0;

// Vérifie si l'action peut être effectuée
static bool CanPerformAction()
{
    long currentTime = DateUtils.GetCurrentTime();
    TimeSpan elapsedTime = DateUtils.CompareWithCurrentTime(lastActionTime);
    return elapsedTime.TotalSeconds >= cooldownDuration;
}

// Met Ă  jour le dernier temps d'action
static void PerformAction()
{
    lastActionTime = DateUtils.GetCurrentTime();
}

// Récupère le temps restant du cooldown
static TimeSpan GetRemainingCooldown()
{
    TimeSpan elapsedTime = DateUtils.CompareWithCurrentTime(lastActionTime);
    return TimeSpan.FromSeconds(cooldownDuration) - elapsedTime;
}

// Exemple d'utilisation
if (CanPerformAction())
{
    // Votre code ici
}
else
{
    TimeSpan remainingCooldown = GetRemainingCooldown();
    // Votre message d'avertissement ici avec remainingCooldown
}
PrécédentCooldown individuelSuivantÉvénements

Dernière mise à jour il y a 3 mois