mattjeanes

Evolve Thirdperson plugin

Dec 31st, 2012
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.11 KB | None | 0 0
  1. local PLUGIN = {}
  2. PLUGIN.Title = "Third Person"
  3. PLUGIN.Description = "Allows players to toggle third person view."
  4. PLUGIN.Author = "Alan Edwardes"
  5. PLUGIN.ChatCommand = "thirdperson"
  6. PLUGIN.Usage = "[1/0]"
  7. PLUGIN.Privileges = { "Third Person" }
  8.  
  9. function PLUGIN:CalcView( ply, pos, angles, fov )
  10.     if ply.EV_ThirdPerson then
  11.         return {
  12.             origin = pos-(angles:Forward()*100),
  13.             angles = angles,
  14.             fov = fov
  15.         }
  16.     end
  17. end
  18.  
  19. function PLUGIN:ShouldDrawLocalPlayer( ply )
  20.     if ply.EV_ThirdPerson then return true end
  21. end
  22.  
  23. function PLUGIN:PlayerInitialSpawn( ply )
  24.     timer.Create("SetThirdPersonViewLoadIn", 5, 1, function()
  25.         --[[
  26.             For some reason you can't add to the player
  27.             table before the player has completely loaded
  28.             in, so delay it 5 seconds.
  29.         ]]--
  30.         self:SetThirdPersonView( ply, ply:GetProperty( "ThirdPersonView" ) )
  31.     end )
  32. end
  33.  
  34. function PLUGIN:SetThirdPersonView( ply, setting )
  35.     if setting ~= nill then
  36.         ply:SendLua("LocalPlayer().EV_ThirdPerson = " .. tostring(setting) )
  37.     end
  38. end
  39.  
  40. function PLUGIN:Call( ply, args )
  41.     if ply:EV_HasPrivilege( "Third Person" ) then
  42.         if args[1] == "0" then
  43.             ply:SetProperty( "ThirdPersonView", false )
  44.             evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " switched to first person view." )
  45.             self:SetThirdPersonView( ply, false )
  46.         else
  47.             ply:SetProperty( "ThirdPersonView", true )
  48.             evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " switched to third person view." )
  49.             self:SetThirdPersonView( ply, true )
  50.         end
  51.     else
  52.         evolve:Notify( ply, evolve.colors.red, evolve.constants.notallowed )
  53.     end
  54. end
  55.  
  56. evolve:RegisterPlugin( PLUGIN )
  57.  
  58. local PLUGIN = {}
  59. PLUGIN.Title = "First Person"
  60. PLUGIN.Description = "So players can just type !firstperson to return to normal."
  61. PLUGIN.Author = "Alan Edwardes"
  62. PLUGIN.ChatCommand = "firstperson"
  63.  
  64. function PLUGIN:Call( ply, args )
  65.     ply:SetProperty( "ThirdPersonView", false )
  66.     evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " switched to first person view." )
  67.     ply:SendLua( "LocalPlayer().EV_ThirdPerson = false" )
  68. end
  69.  
  70. evolve:RegisterPlugin( PLUGIN )
Add Comment
Please, Sign In to add comment