Advertisement
Guest User

Untitled

a guest
Aug 7th, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.64 KB | None | 0 0
  1. ----------------------------------------------------------------------------------------------------------------------------------
  2. -- This script is made by Dr.Chapman(E-Mail: chap600@hotmail.com)(Steam: jespercal)
  3. -- Do NOT reupload or upload a 'fixed' version, if anything is wrong with it, tell me and I'll fix it.
  4. ----------------------------------------------------------------------------------------------------------------------------------
  5.  
  6. ----------------------------
  7. -- Configuation Functions --
  8. ----------------------------
  9. STA_IsRankNeeded = false -- Is the script for admins only?
  10. STA_EnableCustomRanks = true --Else it will just use admin and superadmin.
  11. STA_CustomRanks = {"Trial-Moderator"} -- If the custom ranks are enabled, what groups should be able to use this? ex. {"admin","superadmin"}
  12. ----------------------------
  13.  
  14.  
  15. -- Do NOT touch this below or you will risk to break the script!
  16. if SERVER then
  17.  
  18. AddCSLuaFile("sta_core.lua")
  19.  
  20. function STA_OnPlayerSprayed( ply )
  21. STA_BaseTable = STA_BaseTable or {}
  22. local shootpos = ply:GetShootPos()
  23. local trace = ply:GetEyeTrace()
  24. local steamid = ply:SteamID()
  25. STA_BaseTable[steamid] = STA_BaseTable[steamid] or {}
  26. STA_BaseTable[steamid].pos = trace.HitPos
  27. STA_BaseTable[steamid].ang = trace.HitNormal
  28. STA_BaseTable[steamid].name = ply:Name()
  29. umsg.Start("_STA_Update3D2DSprayTracker_Clean")
  30. umsg.End()
  31. for k,v in pairs(STA_BaseTable) do
  32. umsg.Start("_STA_Update3D2DSprayTracker_Add")
  33. umsg.Vector(v.pos)
  34. umsg.Angle(v.ang)
  35. umsg.String(k)
  36. umsg.String(v.name)
  37. umsg.End()
  38. end
  39. end
  40. hook.Add( "PlayerSpray", "STA_OnPlayerSprayed", STA_OnPlayerSprayed )
  41.  
  42. function STA_CheckAdmin( ply )
  43. if not STA_EnableCustomRanks then return end
  44. for k,v in pairs(STA_CustomRanks) do
  45. if ply:IsUserGroup(v) then
  46. return true
  47. end
  48. end
  49. return false
  50. end
  51.  
  52. function STA_OnPlayerSprayed( ply )
  53. STA_BaseTable = STA_BaseTable or {}
  54. timer.Simple(5,function()
  55. umsg.Start("_STA_Update3D2DSprayTracker_Clean")
  56. umsg.End()
  57. for k,v in pairs(STA_BaseTable) do
  58. umsg.Start("_STA_Update3D2DSprayTracker_Add")
  59. umsg.Vector(v.pos)
  60. umsg.Angle(v.ang)
  61. umsg.String(k)
  62. umsg.String(v.name)
  63. umsg.End()
  64. end
  65. end)
  66. end
  67. hook.Add("PlayerInitialSpawn","STA_OnPlayerSprayed",STA_OnPlayerSprayed)
  68.  
  69. function STA_PlayerSay_ToggleSTA( ply, text, team )
  70. if( string.sub(text,1,13) == "/spray" or string.sub(text,1,13) == "!spray" or string.sub(text,1,10) == ":spray" ) then
  71. if STA_IsRankNeeded then
  72. if( ( not STA_EnableCustomRanks and not ply:IsAdmin() ) or ( STA_EnableCustomRanks and not STA_CheckAdmin(ply) ) ) then
  73. return false
  74. end
  75. end
  76. if ply.STA_Enabled then
  77. chat.AddText(Color(255, 255, 255), "Spray Tracking has been ", Color(255, 51, 51), "Disabled",Color(255, 255, 255), ".")
  78. ply:SendLua([[STA_Is_Enabled = false
  79. surface.PlaySound("buttons/button15.wav")]])
  80. ply.STA_Enabled = false
  81. else
  82. chat.AddText(Color(255, 255, 255), "Spray Tracking has been ", Color(153, 255, 153), "Enabled", Color(255, 255, 255), " for your own personal use.")
  83. ply:SendLua([[STA_Is_Enabled = true
  84. surface.PlaySound("buttons/button15.wav")]])
  85. ply.STA_Enabled = true
  86. end
  87. return false
  88. end
  89. end
  90. hook.Add("PlayerSay","STA_PlayerSay_ToggleSTA",STA_PlayerSay_ToggleSTA)
  91. else
  92.  
  93. --include("sta_core.lua")
  94.  
  95. function STA_PaintHUDSprays()
  96. if not STA_Is_Enabled then return end
  97. STA_ClientBaseTable = STA_ClientBaseTable or {}
  98. for k,v in pairs(STA_ClientBaseTable) do
  99. local pos = (v[1]):ToScreen()
  100. local distance = (v[1]-LocalPlayer():GetShootPos()):Length()
  101. local alpha = math.Clamp(300-distance,0,255)
  102. draw.DrawText("User: ", "TabLarge", pos.x, pos.y-15, Color(255, 255, 255, alpha), TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT )
  103. draw.DrawText(v[3], "TabLarge", pos.x, pos.y, Color(255, 255, 255, alpha), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
  104. draw.DrawText("("..k..")", "TabLarge", pos.x, pos.y+15, Color(255, 255, 255, alpha), TEXT_ALIGN_CENTER, TEXT_ALIGN_RIGHT )
  105. end
  106. end
  107. hook.Add("HUDPaint","STA_PaintHUDSprays",STA_PaintHUDSprays)
  108.  
  109. function STA_Update3D2DSprayTracker( data )
  110. STA_ClientBaseTable = STA_ClientBaseTable or {}
  111. local pos = data:ReadVector()
  112. local ang = data:ReadAngle()
  113. local id = data:ReadString()
  114. local name = data:ReadString()
  115. STA_ClientBaseTable[id] = {pos,ang,name}
  116. end
  117. usermessage.Hook("_STA_Update3D2DSprayTracker_Add",STA_Update3D2DSprayTracker)
  118.  
  119. function STA_Update3D2DSprayTracker( data )
  120. STA_ClientBaseTable = {}
  121. end
  122. usermessage.Hook("_STA_Update3D2DSprayTracker_Clean",STA_Update3D2DSprayTracker)
  123.  
  124. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement