ItsMods

Full Version: FOV Plugin
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5
Hello guys

This is my fov plugin. Every player can change his fov to a number between 65 - 90.
Example: !fov 80
Requires @Nukem's dedicated server addon V1.190+

Source:
CSHARP Code
  1. using System;
  2. using Addon;
  3.  
  4. namespace MW3_FOV
  5. {
  6. public class zxz_FOVPlugin : CPlugin
  7. {
  8. public override void OnServerLoad()
  9. {
  10. ServerPrint("\n FOV Plugin loaded \n Author: zxz0O0 \n Thanks to Nukem, Jariz, Pozzuh\n");
  11. }
  12.  
  13. public override ChatType OnSay(string Message, ServerClient Client)
  14. {
  15. if (Message.StartsWith("!fov"))
  16. {
  17. string[] split = Message.Split(' ');
  18. try
  19. {
  20. int num;
  21. bool isNum = int.TryParse(split[1], out num);
  22. if (split.Length == 2 && isNum)
  23. {
  24. if (Convert.ToInt32(split[1]) <= 90 && Convert.ToInt32(split[1]) >= 65)
  25. {
  26. if (Convert.ToInt32(split[1]) <= 90 && Convert.ToInt32(split[1]) > 80)
  27. {
  28. Int32 fov = Convert.ToInt32(split[1]);
  29. float fovscale = (float)fov / 80;
  30.  
  31. SetClientDvar(Client.ClientNum, "cg_fov \" 80 \"");
  32. SetClientDvar(Client.ClientNum, "cg_fovscale \"" + fovscale + "\"");
  33. }
  34. else
  35. {
  36. SetClientDvar(Client.ClientNum, "cg_fov \"" + split[1] + "\"");
  37. SetClientDvar(Client.ClientNum, "cg_fovscale \"1\"");
  38. }
  39.  
  40. TellClient(Client.ClientNum, "PM: FOV changed to " + split[1] + ", default value is 65", true);
  41. }
  42. else
  43. TellClient(Client.ClientNum, "PM: Invalid parameter. Usage: !fov <fov 65-90>", true);
  44. return ChatType.ChatNone;
  45. }
  46.  
  47. }
  48. catch
  49. { }
  50. TellClient(Client.ClientNum, "PM: Invalid parameter. Usage: !fov <fov 65-90>", true);
  51. return ChatType.ChatNone;
  52. }
  53. return ChatType.ChatContinue;
  54. }
  55. }
  56. }


Thanks zxz...
Chicken
It will always tell the player that its invalid coz its outside the catch brackets Wink
(01-06-2012, 12:14)iAegle Wrote: [ -> ]It will always tell the player that its invalid coz its outside the catch brackets Wink

[Image: nope.avi.jpg]
Try it.
Very brave
Well, i'd rather have one that's always activated without using chatcommands, but okay, here you go
(01-06-2012, 13:14)jariz Wrote: [ -> ]Well, i'd rather have one that's always activated without using chatcommands, but okay, here you go

You only need to type it once and besides not everyone likes fov 90. Your plugin doesn't work btw.
noshit sherlock
how activateit without using chatcommands ?
This does not work correctly, when you use the command it changes the FOV, however it also changes so when you ADS it does not zoom in. This is a problem with snipers. I think its because you used cg_fovmin instead of cg_fov.

EDIT: Just tested, this is a edited properly working version:

Code:
using System;
    using Addon;
    
    namespace MW3_FOV
    {
    public class zxz_FOVPlugin : CPlugin
    {
    public override void OnServerLoad()
    {
    ServerPrint("\n FOV Plugin loaded \n Author: zxz0O0 \n Thanks to Nukem, Jariz, Pozzuh\n");
    }
    
    public override ChatType OnSay(string Message, ServerClient Client)
    {
    if (Message.StartsWith("!fov"))
    {
    string[] split = Message.Split(' ');
    try
    {
    int num;
    bool isNum = int.TryParse(split[1], out num);
    if (split.Length == 2 && isNum)
    {
    if (Convert.ToInt32(split[1]) <= 90 && Convert.ToInt32(split[1]) >= 65)
    {
    SetClientDvar(Client.ClientNum, "cg_fov \"" + split[1] + "\"");
    TellClient(Client.ClientNum, "PM: FOV changed to " + split[1] + ", default value is 65", true);
    }
    else
    TellClient(Client.ClientNum, "PM: Invalid parameter. Usage: !fov <fov 65-90>", true);
    return ChatType.ChatNone;
    }
    
    }
    catch
    { }
    TellClient(Client.ClientNum, "PM: Invalid parameter. Usage: !fov <fov 65-90>", true);
    return ChatType.ChatNone;
    }
    return ChatType.ChatAll;
    }
    }
    }
Pages: 1 2 3 4 5