Guest User

CL_INIT Spies

a guest
Mar 18th, 2011
52
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. include('shared.lua')
  2.  
  3. local inventory={}
  4.  
  5. function codenameCreate()
  6.  
  7.     local nameWindow=vgui.Create("DFrame")
  8.     nameWindow:SetPos(0,0)
  9.     nameWindow:SetSize(250,100)
  10.     nameWindow:SetTitle("Set Codename")
  11.     nameWindow:SetVisible(true)
  12.     nameWindow:SetDraggable(false)
  13.     nameWindow:ShowCloseButton(false)
  14.     nameWindow:MakePopup()
  15.    
  16.     local nameEntry = vgui.Create("DTextEntry",nameWindow)
  17.     nameEntry:SetPos(0,25)
  18.     nameEntry:SetTall(25)
  19.     nameEntry:SetWide(200)
  20.     nameEntry:SetEnterAllowed(true)
  21.     nameEntry.OnEnter = function()
  22.         RunConsoleCommand("applyCodename",nameEntry:GetValue())
  23.         nameWindow:Close()
  24.     end
  25.  
  26. end
  27.  
  28. concommand.Add("CodenameSet",codenameCreate)
  29.  
  30. function setPlayerColor()
  31.  
  32.     local colorWindow=vgui.Create("DFrame")
  33.     colorWindow:SetPos(0,0)
  34.     colorWindow:SetSize(ScrW()/2,ScrH()/2)
  35.     colorWindow:SetTitle("Choose your Color")
  36.     colorWindow:SetVisible(true)
  37.     colorWindow:SetDraggable(false)
  38.     colorWindow:ShowCloseButton(false)
  39.     colorWindow:MakePopup()
  40.    
  41.     local redButton=vgui.Create("DButton")
  42.     redButton:SetParent(colorWindow)
  43.     redButton:SetText("Red Agency: Skills")
  44.     redButton:SetPos(0,20)
  45.     redButton:SetSize(ScrW()/2,100)
  46.     redButton.DoClick=function()
  47.         RunConsoleCommand("SetRed")
  48.         colorWindow:Close()
  49.     end
  50.    
  51.     local greenButton=vgui.Create("DButton")
  52.     greenButton:SetParent(colorWindow)
  53.     greenButton:SetText("Green Agency: Info")
  54.     greenButton:SetPos(0,120)
  55.     greenButton:SetSize(ScrW()/2,100)
  56.     greenButton.DoClick=function()
  57.         RunConsoleCommand("SetGreen")
  58.         colorWindow:Close()
  59.     end
  60.    
  61.     local blackButton=vgui.Create("DButton")
  62.     blackButton:SetParent(colorWindow)
  63.     blackButton:SetText("Black Agency: Equipment")
  64.     blackButton:SetPos(0,220)
  65.     blackButton:SetSize(ScrW()/2,100)
  66.     blackButton.DoClick=function()
  67.         RunConsoleCommand("SetBlack")
  68.         colorWindow:Close()
  69.     end
  70.    
  71.  
  72. end
  73.  
  74. concommand.Add("setAgencyColor",setPlayerColor)
  75.  
  76. function onClientInit()
  77.  
  78.     local selfPlayer=LocalPlayer()
  79.  
  80.     selfPlayer.inventory={}
  81.     selfPlayer.docs={}
  82.  
  83. end
  84.  
  85. hook.Add("Initialize","TablesSetup",onClientInit)
  86.  
  87. function OpenAgentPanel()
  88.  
  89.     local inventoryWindow=vgui.Create("DFrame")
  90.     inventoryWindow:SetPos(50,0)
  91.     inventoryWindow:SetSize(ScrW()-50,ScrH())
  92.     inventoryWindow:SetTitle("Myself...")
  93.     inventoryWindow:SetVisible(true)
  94.     inventoryWindow:SetDraggable(false)
  95.     inventoryWindow:ShowCloseButton(true)
  96.     inventoryWindow:MakePopup()
  97.    
  98.    
  99.     local selfPlayer=LocalPlayer()
  100.    
  101.     if(inventory!=nil) then
  102.         for k,v in pairs(inventory) do
  103.             selfPlayer:ChatPrint("You have item "..v:GetName())
  104.         end
  105.     end
  106.  
  107.     selfPlayer:ChatPrint(tostring(inventory[0]))
  108.    
  109. end
  110.  
  111. function askforInv( handler, id, encoded, decoded )
  112.     inventory = decoded
  113.     OpenAgentPanel()
  114. end
  115.  
  116. datastream.Hook( "doInventory", askforInv );
  117.  
  118. function inventoryHook(mess)
  119.  
  120.     local selfPlayer=LocalPlayer()
  121.     local invInd=mess:ReadLong()  -- Read first
  122.     local indEnt=mess:ReadEntity() -- Read First
  123.     inventory[invInd]=indEnt
  124.    
  125. end
  126.  
  127. usermessage.Hook("InventorySend",inventoryHook)
  128.  
  129. function playerDrawing(ply)
  130.    
  131.     if(ply:Team()==1) then
  132.         render.SetColorModulation(0,0,0)
  133.     end
  134.     if(ply:Team()==2) then
  135.         render.SetColorModulation(0,1,0)
  136.     end
  137.     if(ply:Team()==3) then
  138.         render.SetColorModulation(1,0,0)
  139.     end
  140.  
  141. end
  142.  
  143. LocalPlayer().inventory={}
  144.  
  145. hook.Add("PrePlayerDraw","preDrawing",playerDrawing)
  146. hook.Add("PostPlayerDraw","PostDrawing",playerDrawing)
  147.  
  148. function dealerDraw()
  149.  
  150.     local dealerWindow=vgui.Create("DFrame")
  151.     dealerWindow:SetPos(0,0)
  152.     dealerWindow:SetSize(ScrW()/2,ScrH()/2)
  153.     dealerWindow:SetTitle("Document Dealer")
  154.     dealerWindow:SetVisible(true)
  155.     dealerWindow:SetDraggable(true)
  156.     dealerWindow:ShowCloseButton(true)
  157.     dealerWindow:MakePopup()
  158.    
  159.     local takeDocument=vgui.Create("DButton")
  160.     takeDocument:SetPos(0,10)
  161.     takeDocument:SetSize(ScrW()/2,100)
  162.     takeDocument:SetText("Take A Document")
  163.  
  164. end
  165.  
  166.  
  167.  
  168. function outputInventory()
  169.  
  170.     for k,v in pairs(LocalPlayer():GetTable().inventory) do
  171.         LocalPlayer():ChatPrint("Item is: "..v:GetClass())
  172.     end
  173.    
  174. end
  175.  
  176. concommand.Add("outputInventory",outputInventory)
RAW Paste Data Copied