Перейти к содержимому
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.
Опубликовано:

Well hello there its me again -_-

And last time I thought I solved the problem but I apperently didn't :(

 

So I want something to happen when the user presses a certain button....

Here's the code I made:

public CustomKillstreaks(Entity player)
       {
           ModLoaded();

           PlayerConnected += new Action(entity =>
           {
               entity.SetField("killstreak", 0);
               entity.SetField("deathstreak", 0);
               entity.SetField("has3killstreak", 0);
               entity.SetField("has5killstreak", 0);
               entity.Call("notifyonplayercommand", "give3killstreak", "+smoke");
               entity.Call("notifyonplayercommand", "give5killstreak", "+actionslot 1");
           });
           player.OnNotify("give3killstreak", (entity) =>
           {
               if ((player.GetField("has3killstreak") == 1))
               {
                      //Super Secret Custom KillStreak Code......
               }
               else
               {
                   player.Call("iprintlnbold", "You don't have a 3 Killstreak yet!");
               }
           });
       }

 

So when I run the server with this code I get the following error:

[scriptLoader] Loading script iSnipe
[scriptLoader] An error occurred during initialization of the script CustomKillstreaks: System.MissingMethodException: Default constructor not found for type iSnipe.CustomKillstreaks.

 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 
Spawn map (mp_bravo, war) complete.

 

I noticed that when I remove (Entity player) in the line of the constructor it doesnt give me this error. But that also disables me to use the code that I want if you know what I mean :P

 

Maybe it's something very obvious...

But how can I fix this?

Featured Replies

Опубликовано:
  • Автор
Remove "(Entity player)" and make it ()... thats a default constructor... also add ": base()" after it so it calls the base function constructor.

 

Ok so I did that. But now it leaves me with the error that "player" does not exist in the current context :?

Опубликовано:
  • Автор

But how do I fix the "player" does not exist in the current context" error? :?

I am not too sure I understand what u guys are telling me ;P

Because I took a look of some of TheApadayo's code and he could put (Entity player) in the constructor of his class? :o

Опубликовано:
Oops, my bad. This should work. You used the player/entity outside it's scope...

 

public CustomKillstreaks()
{
ModLoaded();

PlayerConnected += new Action(entity =>
{
	entity.SetField("killstreak", 0);
	entity.SetField("deathstreak", 0);
	entity.SetField("has3killstreak", 0);
	entity.SetField("has5killstreak", 0);
	entity.Call("notifyonplayercommand", "give3killstreak", "+smoke");
	entity.Call("notifyonplayercommand", "give5killstreak", "+actionslot 1");

	entity.OnNotify("give3killstreak", (player) =>
	{
		if ((player.GetField("has3killstreak") == 1))
		{
			   //Super Secret Custom KillStreak Code......
		}
		else
		{
			player.Call("iprintlnbold", "You don't have a 3 Killstreak yet!");
		}
	});
});
}

So if I were to change the variables "3kills/5kills" to like 9 and 10 will it be like that or am I missing something?

Опубликовано:
  • Автор
Oops, my bad. This should work. You used the player/entity outside it's scope...

 

public CustomKillstreaks()
{
ModLoaded();

PlayerConnected += new Action(entity =>
{
	entity.SetField("killstreak", 0);
	entity.SetField("deathstreak", 0);
	entity.SetField("has3killstreak", 0);
	entity.SetField("has5killstreak", 0);
	entity.Call("notifyonplayercommand", "give3killstreak", "+smoke");
	entity.Call("notifyonplayercommand", "give5killstreak", "+actionslot 1");

	entity.OnNotify("give3killstreak", (player) =>
	{
		if ((player.GetField("has3killstreak") == 1))
		{
			   //Super Secret Custom KillStreak Code......
		}
		else
		{
			player.Call("iprintlnbold", "You don't have a 3 Killstreak yet!");
		}
	});
});
}

 

Thank you so much it works now! :D

At first I solved it with an OnInterval statement which did work but messed stuff up in-game.

But now it work perfectly :P

Maybe I'll put up a showcase video of what I made when I get home from school. I think you guys will like it.

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.