Перейти к содержимому
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.

[Help]how to kill designated player by type?

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

Hi. I need your help for making kill player script.

What codes should I add in this script?

 

I want to make command which can kill player who I designate.

For example, if I type command "!kill player1" , player1 will get killed.

 

Thank you for your help.

 

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

namespace TeachWeapon
{
   public class TeachWeapon : BaseScript
   {
               public TeachWeapon()
           : base()
       {

           PlayerConnected += new Action(entity =>
           {

               Call("setdvar", "motd", "test");
           });
       }
       public override void OnSay(Entity player, string name, string message)
       {
           if (player.IsAlive && (player.GetField("name") == "TeachMeEnglish"))
           {
                   if (message.StartsWith("kill"))
                   {
                   var dest = player.Origin;
                   dest.Z = dest.Z - 1000;
                   Call("magicbullet", "uav_strike_projectile_mp", player.Origin, dest, player);
                   }
           }
       }
   }
}

Featured Replies

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

ah. sorry. I didn't explain my need clearly.

I want to make command which can kill player who I designate.

For example, if I type command "!kill player1" , player1 will get killed.

 

In addition, thank you for your works such as MapEdit. It really makes mw3 more fun.

Okay... so... you want the player who says kill to get killed?
Опубликовано:
ah. sorry. I didn't explain my need clearly.

I want to make command which can kill player who I designate.

For example, if I type command "!kill player1" , player1 will get killed.

 

In addition, thank you for your works such as MapEdit. It really makes IW5 more fun.

Okay... so... you want the player who says kill to get killed?

Hopefully I can do this without spoonfeeding you (aka writing it for you)... Iterate through the first 18 entities (use getentbynum) and compare the name field in the entity to the wanted players name (which can be extracted by doing a << string.Split(" ")[1] >> on the message) and then call suicide on the resulting entity.

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

that code work correctly i cant compile now

 



       public override void OnSay(Entity player, string name, string message)
       {
           if (player.IsAlive && (player.GetField("name") == "TeachMeEnglish"))
           {
                   if (message.StartsWith("!kill"))
                   {
                        kill(player,message);
                   }
           }
       }
   }
}


       private void kill(Entity player, string message)
       {
           string[] strArray = message.Split(new char[] { ' ' });
           string newValue = "";
           if (strArray.Length <= 1)
           {
               TellClient(player, "^1Enter a playername");
           }
           else
           {
               Entity entity = FindByName(strArray[1]);
               if (entity == null)
               {
                   TellClient(player, "^1That user wasn't found or multiple were found.");
               }
               else if (strArray.Length > 2)
               {
                   for (int i = 2; i < strArray.Length; i++)
                   {
                       newValue = newValue + " " + strArray[i];
                   }
                   entity.Call("suicide");
               }
               else if (strArray.Length <= 2)
               {
                   entity.Call("suicide");
               }
           }
       }


       private Entity FindByName(string name)
       {
           int num = 0;
           Entity entity = null;
           foreach (Entity entity2 in Entitys)
           {
               if (0 <= entity2.Name.IndexOf(name, StringComparison.InvariantCultureIgnoreCase))
               {
                   entity = entity2;
                   num++;
               }
           }
           if ((num <= 1) && (num == 1))
           {
               return entity;
           }
           return null;
       }



       private void ServerSay(string message)
       {
           Utilities.ExecuteCommand("say " + message);
       }


       private void TellClient(Entity player, string message)
       {
           Utilities.ExecuteCommand(string.Concat(new object[] { "tell ", player.Call("getentitynumber", new Parameter[0]), " ", "^3[PM]^7: " + message }));
       }

  • 4 weeks later...
Опубликовано:
that code work correctly i cant compile now

 



       public override void OnSay(Entity player, string name, string message)
       {
           if (player.IsAlive && (player.GetField("name") == "TeachMeEnglish"))
           {
                   if (message.StartsWith("!kill"))
                   {
                        kill(player,message);
                   }
           }
       }
   }
}


       private void kill(Entity player, string message)
       {
           string[] strArray = message.Split(new char[] { ' ' });
           string newValue = "";
           if (strArray.Length <= 1)
           {
               TellClient(player, "^1Enter a playername");
           }
           else
           {
               Entity entity = FindByName(strArray[1]);
               if (entity == null)
               {
                   TellClient(player, "^1That user wasn't found or multiple were found.");
               }
               else if (strArray.Length > 2)
               {
                   for (int i = 2; i < strArray.Length; i++)
                   {
                       newValue = newValue + " " + strArray[i];
                   }
                   entity.Call("suicide");
               }
               else if (strArray.Length <= 2)
               {
                   entity.Call("suicide");
               }
           }
       }


       private Entity FindByName(string name)
       {
           int num = 0;
           Entity entity = null;
           foreach (Entity entity2 in Entitys)
           {
               if (0 <= entity2.Name.IndexOf(name, StringComparison.InvariantCultureIgnoreCase))
               {
                   entity = entity2;
                   num++;
               }
           }
           if ((num <= 1) && (num == 1))
           {
               return entity;
           }
           return null;
       }



       private void ServerSay(string message)
       {
           Utilities.ExecuteCommand("say " + message);
       }


       private void TellClient(Entity player, string message)
       {
           Utilities.ExecuteCommand(string.Concat(new object[] { "tell ", player.Call("getentitynumber", new Parameter[0]), " ", "^3[PM]^7: " + message }));
       }

Thank you for giving me good codes. but, your codes didn't work at my server.

I found following codes and these codes work well at my server.

public override void OnSay(Entity player, string name, string message)
{ 
  if (message.StartsWith("die"))
               {

                   Designated_Suicide(player, message);
                   OnInterval(1000, () =>
                   {
                       foreach (Entity ALLMEMBERS in getPlayers())
                       {
                           Utilities.RawSayTo(ALLMEMBERS.EntRef, "KOREA Infected : DON'T HIDE OR GO TOO FAR ^^");
                       }
                       return false;
                   });
               }
}
       private void Designated_Suicide(Entity TeachMe, string message)
       {
           Char[] delimit = { ' ' };
           String[] split = message.Split(delimit);
           if (split.Length == 1)
           {
               Utilities.RawSayTo(TeachMe.EntRef, "die [player's name]");
           }
           OnInterval(1000, () =>
           {
               foreach (Entity Designated_PLAYERS in getPlayers())
               {
                   if (Designated_PLAYERS.Name.Contains(message.Split(' ')[1]))
                   {
                       Designated_PLAYERS.Call("suicide");
                   }
               }
               return false;

           });
       }
       private Entity[] getPlayers()
       {
           List players = new List();
           for (int i = 0; i < 17; i++)
           {
               Entity entity = Call("getentbynum", i);
               if (entity != null)
               {
                   if (entity.IsPlayer)
                   {
                       players.Add(entity);
                   }
               }
           }
           return players.ToArray();
       }

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

my code work but i write wrong that and you must put entity.call("suicide"); in on after delay ;)

Опубликовано:
my code work but i write wrong that and you must put entity.call("suicide"); in on after delay ;)

foreach (Entity entity2 in Entitys)
           {
               if (0 <= entity2.Name.IndexOf(name, StringComparison.InvariantCultureIgnoreCase))
               {
                   entity = entity2;
                   num++;
               }
           }

Hi. I didn't know what "entity2 in Entitys" means . and I didn't have list Code related to Entitys.

maybe, such reason, it didn't work at my server.

Anyway, Thank you for help and your scripts are really good and usefull.

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.