Skip to content

Cops-and-Crimes/altv-notifications

Repository files navigation

GTA5_gbKnmxGfSH_2023_04_08

Notifications

Created by Rezondes

❤️ Geschrieben für Cops and Crimes

⭐ Wenn dir dieses Repository geholfen hat!

❤️ Ein Danke geht an xLuxy ❤️

Beschreibung

Dieses Repository stellt eine alt:V-Ressource bereit, um dem Spieler einfache Benachrichtigungen anzuzeigen.

Installation

Fügen Sie einfach den Ordner altv-rezondes-notifications in ihren Serverordner resources und den Namen dieser Ressource zu Ihrer server.toml hinzu.

altv-rezondes-notifications

Verwendung (Allgemein)

Am Ende wird immer diese Methode aufgerufen:

function showNotification(type, msg, duration, titleText = "")
/// <param name="type">Farbe</param>
enum NotificationTypeEnum 
{
  Error, // Rot
  Info, // Gelb
  Success, // Grün 
  Dispatch // Blau 
} 
/// <param name="msg">Nachricht, welche dem Spieler angezeigt wird</param>
/// <param name="duration">In Millisekunden</param>
/// <param name="title">Wenn nicht gesetzt => notificationType.ToString()</param>

Verwendung unter Javascript

// Client
alt.emit("Client:Notifications:Show", "Error", "Das Passwort ist nicht korrekt!", 5000);

// Server
alt.emitClient(player, "Client:Notifications:Show", "Error", "Das Passwort ist nicht korrekt!", 5000);

GTA5_7xvY9qRYyi_2023_04_08

// Client
alt.emit("Client:Notifications:Show", "Success", "Erfolgreich eingeloggt!", 2500, "Login")

// Server
alt.emitClient(player, "Client:Notifications:Show", "Success", "Erfolgreich eingeloggt!", 2500, "Login");

GTA5_cefEeRirFX_2023_04_08

// Client
alt.emit("Client:Notifications:Show", "Success", "Erfolgreich eingeloggt!", 2500, "Login")

// Server
alt.emitClient(player, "Client:Notifications:Show", "Success", "Erfolgreich eingeloggt!", 2500, "Login");

GTA5_CXlspxmcW4_2023_04_08

// Client
alt.emit("Client:Notifications:Show", "Success", "Erfolgreich eingeloggt!", 2500, "Login")

// Server
alt.emitClient(player, "Client:Notifications:Show", "Success", "Erfolgreich eingeloggt!", 2500, "Login");

GTA5_ZVbfeG4CN2_2023_04_08

Mehrere Benachrichtigungen werden übereinander gestapelt:
GTA5_tZSkZtyHA9_2023_04_08

Verwendung unter C# (Serverside)

Enum + statische Methode zur einfacheren Anwendung

public enum NotificationTypeEnum
{
  Error, // Rot
  Info, // Gelb
  Success, // Grün
  Dispatch // Blau
}

/// <summary>
/// Zum einfacherem nutzen von altv-notifications
/// </summary>
/// <param name="msg">Nachricht, welche dem Spieler angezeigt wird</param>
/// <param name="duration">In Millisekunden</param>
/// <param name="title">Wenn nicht gesetzt => notificationType.ToString()</param>
public static void ShowNotification(this IPlayer player, NotificationTypeEnum notificationType, string msg, int duration, string title = "")
{
  player.Emit("Client:Nofitications:Show", notificationType.ToString(), msg, duration, title);
}

Beispiele

player.ShowNotification(NotificationTypeEnum.Error, "Das Passwort ist nicht korrekt!", 5000);
player.ShowNotification(NotificationTypeEnum.Info, "Dies ist ein Infotext!", 5000, "TestTitel");
player.ShowNotification(NotificationTypeEnum.Success, "Erfolgreich eingeloggt!", 2500, "Login");
player.ShowNotification(NotificationTypeEnum.Dispatch, "[911] Dispatch - Dispatchtext über einen flüchtigen Verbrecher!", 7500);

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published