Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.01 KB | None | 0 0
  1. SM = {}
  2.  
  3. function SM.CreateNPCs()
  4.  
  5.     local AmmoGuy = SM.CreateNPC('npc_combine_s', Vector(3422.0801, 10958.4746, -432.1877), Angle(0, -0.665, 0), (function(ply)
  6.         local t = ply:Team()
  7.         if t == TEAM_POLICE or t == TEAM_CHIEF or t == TEAM_MAGUARD then
  8.             ply:GiveAmmo(30,'SMG1')
  9.             ply:GiveAmmo(30,'Buckshot')
  10.             ply:GiveAmmo(30,'Pistol')
  11.             ply:ChatPrint("Chief Ben: Here is your ammo go patrol now!")
  12.         else
  13.             ply:ChatPrint("Chief Ben: You must be from the goverment to get ammo!")
  14.         end
  15.         return
  16.     end), 'models/combine_soldier_prisonguard.mdl'); //
  17.    
  18.         local HelloGuy = SM.CreateNPC('npc_combine', Vector(3775.6563, 10634.0566, -429.9688), Angle(0, -90, 0), (function(ply)
  19.         local t = ply:Team()
  20.         if t == TEAM_POLICE or t == TEAM_CHIEF or t == TEAM_MAGUARD then
  21.         ply:ChatPrint("Cop Bob: Shouldent you go patrol the city ?")
  22.         else
  23.         ply:ChatPrint("Cop Bob: Hello welcome to the city, enjoy your stay!")
  24.         end
  25.         return
  26.     end), 'models/combine_soldier.mdl'); //
  27.    
  28. end
  29.  
  30.  
  31.  
  32. //////////////////////////////////////////////////////////////////////////////////////////
  33. //////////////////////////////////////////////////////////////////////////////////////////
  34. //////////////////////////////////////////////////////////////////////////////////////////
  35.  
  36.  
  37.  
  38. function SM.CreateNPC(class,pos,ang,msg,model)
  39.     local NewNPC = ents.Create(class)
  40.     NewNPC:SetModel(model)
  41.     NewNPC:SetHullType( HULL_HUMAN )
  42.     NewNPC:SetNPCState( NPC_STATE_SCRIPT )
  43.     NewNPC.Umsg = msg
  44.     NewNPC:SetPos(pos)
  45.     NewNPC:SetAngles(ang)
  46.     NewNPC:CapabilitiesAdd( CAP_ANIMATEDFACE | CAP_TURN_HEAD )
  47.     NewNPC:SetSolid( SOLID_BBOX )
  48.     NewNPC:Spawn()
  49.     NewNPC:Activate()
  50.     NewNPC:SetHealth(999999999)
  51.    
  52.     local bubble = ents.Create("prop_physics")
  53.     bubble:SetModel("models/extras/info_speech.mdl")
  54.     bubble:SetPos(pos + Vector(0,0,90))
  55.     bubble:SetAngles(ang)
  56.     bubble:Spawn()
  57.     bubble:Activate()
  58.     bubble:SetParent(NewNPC)
  59.     bubble:SetCollisionGroup( COLLISION_GROUP_WORLD )
  60. end
  61.  
  62. function SM.DoMapSetup ( )
  63.     --RunConsoleCommand('ai_disabled 1')
  64.  
  65.     for k, v in pairs(ents.FindByClass('item_healthcharger')) do v:Remove(); end
  66.    
  67.     SM.CreateNPCs()
  68. end
  69. timer.Simple(5, SM.DoMapSetup);
  70.  
  71.  
  72.  
  73. //////////////////////////////////////////////////////////////////////////////////////////
  74. //////////////////////////////////////////////////////////////////////////////////////////
  75. //////////////////////////////////////////////////////////////////////////////////////////
  76.  
  77.  
  78.  
  79. function PlayerUseNPC(ply,key)
  80.     if !ply:IsValid() then return end
  81.     if key != IN_USE then return end
  82.     local ent = ply:GetEyeTrace().Entity
  83.     if !ent.Umsg then return end
  84.     if ent:GetPos():Distance(ply:GetPos()) > 80 then return end
  85.    
  86.     if type(ent.Umsg) == "function" then
  87.         ent.Umsg(ply)
  88.         return
  89.     end
  90.    
  91.     umsg.Start(tostring(ent.Umsg),ply)
  92.     umsg.End()
  93. end
  94. hook.Add( "KeyPress", "PlayerUseNPC", PlayerUseNPC )
  95.  
  96. function ScaleDamage( npc, hitgroup, dmginfo )
  97.     dmginfo:ScaleDamage( 0 )
  98. end
  99. hook.Add("ScaleNPCDamage","ScaleDamage",ScaleDamage)
  100.  
  101. resource.AddFile("models/keycard/keycard.mdl")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement