HasterPaster

Send an alert to a DayZ player using the nickname Survivor and ask to change

Dec 1st, 2021 (edited)
707
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.98 KB | None | 0 0
  1. // This script requires the mod VPPNotifications.
  2.  
  3. class CustomMission: MissionServer
  4. {
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.     override void InvokeOnConnect(PlayerBase player, PlayerIdentity identity)
  16.     {
  17.         super.InvokeOnConnect(player, identity);
  18.  
  19.         // Code for sending an alert to a player named "Survivor" prompting to change nickname to something else. Code starts here.
  20.  
  21.         // Set how long in minutes the alert should stay visible for the player as well as the heading and message. Don't edit anything else unless you know what you are doing.
  22.         int alertVisibleTime = 60;
  23.         string alertHeading = "Alert";
  24.         string alertMessage = "Please change your nick from Survivor to something else.";
  25.  
  26.         // Convert the time to seconds.
  27.         alertVisibleTime = alertVisibleTime * 60;
  28.  
  29.         // Get the players nickname.
  30.         string playerNickName = player.GetIdentity().GetName();
  31.  
  32.         // Extract the first word of the nickname by looking for the first space between the words. That means even players called "Survivor (2)" will get the alert.
  33.         int endOfFirstWord = playerNickName.IndexOf(" ");
  34.  
  35.         // If no space is found (-1), it means the nickname is only one word long and we will use the entire length of the nickname.
  36.         if (endOfFirstWord == -1)
  37.             endOfFirstWord = playerNickName.Length();
  38.  
  39.         // Cut out the part of the nickname we want.
  40.         playerNickName = playerNickName.Substring(0, endOfFirstWord);
  41.  
  42.         // Convert the nickname to lowercase. This is done by using ToLower(), which converts the string to lowercase and returns the number of characters in the string as an int, that we will never use. Strange way of doing it.
  43.         int nickToLower = playerNickName.ToLower();
  44.  
  45.         // If the nickname is "survivor": send the alert to the player.
  46.         if (playerNickName == "survivor")
  47.             g_Game.SendMessage(false, identity, alertHeading, alertMessage, alertVisibleTime, 2, false, true, "", 0, 0);
  48.  
  49.         // Code for sending an alert to a player named "Survivor" prompting to change nickname to something else. Code ends here.
  50.     }
  51. };
  52.  
Add Comment
Please, Sign In to add comment