shadowndacorner

stuff for ya

Nov 10th, 2012
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.31 KB | None | 0 0
  1. --CLIENT
  2. local currenthits = {}
  3.  
  4. local function hitmenu( data )
  5.     str=data:ReadString()
  6.     table.insert( currenthits, str )
  7.     print( "loaded hits!" )
  8. end
  9. usermessage.Hook( "hits", hitmenu )
  10.  
  11. function showmenu( ply )
  12.     local panel = vgui.Create( "DFrame")
  13.     panel:MakePopup()
  14.     panel:SetMouseInputEnabled(true)
  15.     panel:SetKeyboardInputEnabled(true)
  16.     panel:SetTitle( "Hit list" )
  17.     panel:SetSize( 500, 400 )
  18.     panel:SetPos( ScrW()/2-(panel:GetWide()/2), ScrH()/2-(panel:GetTall()/2) )
  19.     local listed = vgui.Create( "DListView", panel )
  20.     listed:SetSize( 450, 330 )
  21.     listed:SetPos( 25, 45 )
  22.     listed:AddColumn( "Name" )
  23.    
  24.     for k, v in pairs( currenthits ) do
  25.         listed:AddLine(table.concat( currenthits[v] ))
  26.     end
  27. end
  28. usermessage.Hook( "hitmenu", showmenu )
  29.  
  30. function showclientmenu( ply )
  31.     local panel = vgui.Create( "DFrame")
  32.     panel:MakePopup()
  33.     panel:SetMouseInputEnabled(true)
  34.     panel:SetKeyboardInputEnabled(true)
  35.     panel:SetTitle( "Place a hit!" )
  36.     panel:SetSize( 500, 400 )
  37.     panel:SetPos( ScrW()/2-(panel:GetWide()/2), ScrH()/2-(panel:GetTall()/2) )
  38. end
  39. usermessage.Hook( "placehitmenu", showclientmenu )
  40.  
  41. usermessage.Hook( "newHit", function(data)
  42.     local ply=data:ReadEntity()
  43.     local amnt=data:ReadShort()
  44.     ply.HitMoney=amnt
  45. end)
  46.  
  47. --SERVER
  48. function menu( ply, text)
  49.     if ( string.sub( text, 1, 5 ) == "!hits" ) and ply:Team() != TEAM_HIT then
  50.         umsg.Start( "placehitmenu", ply )
  51.         umsg.End()
  52.         return ""
  53.     elseif TEAM_HIT == ply:Team() then
  54.         umsg.Start( "hitmenu", ply )
  55.         umsg.End()
  56.     end
  57. end
  58. hook.Add( "PlayerSay", "chat", menu )
  59.  
  60. hits = {}
  61. players = {}
  62. function getplayers()
  63. end
  64.  
  65. local function MakeHit(ply, args)
  66.     local plyname=string.lower(string.sub(ply, 0, string.len(args)-string.find(string.reverse(args), " ")))
  67.     local num=tonumber(string.sub(args, string.len(args)-1, string.len(args)))
  68.     if !(plyname and num) then
  69.         GAMEMODE:Notify(ply, 1, 4, "Your hit was not set - you probably formatted the command wrong!  /hit player amount")
  70.         return
  71.     end
  72.     local hitte=NULL
  73.     for f, v in pairs(player.GetAll()) do
  74.         if string.find(v:Nick(), plyname) then
  75.             hitte=v
  76.             break
  77.         end
  78.     end
  79.     if IsValid(hitte) then return end
  80.     v.HitMoney=num
  81.     for f, v in pairs(player.GetAll()) do
  82.         if v:Team()==TEAM_HIT then
  83.             SendUserMessage("newHit", v, hitte, num)
  84.         end
  85.     end
  86. end
  87. AddChatCommand("/hit", MakeHit)
Advertisement
Add Comment
Please, Sign In to add comment