Перейти к содержимому
View in the app

A better way to browse. Learn more.

Zloplay community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
Опубликовано:

First of all, I'm new to C#, so this mod might not be perfect!

The way it works is very simple. It reads a text file and displays it's content as welcome message on your server.

 

Source:

//momo5502 is learning C# 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

using InfinityScript;

namespace Message
{

   public class Message : BaseScript
   {
       public Message()
           : base()
       {

           //Read the config file
           var config = File.ReadAllLines("scripts\\message.txt");

           //Write to the console
           Log.Write(LogLevel.Info, "\nMomo5502's Welcome Message Plugin loaded!\nMessage set to:\n  1st Line: \"" + config[0] + "\"\n  2nd Line: \"" + config[1] + "\"\n  3rd Line: \"" + config[2] + "\"\nIcon set to: \"" + config[3] + "\"\nHud set to: \"" + config[4] + "\"");

           //Precache the Icon
           Call("precacheShader", config[3]);

           PlayerConnected += entity =>
           {
               //Hud Text
               var hud = HudElem.CreateFontString(entity, "objective", 3f);
               hud.SetPoint("TOPCENTER", "TOPCENTER", 0, 10);
               hud.SetText(config[4]);

               entity.AfterDelay(12000, Entity =>
                   {
                       //First Line
                       var elem = HudElem.CreateFontString(entity, "objective", 2.5f); 
                       elem.SetPoint("CENTER", "CENTER", 0, -50);
                       elem.SetText(config[0]);

                       //Second Line
                       var text = HudElem.CreateFontString(entity, "objective", 2.0f); 
                       text.SetPoint("CENTER", "CENTER", 0, -30);
                       text.SetText(config[1]);

                       //Third Line
                       var text1 = HudElem.CreateFontString(entity, "objective", 1.75f);
                       text1.SetPoint("CENTER", "CENTER", 0, -10);
                       text1.SetText(config[2]);

                       //Icon
                       var icon = HudElem.CreateIcon(entity, config[3], 60, 60);
                       icon.SetPoint("CENTER", "CENTER", 0, 30);
                       icon.Alpha = 1;

                       //Hide everything after 7 seconds
                       entity.AfterDelay(7000, Momo5502 => //Momo5502 as parameter^^
                       {
                           elem.SetText("");
                           text.SetText("");
                           text1.SetText("");
                           icon.Alpha = 0;
                       });   
                   });     
           };
       }
   }
}

 

Extract the downloaded files to the scripts folder and edit your welcome message in the message.txt

 

-UPDATE-

Supports now up to 3 lines of text, 1 icon and a hud text.

If you don't want for example the icon (or line1, 2 or 3), don't completly remove the line from the message.txt, but simply leave the line blank (or your unwanted line of text)!

To sum it up: Your message.txt contains out of 6 lines (no matter if blank or not):

Line 1: Text of line 1

Line 2: Text of line 2

Line 3: Text of line 3

Line 4: Iconname

Line 5: Hud text on the top

Line 6: Security line (always blank; otherwise server will crash)

 

Please report any bugs! :)

 

 

911D24FFAC5E2A378EBDC5BFD2BC3D9B3259FA72

 

C8D4CA156F51FE5C3401057E1ABC620FBBCE878F

 

  • Approved by Pigophone on 08/10/12

  • Ответы 82
  • Просмотры 7,2k
  • Created
  • Последний ответ

Top Posters In This Topic

Do you want to be able to configure the font through the config? 88 пользователей проголосовало

  1. 1. Do you want to be able to configure the font through the config?

    • Don't care!
      11%
      15
    • No!
      3%
      5
    • Yes!
      84%
      107

Пожалуйста, войдите или зарегистрируйтесь для голосования в опросе.

Featured Replies

Опубликовано:
Aalalex":2kvv1vkz]
Is this good? :(

haven't tested if the plugin actually works though..

 

[scriptLoader] An error occurred during initialization of the script Message: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IndexOutOfRangeException: Array index is out of range.

 at Message.Message..ctor () [0x00000] in :0 

 at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)

 at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0 

 --- End of inner exception stack trace ---

 at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0 

 at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0 

 at System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) [0x00000] in :0 

 at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x00000] in :0 

 at System.Activator.CreateInstance (System.Type type) [0x00000] in :0 

 at InfinityScript.ScriptLoader.LoadAssembly (System.Reflection.Assembly assembly) [0x00000] in :0

 

 

You probably don't have 5 lines in your message.txt file... ;)

 

Ah, yes.

:/

Thanks.

  • 2 weeks later...
Опубликовано:

Occassionally when players enter it shown welcome message to everyone, so have reported it showing on every player entering. Can you check it only shows to player connecting.

 

Are you also able to make it so the icon could be an image file

  • 2 weeks later...
Опубликовано:

Ummmmm I have a Question...

I wanna set a Icon, but i dont know where i have to Drop it? :?:

 

Another Question....

~>Can be any Image or you have some [special] Images List?

~>Type of Image?

Example: .jpg .icon .bmp

 

~>Size?

Example: 12 x 12 or 46 x 46

 

Sorry, if i did some Stupid Question.... but i wanna know and i didnt find any post talking about it :?

  • 2 weeks later...
Опубликовано:
@momo would you be so kind and upload the source? ;)

from ilspy:

using InfinityScript;
using System;
using System.IO;
namespace Message
{
public class Message : BaseScript
{
	public Message()
	{
		Log.Write(4, "Momo5502's Welcome Message Plugin loaded!");
		string[] settings = File.ReadAllLines("scripts\\message.txt");
		Log.Write(4, "Message set to:");
		Log.Write(4, "  1st Line: \"" + settings[0] + "\"");
		Log.Write(4, "  2nd Line: \"" + settings[1] + "\"");
		Log.Write(4, "  3rd Line: \"" + settings[2] + "\"");
		Log.Write(4, "Icon set to: \"" + settings[3] + "\"");
		int message_displayed = 0;
		base.Call("precacheShader", new Parameter[]
		{
			settings[3]
		});
		base.add_PlayerConnected(delegate(Entity entity)
		{
			message_displayed = 0;
			entity.add_SpawnedPlayer(delegate
			{
				if (message_displayed == 0)
				{
					HudElem elem = HudElem.CreateFontString(entity, "default", 2.5f);
					elem.SetPoint("CENTER", "CENTER", 0, -50);
					elem.SetText(settings[0]);
					HudElem text = HudElem.CreateFontString(entity, "default", 2f);
					text.SetPoint("CENTER", "CENTER", 0, -30);
					text.SetText(settings[1]);
					HudElem text1 = HudElem.CreateFontString(entity, "default", 1.75f);
					text1.SetPoint("CENTER", "CENTER", 0, -10);
					text1.SetText(settings[2]);
					message_displayed = 1;
					HudElem icon = HudElem.CreateIcon(entity, settings[3], 60, 60);
					icon.SetPoint("CENTER", "CENTER", 0, 30);
					icon.set_Alpha(1f);
					message_displayed = 1;
					entity.AfterDelay(5000, delegate(Entity Entity)
					{
						elem.SetText("");
						text.SetText("");
						text1.SetText("");
						icon.set_Alpha(0f);
					});
				}
			});
		});
	}
}
}

I am not developing, I merely dragged and dropped this file into ILSpy and copied the decompiled source. This post is completely without prejudice.

Опубликовано:
@momo would you be so kind and upload the source? ;)

from ilspy:

using InfinityScript;
using System;
using System.IO;
namespace Message
{
public class Message : BaseScript
{
	public Message()
	{
		Log.Write(4, "Momo5502's Welcome Message Plugin loaded!");
		string[] settings = File.ReadAllLines("scripts\\message.txt");
		Log.Write(4, "Message set to:");
		Log.Write(4, "  1st Line: \"" + settings[0] + "\"");
		Log.Write(4, "  2nd Line: \"" + settings[1] + "\"");
		Log.Write(4, "  3rd Line: \"" + settings[2] + "\"");
		Log.Write(4, "Icon set to: \"" + settings[3] + "\"");
		int message_displayed = 0;
		base.Call("precacheShader", new Parameter[]
		{
			settings[3]
		});
		base.add_PlayerConnected(delegate(Entity entity)
		{
			message_displayed = 0;
			entity.add_SpawnedPlayer(delegate
			{
				if (message_displayed == 0)
				{
					HudElem elem = HudElem.CreateFontString(entity, "default", 2.5f);
					elem.SetPoint("CENTER", "CENTER", 0, -50);
					elem.SetText(settings[0]);
					HudElem text = HudElem.CreateFontString(entity, "default", 2f);
					text.SetPoint("CENTER", "CENTER", 0, -30);
					text.SetText(settings[1]);
					HudElem text1 = HudElem.CreateFontString(entity, "default", 1.75f);
					text1.SetPoint("CENTER", "CENTER", 0, -10);
					text1.SetText(settings[2]);
					message_displayed = 1;
					HudElem icon = HudElem.CreateIcon(entity, settings[3], 60, 60);
					icon.SetPoint("CENTER", "CENTER", 0, 30);
					icon.set_Alpha(1f);
					message_displayed = 1;
					entity.AfterDelay(5000, delegate(Entity Entity)
					{
						elem.SetText("");
						text.SetText("");
						text1.SetText("");
						icon.set_Alpha(0f);
					});
				}
			});
		});
	}
}
}

I am not developing, I merely dragged and dropped this file into ILSpy and copied the decompiled source. This post is completely without prejudice.

I already got you can view it with .NET Reflector

Опубликовано:
  • Автор
@momo would you be so kind and upload the source? ;)

from ilspy:

using InfinityScript;
using System;
using System.IO;
namespace Message
{
public class Message : BaseScript
{
	public Message()
	{
		Log.Write(4, "Momo5502's Welcome Message Plugin loaded!");
		string[] settings = File.ReadAllLines("scripts\\message.txt");
		Log.Write(4, "Message set to:");
		Log.Write(4, "  1st Line: \"" + settings[0] + "\"");
		Log.Write(4, "  2nd Line: \"" + settings[1] + "\"");
		Log.Write(4, "  3rd Line: \"" + settings[2] + "\"");
		Log.Write(4, "Icon set to: \"" + settings[3] + "\"");
		int message_displayed = 0;
		base.Call("precacheShader", new Parameter[]
		{
			settings[3]
		});
		base.add_PlayerConnected(delegate(Entity entity)
		{
			message_displayed = 0;
			entity.add_SpawnedPlayer(delegate
			{
				if (message_displayed == 0)
				{
					HudElem elem = HudElem.CreateFontString(entity, "default", 2.5f);
					elem.SetPoint("CENTER", "CENTER", 0, -50);
					elem.SetText(settings[0]);
					HudElem text = HudElem.CreateFontString(entity, "default", 2f);
					text.SetPoint("CENTER", "CENTER", 0, -30);
					text.SetText(settings[1]);
					HudElem text1 = HudElem.CreateFontString(entity, "default", 1.75f);
					text1.SetPoint("CENTER", "CENTER", 0, -10);
					text1.SetText(settings[2]);
					message_displayed = 1;
					HudElem icon = HudElem.CreateIcon(entity, settings[3], 60, 60);
					icon.SetPoint("CENTER", "CENTER", 0, 30);
					icon.set_Alpha(1f);
					message_displayed = 1;
					entity.AfterDelay(5000, delegate(Entity Entity)
					{
						elem.SetText("");
						text.SetText("");
						text1.SetText("");
						icon.set_Alpha(0f);
					});
				}
			});
		});
	}
}
}

I am not developing, I merely dragged and dropped this file into ILSpy and copied the decompiled source. This post is completely without prejudice.

I already got you can view it with .NET Reflector

Cheaters... :lol:

Опубликовано:
@momo would you be so kind and upload the source? ;)

from ilspy:

I am not developing, I merely dragged and dropped this file into ILSpy and copied the decompiled source. This post is completely without prejudice.

Thank you.

EDIT: That code is not compilable. ILSpy doesn't decompile the code correctly. .NET Reflector works like a charm though.

Опубликовано:

Hmm HUD Icons seem to hate me, when I use the icon you used it works fine..

but when I want to use for example this one: specialty_longsprint_upgrade

its screws up and shows some strange blocky image :S

what am I doing wrong here? :(

Опубликовано:
Aalalex":3lzfveh6]Hmm HUD Icons seem to hate me, when I use the icon you used it works fine..

but when I want to use for example this one: specialty_longsprint_upgrade

its screws up and shows some strange blocky image :S

what am I doing wrong here? :(

maybe name of the icon is wrong.

Опубликовано:
  • Автор
Aalalex":3luq91sh]Hmm HUD Icons seem to hate me, when I use the icon you used it works fine..

but when I want to use for example this one: specialty_longsprint_upgrade

its screws up and shows some strange blocky image :S

what am I doing wrong here? :(

maybe name of the icon is wrong.

 

dunno, i had the same problem with some icons. Maybe there are a few which simply don't work!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Гость
Ответить в тему...

Сейчас на странице 0

  • Нет пользователей, просматривающих эту страницу

Важная информация

Используя этот сайт, вы соглашаетесь Условия использования.

Account

Navigation

Поиск

Поиск

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.