Advertisement
Silverlan

Untitled

Oct 8th, 2012
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.99 KB | None | 0 0
  1. local cvWep = CreateConVar("gm_sandbox_npc_weapon","0",FCVAR_REPLICATED | FCVAR_ARCHIVE)
  2.  
  3. local nextName
  4. local tbNPCs = {}
  5. hook.Add("PlayerSpawnNPC","npcspawngetname",function(pl,name,wepName) nextName = name end)
  6.  
  7. hook.Add("PlayerSpawnedNPC","npcspawnupdatemodel",function(pl,npc)
  8.     if(!nextName) then return end
  9.     if(tbNPCs[nextName]) then
  10.         local min,max = npc:GetCollisionBounds()
  11.         local hull = npc:GetHullType()
  12.         npc:SetModel(tbNPCs[nextName])
  13.         npc:SetSolid(SOLID_BBOX)
  14.         npc:SetHullType(hull)
  15.         npc:SetHullSizeNormal()
  16.         npc:SetCollisionBounds(min,max)
  17.         npc:DropToFloor()
  18.     end
  19.     nextName = nil
  20. end)
  21.  
  22. local function AddNPC(category,name,class,model,keyvalues,skin)
  23.     keyvalues = keyvalues || {}
  24.     keyvalues["additionalequipment"] = cvWep:GetString()
  25.     list.Set("NPC",name,{Name = name,Class = class,Skin = skin,Model = model,Category = category,KeyValues = keyvalues})
  26.     tbNPCs[name] = model
  27. end
  28. AddNPC("Some Category","Metro 1","npc_metropolice","models/stalker.mdl",{["manhacks"] = 2},1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement