Advertisement
Guest User

GM fix Plz

a guest
Feb 3rd, 2010
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.15 KB | None | 0 0
  1. --[[
  2.  
  3.     GModRP - Real Garry's Mod Roleplay.
  4.             By Slob187.
  5.         www.plane-builders.com
  6.  
  7. ]]         
  8.    
  9. --includes
  10. include('shared.lua')
  11. include('sv_ply_functions.lua')
  12. include("configuration.lua")
  13.  
  14. --lua file download
  15. AddCSLuaFile("shared.lua")
  16. AddCSLuaFile("cl_init.lua")
  17. AddCSLuaFile("itembase.lua")
  18.  
  19. --base include
  20. for k, v in pairs(file.FindInLua("GModRP/gamemode/base/*.lua")) do
  21.  
  22.     include("base/"..v)
  23.    
  24. end
  25.  
  26.  
  27. --plugins include
  28. for k, v in pairs(file.FindInLua("GModRP/gamemode/sv_plugins/*.lua")) do
  29.  
  30.     include("sv_plugins/"..v)
  31.    
  32. end
  33.  
  34.  
  35. --derma download
  36. for k, v in pairs( file.FindInLua( "GModRP/gamemode/derma/*.lua" ) ) do
  37.  
  38.     AddCSLuaFile("derma/"..v)
  39.    
  40. end
  41.  
  42.  
  43. --vgui download
  44. for k, v in pairs( file.FindInLua( "GModRP/gamemode/vgui/*.lua" ) ) do
  45.  
  46.     AddCSLuaFile("vgui/"..v)
  47.    
  48. end
  49.  
  50. Radiostations = {}
  51.  
  52. function GMRP.AddMaterial( f )
  53.  
  54.     resource.AddFile( "materials/"..f..".vmt" )
  55.     resource.AddFile( "materials/"..f..".vtf" )
  56.    
  57. end
  58.  
  59.  
  60. GMRP.AddMaterial( "gmodrp/icons/cake" )
  61. GMRP.AddMaterial( "gmodrp/icons/lighting" )
  62. GMRP.AddMaterial( "gmodrp/icons/money" )
  63.  
  64.  
  65. --settings
  66. if Configuration["realistic"] == 1 then
  67.  
  68.     game.ConsoleCommand( "sbox_godmode 0\n" )
  69.     game.ConsoleCommand( "sbox_plpldamage 0\n" )
  70.     game.ConsoleCommand( "sbox_noclip 0\n" )
  71.    
  72. end
  73.  
  74.  
  75. function GM:PlayerSpawn( ply )
  76.  
  77.     if !ply:GetNWBool( "sleeping" ) then
  78.    
  79.         if game.GetMap() == "rp_oviscity_gmc4" then
  80.    
  81.             GMRP.OvisCitySpawns( ply )
  82.        
  83.         end
  84.        
  85.         ply:SpawnProtection()
  86.  
  87.     end
  88.    
  89.     ply:ApplyPlayerSettings()
  90.    
  91.     ply:UnSpectate()
  92.    
  93. end
  94.  
  95.  
  96.  
  97. function GM:PlayerHurt( ply )
  98.  
  99.     self.BaseClass:PlayerHurt( ply )
  100.     ply:RealisticDamage()
  101.    
  102. end
  103.  
  104.  
  105.  
  106. function GMRP.SetModel( ply, command, args )
  107.  
  108.     for k, v in pairs( citizenmodels ) do
  109.    
  110.         if tostring( args[1] ) == v then
  111.        
  112.             if GMRP.UseLimit( ply ) then
  113.                 ply:SetPData( "rpmodel", args[1] )
  114.                 ply:SetModel( args[1] )
  115.                 ply:GreenNotify( "Player model changed to "..tostring( args[1] )..". This model will stay after rejoining." )  
  116.             end
  117.            
  118.         end
  119.        
  120.     end
  121.    
  122. end
  123.  
  124. GMRP.command( "setmodel", GMRP.SetModel )
  125.  
  126.  
  127. function GM:PlayerDeathSound(ply)
  128.  
  129.     ply:EmitSound("vo/npc/Barney/ba_ohshit03.wav") --say 'oh shit' when player dies
  130.     return true --disable the default beep sound   
  131.    
  132. end
  133.  
  134.  
  135. function GM:DoPlayerDeath( p, attacker, dmginfo )
  136.  
  137.     p:RedNotify( "You got knocked out and lost "..CUR..Configuration["knockouttax"].."." )
  138.     p:TakeMoney( Configuration["knockouttax"] )
  139.  
  140.     p:CreateRagdoll()
  141.    
  142. end
  143.  
  144.  
  145. function GM:ShowTeam( p )
  146.  
  147.     p:ConCommand( "gm_rp_shopmenu" )
  148.    
  149. end
  150.  
  151.  
  152. function GM:ShowHelp(ply)
  153.  
  154.     ply:ConCommand("gm_rp_motd")
  155.     return false
  156.    
  157. end
  158.  
  159.  
  160. function GM:PlayerInitialSpawn( ply )
  161.    
  162.     self.BaseClass:PlayerInitialSpawn( ply )
  163.    
  164.     ply:applyPayDay( TEAM_CITIZEN )
  165.    
  166.     ply:SetTeam( TEAM_CITIZEN )
  167.  
  168.     ply:SetupAccount()
  169.  
  170.     ply:CorrectMoney()
  171.  
  172.     ply:ConCommand( "gm_rp_motd" )
  173.  
  174.     GMRP.SendInventory( ply )
  175.    
  176.     GMRP.SendPermits( ply )
  177.  
  178.     for k, v in pairs( Radiostations ) do
  179.    
  180.         ply:SendLua("table.insert( Radiostations, '"..tostring( v ).."' )")
  181.        
  182.     end
  183.    
  184.     if ( ply:Nick() == "UNOWNABLE" ) then
  185.  
  186.         ply:Kick( "Please change your name and rejoin." )
  187.        
  188.     end
  189.    
  190. end
  191.  
  192.  
  193. function GM:PlayerDisconnected( ply )
  194.  
  195.     self.BaseClass:PlayerDisconnected( ply )
  196.    
  197.     ply:cleanEntOwnerShip()
  198.    
  199.     if timer.IsTimer( ply:UniqueID().."PayDayTimer" ) then
  200.    
  201.         timer.Destroy( ply:UniqueID().."PayDayTimer" )
  202.        
  203.     end
  204.    
  205. end
  206.  
  207.  
  208. local NextFireSpreadTime = 0
  209.  
  210. function GM:Think()
  211.  
  212.     for _, ply in pairs( player.GetAll() ) do  
  213.    
  214.         if ply:IsValid() then
  215.    
  216.             ply:StaminaCheck()
  217.            
  218.             ply:CheckHunger()      
  219.        
  220.             if ply:GetNWBool( "ishigh" ) then
  221.            
  222.                 if ply:GetVelocity():Length() > 0 then
  223.  
  224.                     ply:SetVelocity( Vector( math.random( -50, 50 ), math.random( -50, 50 ), 0 ) )
  225.                    
  226.                 end
  227.                
  228.             end
  229.            
  230.             if ply.NextO2Think == nil then
  231.            
  232.                 ply.NextO2Think = 0
  233.                
  234.             end
  235.        
  236.             if CurTime() > ply.NextO2Think then
  237.            
  238.                 if !ply:Alive() then return end    
  239.                
  240.                 if !ply.O2 then
  241.                
  242.                     if ply:WaterLevel() > 0 then
  243.                    
  244.                         ply:TakeDamage( 5, ply, ply )  
  245.                        
  246.                     end
  247.                    
  248.                 end
  249.                
  250.                 ply.NextO2Think = CurTime() + 1
  251.                
  252.             end
  253.            
  254.         end
  255.        
  256.     end
  257.  
  258.    
  259.     if CurTime() > NextFireSpreadTime then
  260.    
  261.         for k, v in pairs( ents.GetAll() ) do
  262.        
  263.             if v:GetClass() == "prop_physics" || v:IsPlayer() then
  264.        
  265.                 if v:IsOnFire() then
  266.                
  267.                     v:SetColor( 0, 0, 0, 255 )
  268.                    
  269.                     for _, ent in pairs( ents.FindInSphere( v:GetPos(), math.random( 30, 100 ) ) ) do
  270.                    
  271.                         if ( !ent:IsOnFire() ) then
  272.                    
  273.                             if ent:IsPlayer() && ent:Alive() && ent:Team() != TEAM_FIREFIGHTER then
  274.                            
  275.                                 ent:Ignite( 30, 0 )
  276.                                 ent:SetColor( 100, 100, 100, 255 )
  277.        
  278.                             elseif ent:GetClass() == "prop_physics" then
  279.                            
  280.                                 ent:Ignite( 300, 0 )
  281.                                 ent:SetColor( 0, 0, 0, 255 )
  282.                                
  283.                             end
  284.                            
  285.                         end
  286.                        
  287.                     end
  288.                    
  289.                 end
  290.                
  291.             end
  292.            
  293.         end
  294.        
  295.         NextFireSpreadTime = CurTime() + 3
  296.        
  297.     end
  298.    
  299. end
  300.  
  301.  
  302. function GM:PlayerShouldTakeDamage( victim, attacker )
  303.  
  304.     if attacker:IsValid() then
  305.    
  306.         local attClass = attacker:GetClass()
  307.    
  308.         if attClass == "prop_physics" then --disable the prop damage - no more prop killing
  309.        
  310.             return false
  311.    
  312.         elseif attacker:IsPlayer() then
  313.        
  314.             if attacker:GetActiveWeapon():GetClass() == "weapon_stunstick" then
  315.                
  316.                 victim:SetVelocity( attacker:GetAimVector():GetNormalized() * 1000 )
  317.                 victim:TakeDamage( 5, attacker, attacker:GetActiveWeapon() )       
  318.                
  319.                 return false       
  320.                
  321.             end        
  322.            
  323.         end
  324.        
  325.     end
  326.    
  327.     return true
  328.    
  329. end
  330.  
  331.  
  332. function GM:GravGunPunt( userid, target )
  333.  
  334.     DropEntityIfHeld( target )
  335.    
  336.     return false
  337.    
  338. end
  339.  
  340.  
  341. concommand.Add( "gm_spare1", function( p )
  342.  
  343.     p:ConCommand( "gm_showspare1" )
  344.    
  345. end )  
  346.  
  347.  
  348. concommand.Add( "gm_spare2", function( p )
  349.  
  350.     p:ConCommand( "gm_showspare2" )
  351.    
  352. end )
  353.    
  354.    
  355.    
  356. function GM:ShowSpare1( p )
  357.  
  358.     p:ConCommand( "gm_rp_playermenu" )
  359.    
  360. end
  361.  
  362.  
  363. function RunLuaAll( lua )
  364.  
  365.     for k, v in pairs( player.GetAll() ) do
  366.    
  367.         v:SendLua( lua )
  368.        
  369.     end
  370.  
  371. end
  372.  
  373.  
  374. function GM:KeyPress( ply, key )
  375.  
  376.     self.BaseClass:KeyPress( ply, key )
  377.  
  378.     local trace = {}
  379.     trace.start = ply:EyePos()
  380.     trace.endpos = trace.start + ply:GetAimVector() * 85
  381.     trace.filter = ply
  382.     local tr = util.TraceLine( trace ) 
  383.    
  384.     if !tr.Entity:IsValid() then return end
  385.    
  386.     if key == IN_USE && !ply:KeyDown( IN_SPEED ) then
  387.        
  388.         if tr.Entity.Money then
  389.        
  390.             ply:GreenNotify( "+"..CUR..tr.Entity.Amount )
  391.             ply:AddMoney(tr.Entity.Amount )
  392.             tr.Entity:Remove()
  393.            
  394.         end
  395.        
  396.         if tr.Entity:GetNWString( "permit" ) != "" then
  397.        
  398.             if tr.Entity.Owner == ply then
  399.        
  400.                 tr.Entity:Remove()
  401.                 ply.Permits = ply.Permits - 1
  402.                
  403.             end
  404.            
  405.         end
  406.        
  407.         if !tr.Entity.IsItem then return end
  408.        
  409.         tr.Entity.Use( ply, tr.Entity )
  410.        
  411.         if tr.Entity.Removeable then
  412.        
  413.             tr.Entity:Remove()
  414.            
  415.         end
  416.  
  417.     elseif ( key == IN_RELOAD ) then
  418.    
  419.         if !ply:InVehicle() then
  420.    
  421.             if tr.Entity.IsItem || ( string.find( tr.Entity:GetClass(), "vehicle" ) && tr.Entity:GetNWString( "doorowner" ) == ply:Nick() ) then
  422.            
  423.                 if string.find( tr.Entity:GetClass(), "vehicle" ) then
  424.                
  425.                     ply.alreadyOwned = ply.alreadyOwned - 1
  426.                    
  427.                 end
  428.                
  429.                 --if it's a radiostation, delete the radiostation's name from radiostation list
  430.                 GMRP.DeleteRadiostation( tr.Entity )               
  431.            
  432.                 GMRP.AddToInentory( ply, tr.Entity.ID )
  433.                 tr.Entity:Remove()
  434.                
  435.             end
  436.            
  437.         end
  438.  
  439.     end
  440.  
  441. end
  442.  
  443.  
  444. function GM:GetFallDamage( ply, fspeed )
  445.  
  446.     return ( fspeed / 8 )
  447.  
  448. end
  449.  
  450.  
  451. function GM:CanPlayerSuicide( p )
  452.  
  453.     if p.arrested then
  454.    
  455.         p:PrintMessage( HUD_PRINTCONSOLE, "You can not suicide while handcuffed." )
  456.         return false
  457.        
  458.     end
  459.    
  460.     return true
  461.    
  462. end
  463.  
  464.  
  465. function GM:PlayerSwitchFlashlight( ply, SwitchOn )
  466.    
  467.     return ply.hasFlashlight || !SwitchOn
  468.  
  469. end
  470.  
  471.  
  472. function GM:PlayerCanHearPlayersVoice( l, t )
  473.  
  474.     for k, v in pairs( ents.FindInSphere( t:GetPos(), Configuration["talkrange"] ) ) do
  475.    
  476.         if v == l then
  477.        
  478.             return true
  479.            
  480.         end
  481.  
  482.     end
  483.    
  484.     return false
  485.    
  486. end
  487.  
  488.  
  489. function GM:EntityRemoved( ent )
  490.  
  491.     GMRP.DeleteRadiostation( ent )
  492.    
  493. end
  494.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement