ItsMods

Full Version: Freeze?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey guys, i was thinking about a command which freeze u...
Like !freeze (nameuwant)
Can it be possible?, if its possible, can u make it to me? Thanks Big Grin
P.S my server its in 3.0 Tongue
yea. i want one too Smile
and maybe the code of how to freeze an player.
CSHARP Code
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Addon;
  5.  
  6. namespace ClassLibrary1
  7. {
  8. public class Class1:CPlugin
  9. {
  10. public override void OnServerLoad()
  11. {
  12. ServerPrint("Freeze Plugin by 8Q4S8 loaded!");
  13. }
  14. public override ChatType OnSay(string Message, ServerClient Client)
  15. {
  16. if (Message.ToLower().StartsWith("!freeze"))
  17. {
  18. string[] split = Message.Split(' ');
  19. foreach (ServerClient c in GetClients())
  20. {
  21. if (c.Name.ToLower().Contains(split[1].ToLower()))
  22. {
  23. c.Other.ControlsFrozen = true;
  24. TellClient(Client.ClientNum, "^1" + c.Name + "^7 is frozen!", true);
  25. }
  26. }
  27. return ChatType.ChatNone;
  28. }
  29. else if (Message.ToLower().StartsWith("!unfreeze"))
  30. {
  31. string[] split = Message.Split(' ');
  32. foreach (ServerClient c in GetClients())
  33. {
  34. if (c.Name.ToLower().Contains(split[1].ToLower()))
  35. {
  36. c.Other.ControlsFrozen = false;
  37. TellClient(Client.ClientNum,"^1"+ c.Name+"^7 is unfrozen!", true);
  38. }
  39. }
  40. return ChatType.ChatNone;
  41. }
  42. return ChatType.ChatContinue;
  43. }
  44. }
  45. }


I didn't test the plugin, you can edit the code if you want.
Commads are !freeze and !unfreeze.
Thx man. I'll test the code

it worked. thx again Smile
(02-10-2013, 18:42)8q4s8 Wrote: [ -> ]
CSHARP Code
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Addon;
  5.  
  6. namespace ClassLibrary1
  7. {
  8. public class Class1:CPlugin
  9. {
  10. public override void OnServerLoad()
  11. {
  12. ServerPrint("Freeze Plugin by 8Q4S8 loaded!");
  13. }
  14. public override ChatType OnSay(string Message, ServerClient Client)
  15. {
  16. if (Message.ToLower().StartsWith("!freeze"))
  17. {
  18. string[] split = Message.Split(' ');
  19. foreach (ServerClient c in GetClients())
  20. {
  21. if (c.Name.ToLower().Contains(split[1].ToLower()))
  22. {
  23. c.Other.ControlsFrozen = true;
  24. TellClient(Client.ClientNum, "^1" + c.Name + "^7 is frozen!", true);
  25. }
  26. }
  27. return ChatType.ChatNone;
  28. }
  29. else if (Message.ToLower().StartsWith("!unfreeze"))
  30. {
  31. string[] split = Message.Split(' ');
  32. foreach (ServerClient c in GetClients())
  33. {
  34. if (c.Name.ToLower().Contains(split[1].ToLower()))
  35. {
  36. c.Other.ControlsFrozen = false;
  37. TellClient(Client.ClientNum,"^1"+ c.Name+"^7 is unfrozen!", true);
  38. }
  39. }
  40. return ChatType.ChatNone;
  41. }
  42. return ChatType.ChatContinue;
  43. }
  44. }
  45. }


I didn't test the plugin, you can edit the code if you want.
Commads are !freeze and !unfreeze.
Thank u so much !!!!!!!!
Its works Big GrinDD
The above code is a bit verbose as your using the same code twice in the IF ELSE statement but only changing one thing in the TellClient method call, see the below which eliminates the redundant code and cleans things up.

CSHARP Code
  1. using Addon;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Text;
  5.  
  6. namespace Freezer
  7. {
  8. public class Freezer : CPlugin
  9. {
  10. public override void OnServerLoad()
  11. {
  12. ServerPrint("Freeze Plugin by 8Q4S8 loaded!");
  13. }
  14.  
  15. public override ChatType OnSay(string Message, ServerClient Client)
  16. {
  17. string msg = Message.ToLower();
  18. string[] split = msg.Split(' ');
  19.  
  20. if (msg.StartsWith("!freeze") || msg.StartsWith("!unfreeze"))
  21. {
  22. bool isFrozen = msg.StartsWith("!freeze");
  23.  
  24. foreach (ServerClient c in GetClients())
  25. {
  26. if (c.Name.ToLower() == split[1] || c.Name.ToLower().Contains(split[1]))
  27. {
  28. c.Other.ControlsFrozen = isFrozen;
  29. TellClient(Client.ClientNum, string.Format("^1{0} ^7is {1}!", c.Name, (isFrozen ? "frozen" : "unfrozen")), true);
  30. }
  31. }
  32.  
  33. return ChatType.ChatNone;
  34. }
  35.  
  36. return ChatType.ChatContinue;
  37. }
  38. }
  39. }