Advertisement
Guest User

Untitled

a guest
May 9th, 2013
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. #pragma semicolon 1
  2.  
  3. #include <sourcemod>
  4. #include <sdktools>
  5. #include <clientprefs>
  6. #include <easy_commands>
  7.  
  8. #define PLUGIN_VERSION "1.0.1"
  9.  
  10. public Plugin:myinfo = {
  11. name = "[ANY] Unrestricted FOV",
  12. author = "Dr. McKay",
  13. description = "Allows players to choose their own FOV",
  14. version = PLUGIN_VERSION,
  15. url = "http://www.doctormckay.com"
  16. };
  17.  
  18. new Handle:cookieFOV;
  19. new Handle:cvarFOVMin;
  20. new Handle:cvarFOVMax;
  21.  
  22. #define UPDATE_FILE "unrestricted_fov.txt"
  23. #define CONVAR_PREFIX "ufov"
  24. #include "mckayupdater.sp"
  25.  
  26. public OnPluginStart() {
  27. cookieFOV = RegClientCookie("unrestricted_fov", "Client Desired FOV", CookieAccess_Private);
  28.  
  29. cvarFOVMin = CreateConVar("ufov_min", "20", "Minimum FOV a client can set with the !fov command", _, true, 20.0, true, 180.0);
  30. cvarFOVMax = CreateConVar("ufov_max", "130", "Maximum FOV a client can set with the !fov command", _, true, 20.0, true, 180.0);
  31.  
  32. RegEasyAdminCmd("sm_fov <playerfilter> [FOV]", Command_FOV, Admin_Cheats, {Cmd_Filter, Cmd_Cell}, 2, 1);
  33. HookEvent("player_spawn", Event_PlayerSpawn);
  34. }
  35.  
  36. public Command_FOV(client, targets [], numTargets, fov) {
  37. if(!AreClientCookiesCached(client)) {
  38. ReplyToCommand(client, "\x04[SM] \x01This command is currently unavailable. Please try again later.");
  39. return;
  40. }
  41. if(fov == 0) {
  42. QueryClientConVar(client, "fov_desired", OnFOVQueried);
  43. ReplyToCommand(client, "\x04[SM] \x01Your FOV has been reset.");
  44. return;
  45. }
  46. if(fov < GetConVarInt(cvarFOVMin)) {
  47. QueryClientConVar(client, "fov_desired", OnFOVQueried);
  48. ReplyToCommand(client, "\x04[SM] \x01The minimum FOV you can set with !fov is %d.", GetConVarInt(cvarFOVMin));
  49. return;
  50. }
  51. if(fov > GetConVarInt(cvarFOVMax)) {
  52. QueryClientConVar(client, "fov_desired", OnFOVQueried);
  53. ReplyToCommand(client, "\x04[SM] \x01The maximum FOV you can set with !fov is %d.", GetConVarInt(cvarFOVMax));
  54. return;
  55. }
  56. decl String:cookie[12];
  57. IntToString(fov, cookie, sizeof(cookie));
  58. SetClientCookie(client, cookieFOV, cookie);
  59.  
  60. SetEntProp(client, Prop_Send, "m_iFOV", fov);
  61. SetEntProp(client, Prop_Send, "m_iDefaultFOV", fov);
  62.  
  63. ReplyToCommand(client, "\x04[SM] \x01Your FOV has been set to %d on this server.", fov);
  64. }
  65.  
  66. public Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) {
  67. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  68. if(!AreClientCookiesCached(client)) {
  69. return;
  70. }
  71.  
  72. decl String:cookie[12];
  73. GetClientCookie(client, cookieFOV, cookie, sizeof(cookie));
  74. new fov = StringToInt(cookie);
  75. if(fov < GetConVarInt(cvarFOVMin) || fov > GetConVarInt(cvarFOVMax)) {
  76. return;
  77. }
  78. SetEntProp(client, Prop_Send, "m_iFOV", fov);
  79. SetEntProp(client, Prop_Send, "m_iDefaultFOV", fov);
  80. }
  81.  
  82. public OnFOVQueried(QueryCookie:cookie, client, ConVarQueryResult:result, const String:cvarName[], const String:cvarValue[]) {
  83. if(result != ConVarQuery_Okay) {
  84. return;
  85. }
  86. SetClientCookie(client, cookieFOV, "");
  87. SetEntProp(client, Prop_Send, "m_iFOV", StringToInt(cvarValue));
  88. SetEntProp(client, Prop_Send, "m_iDefaultFOV", StringToInt(cvarValue));
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement