C#:
/*
This plugin is made by SzzakiD aka. Disguise.
This file is only uploaded to https://codefling.com & https://lone.design
Modifying and sharing this file without permission is against this file and both of the site's TOS!
If you need help or want to ask for permission contact me via
Email: szzakid@gmail.com
Discord: SzzakiD#2971 (Codefling - https://discord.gg/pMwHXnmypb / Lone.Design - https://discord.gg/w8sKDh6Dp8)
*/
#region \|/ PLUGIN \|/
using Oxide.Core;
using Oxide.Core.Configuration;
using Oxide.Core.Libraries;
using Oxide.Core.Libraries.Covalence;
using Oxide.Plugins;
using System;
using Network;
using UnityEngine;
using CompanionServer.Handlers;
using Oxide.Game.Rust.Libraries;
using System.Collections.Generic;
using Newtonsoft.Json;
#region \\\ Disable Warnings \\\
#pragma warning disable CS8618
#pragma warning disable CS8600
#endregion
namespace Oxide.Plugins
{
[Info("WelcomeConsolePremium", "Disguise", "1.4.4")]
[Description("Give a warm welcome to your players in a fancy way.")]
class WelcomeConsolePremium : RustPlugin
{
#region \\\ INIT \\\
void Init()
{
permission.RegisterPermission("welcomeconsolepremium.admin", this);
}
void OnServerInitialized(bool init)
{
if (init == true)
base.LoadConfig();
configData = Config.ReadObject<ConfigData>();
if (configData.version < Version)
UpdateConfigValues();
Config.WriteObject(configData, true);
}
protected override void LoadDefaultConfig() => configData = GetBaseConfig();
protected override void SaveConfig() => Config.WriteObject(configData, true);
private void UpdateConfigValues()
{
string msg1 = "Your Config File is Outdated!";
string msg2 = $"Do you wish to update the config file? From v{configData.version} to v{Version}\n(All unsaved changes will be lost!) Y/N";
string msg3 = "[WelcomeConsolePremium] Config File Update Completed! You can continue...";
string msg4 = "[WelcomeConsolePremium] Config File Update Aborted! The plugin might not work properly!";
string msg5 = "[WelcomeConsolePremium] No valid answer were given! Config File Update Aborted!";
Console.ForegroundColor = ConsoleColor.Magenta;
Console.WriteLine(msg1);
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine(msg2);
Console.ResetColor();
string readline = Console.ReadLine();
if (readline == "Y")
{
ConfigData baseConfig = GetBaseConfig();
configData.version = Version;
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine(msg3);
Console.ResetColor();
}
else if (readline == "N")
{
Console.ForegroundColor = ConsoleColor.Magenta;
Console.WriteLine(msg4);
Console.ResetColor();
}
else if (readline != "N" || readline != "Y")
{
Console.ForegroundColor = ConsoleColor.Magenta;
Console.WriteLine(msg5);
Console.ResetColor();
}
}
#endregion
#region \\\ CONFIG \\\
#region \\\ MAIN \\\ < CONFIG
private static ConfigData configData;
class ConfigData
{
[JsonProperty(PropertyName = "Console_Welcome")]
public Console_Welcome text { get; set; }
/*[JsonProperty(PropertyName = "Console_Farewell")]
public Console_Farewell text2 { get; set; }*/
[JsonProperty(PropertyName = "Chat_General")]
public Chat_General chat_g { get; set; }
[JsonProperty(PropertyName = "Chat_Welcome")]
public Chat_Welcome chat { get; set; }
[JsonProperty(PropertyName = "Chat_Farewell")]
public Chat_Farewell chat2 { get; set; }
[JsonProperty(PropertyName = "Admin")]
public Admin admin { get; set; }
[JsonProperty(PropertyName = "Country")]
public Country country { get; set; }
[JsonProperty(PropertyName = "Version")]
public VersionNumber version { get; set; }
}
class Console_Welcome
{
[JsonProperty(PropertyName = "Enable Welcome Console Message")]
public bool enable_console { get; set; }
[JsonProperty(PropertyName = "Welcome")]
public string welcome { get; set; }
[JsonProperty(PropertyName = "Server Description")]
public string serverdescription { get; set; }
[JsonProperty(PropertyName = "GLHF / Endline")]
public string glhf { get; set; }
}
/*class Console_Farewell
{
[JsonProperty(PropertyName = "Enable Farewell Console Message")]
public bool enable_console_fw { get; set; }
[JsonProperty(PropertyName = "Goodbye")]
public string goodbye { get; set; }
[JsonProperty(PropertyName = "Thank You for Playing")]
public string ty_for_playing { get; set; }
[JsonProperty(PropertyName = "Server IP:port")]
public string serverconnect { get; set; }
}*/
class Chat_General
{
[JsonProperty(PropertyName = "Enable Chat Message")]
public bool enable_chat_msg { get; set; }
[JsonProperty(PropertyName = "Prefix")]
public string prefix { get; set; }
}
class Chat_Welcome
{
[JsonProperty(PropertyName = "Enable Welcome Message")]
public bool prnt_to_chat { get; set; }
[JsonProperty(PropertyName = "Chat Message (When Player Connects)")]
public string chat_msg { get; set; }
[JsonProperty(PropertyName = "Enable Welcome Broadcast")]
public bool enable_bc_c { get; set; }
[JsonProperty(PropertyName = "Broadcast Message (When Player Connects)")]
public string chat_bc_c { get; set; }
}
class Chat_Farewell
{
[JsonProperty(PropertyName = "Enable Farewell Broadcast")]
public bool enable_bc_dc { get; set; }
[JsonProperty(PropertyName = "Broadcast Message (When Player Disconnects)")]
public string chat_bc_dc { get; set; }
}
class Country
{
[JsonProperty(PropertyName = "API KEY (get it from here: https://extreme-ip-lookup.com)")]
public string key { get; set; }
[JsonProperty(PropertyName = "Show Player's Country (When Player Connects)")]
public bool enable_cc { get; set; }
[JsonProperty(PropertyName = "Show Player's Continent (When Player Connects)")]
public bool enable_ct { get; set; }
[JsonProperty(PropertyName = "Broadcast with Country")]
public string country_msg { get; set; }
[JsonProperty(PropertyName = "Broadcast with Continent")]
public string continent_msg { get; set; }
[JsonProperty(PropertyName = "Broadcast with Country & Continent")]
public string country_continent_msg { get; set; }
}
class Admin
{
[JsonProperty(PropertyName = "Enable Greet Admins")]
public bool greet_admins { get; set; }
[JsonProperty(PropertyName = "Require Permission")]
public bool req_perms_admin { get; set; }
[JsonProperty(PropertyName = "Chat Message")]
public string chat_msg_admin { get; set; }
}
class Response
{
[JsonProperty("country")]
public string CountryName { get; set; }
[JsonProperty("continent")]
public string Continent { get; set; }
}
#endregion
#region \\\ JSON \\\ < CONFIG
private ConfigData GetBaseConfig()
{
return new ConfigData
{
text = new Console_Welcome
{
enable_console = true,
welcome = "<size=30><color=#ffff00>Welcome to</color> <color=#00ffa2>My Server Name</color></size>",
serverdescription = "<size=12><color=#ffffff>This is the server description.\n- 2x gather rate\n- custom monuments\n- For more info, go to: discord.gg/mylink</color></size>",
glhf = "<size=10><color=#ffffaa>Good Luck & Have Fun!</color></size>"
},
/*text2 = new Console_Farewell
{
enable_console_fw = true,
goodbye = "<size=30><color=#ffff00>Thank you for playing on</color> <color=#00ffa2>My Server Name!</color></size>",
ty_for_playing = "<size=12><color=#ffffff>We hope you had enough fun for today and you're welcome back any time!</color></size>",
serverconnect = "<size=10><color=#ffffaa>Server: 127.0.0.0:28015</color>\n<color=#f8df0c>Don't forget to add it to your favorites!</color></size>"
},*/
chat_g = new Chat_General
{
enable_chat_msg = true,
prefix = "<color=orange>[</color>WelcomeConsole<color=orange>]</color>"
},
chat = new Chat_Welcome
{
chat_bc_c = "<color=orange>{0}</color> connected",
chat_msg = "Press <color=orange>F1</color> to view the information about the server.",
enable_bc_c = true,
prnt_to_chat = true
},
chat2 = new Chat_Farewell
{
chat_bc_dc = "<color=orange>{0}</color> disconnected",
enable_bc_dc = true
},
country = new Country
{
key = "key=ExAmPle1234",
enable_cc = true,
enable_ct = true,
country_msg = "<color=orange>{0}</color> connected <color=orange>[</color>{1}<color=orange>]</color>",
continent_msg = "<color=orange>{0}</color> <color=orange>[</color>{1}<color=orange>]</color>",
country_continent_msg = "<color=orange>{0}</color> <color=orange>[</color>{1}/{2}<color=orange>]</color>",
},
admin = new Admin
{
greet_admins = true,
req_perms_admin = false,
chat_msg_admin = "<color=#acfa58>{0}</color> is here to give you anxiety."
},
version = Version
};
}
#endregion
#endregion
#region \\\ HOOKS \\\
#region \\\ IP-LOOKUP & SERVER BROADCASTS \\\ < HOOKS
void OnUserConnected(IPlayer iplayer, string message)
{
if (configData.chat.prnt_to_chat && configData.chat.enable_bc_c && !configData.country.enable_cc && !configData.country.enable_ct && !iplayer.IsAdmin)
{
Server.Broadcast($"{configData.chat.chat_bc_c}", $"{configData.chat_g.prefix}", Convert.ToUInt64(iplayer.Id), iplayer.Name);
}
else if (configData.chat.prnt_to_chat && configData.chat.enable_bc_c && configData.admin.greet_admins && iplayer.IsAdmin && !configData.admin.req_perms_admin)
{
Server.Broadcast($"{configData.admin.chat_msg_admin}", $"{configData.chat_g.prefix}", Convert.ToUInt64(iplayer.Id), iplayer.Name);
}
else if (configData.chat.prnt_to_chat && configData.chat.enable_bc_c && configData.admin.greet_admins && iplayer.HasPermission("welcomeconsolepremium.admin"))
{
Server.Broadcast($"{configData.admin.chat_msg_admin}", $"{configData.chat_g.prefix}", Convert.ToUInt64(iplayer.Id), iplayer.Name);
}
if (configData.chat.prnt_to_chat && configData.country.enable_cc && !iplayer.IsAdmin || configData.chat.prnt_to_chat && configData.country.enable_ct && !iplayer.IsAdmin)
{
string apiUrl = $"https://extreme-ip-lookup.com/json/"; // 20 requests/minute in the free version
webrequest.Enqueue($"{apiUrl}{iplayer.Address}?{configData.country.key}", null, (code, response) =>
{
if (code != 200 || response == null)
{
PrintError($"API Webrequest Failed to Response!\nPlease make sure you have a valid API-key!");
Server.Broadcast($"{configData.chat.chat_bc_c}", $"{configData.chat_g.prefix}", Convert.ToUInt64(iplayer.Id), iplayer.Name);
return;
}
else
{
if (configData.country.enable_cc && configData.country.enable_ct)
{
string country = JsonConvert.DeserializeObject<Response>(response).CountryName;
string continent = JsonConvert.DeserializeObject<Response>(response).Continent;
Server.Broadcast($"{configData.country.country_continent_msg}", $"{configData.chat_g.prefix}", Convert.ToUInt64(iplayer.Id), iplayer.Name, country, continent);
}
else if (configData.country.enable_cc && !configData.country.enable_ct)
{
string country = JsonConvert.DeserializeObject<Response>(response).CountryName;
Server.Broadcast($"{configData.country.country_msg}", $"{configData.chat_g.prefix}", Convert.ToUInt64(iplayer.Id), iplayer.Name, country);
}
else if (!configData.country.enable_cc && configData.country.enable_ct)
{
string continent = JsonConvert.DeserializeObject<Response>(response).Continent;
Server.Broadcast($"{configData.country.continent_msg}", $"{configData.chat_g.prefix}", Convert.ToUInt64(iplayer.Id), iplayer.Name, continent);
}
}
}, this, RequestMethod.GET);
}
}
void OnPlayerConnected(BasePlayer bplayer)
{
do
{
if (configData.text.enable_console)
{
bplayer.ConsoleMessage($"{configData.text.welcome}\n\n{configData.text.serverdescription}\n\n{configData.text.glhf}");
}
if (configData.chat.prnt_to_chat && configData.chat_g.enable_chat_msg)
{
bplayer.SendMessage($"{configData.chat.chat_msg}", $"{configData.chat_g.prefix}:");
}
}
while (!bplayer.isSpawned);
}
void OnPlayerDisconnected(BasePlayer bplayer)
{
if (configData.chat.prnt_to_chat && configData.chat2.enable_bc_dc)
{
Server.Broadcast($"{configData.chat2.chat_bc_dc}", $"{configData.chat_g.prefix}", bplayer.userID, bplayer.displayName);
}
}
/*void OnPlayerSleep(BasePlayer bplayer)
{
do
{
if (configData.text.enable_console && configData.text2.enable_console_fw)
{
bplayer.ConsoleMessage($"{configData.text2.goodbye}\n\n{configData.text2.ty_for_playing}\n\n{configData.text2.serverconnect}");
}
}
while (bplayer.nextRespawnTime == 0f);
}*/
#endregion
#endregion
}
}
#endregion
/*
░░░░░░░░░░░░░░░░░░░░░▄▀░░▌
░░░░░░░░░░░░░░░░░░░▄▀▐░░░▌
░░░░░░░░░░░░░░░░▄▀▀▒▐▒░░░▌
░░░░░▄▀▀▄░░░▄▄▀▀▒▒▒▒▌▒▒░░▌
░░░░▐▒░░░▀▄▀▒▒▒▒▒▒▒▒▒▒▒▒▒█
░░░░▌▒░░░░▒▀▄▒▒▒▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▐▒░░░░░▒▒▒▒▒▒▒▒▒▌▒▐▒▒▒▒▒▀▄
░░░░▌▀▄░░▒▒▒▒▒▒▒▒▐▒▒▒▌▒▌▒▄▄▒▒▐
░░░▌▌▒▒▀▒▒▒▒▒▒▒▒▒▒▐▒▒▒▒▒█▄█▌▒▒▌
░▄▀▒▐▒▒▒▒▒▒▒▒▒▒▒▄▀█▌▒▒▒▒▒▀▀▒▒▐░░░▄
▀▒▒▒▒▌▒▒▒▒▒▒▒▄▒▐███▌▄▒▒▒▒▒▒▒▄▀▀▀▀
▒▒▒▒▒▐▒▒▒▒▒▄▀▒▒▒▀▀▀▒▒▒▒▄█▀░░▒▌▀▀▄▄ -MEOW
▒▒▒▒▒▒█▒▄▄▀▒▒▒▒▒▒▒▒▒▒▒░░▐▒▀▄▀▄░░░░▀
▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▒▒▄▒▒▒▒▄▀▒▒▒▌░░▀▄
▒▒▒▒▒▒▒▒▀▄▒▒▒▒▒▒▒▒▀▀▀▀▒▒▒▄▀
*/