Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------------------------------------------------------------------------------------------------------------------------
- -- This script is made by Dr.Chapman(E-Mail: chap600@hotmail.com)(Steam: jespercal)
- -- Do NOT reupload or upload a 'fixed' version, if anything is wrong with it, tell me and I'll fix it.
- ----------------------------------------------------------------------------------------------------------------------------------
- ----------------------------
- -- Configuation Functions --
- ----------------------------
- STA_IsRankNeeded = false -- Is the script for admins only?
- STA_EnableCustomRanks = true --Else it will just use admin and superadmin.
- STA_CustomRanks = {"Trial-Moderator"} -- If the custom ranks are enabled, what groups should be able to use this? ex. {"admin","superadmin"}
- ----------------------------
- -- Do NOT touch this below or you will risk to break the script!
- if SERVER then
- AddCSLuaFile("sta_core.lua")
- function STA_OnPlayerSprayed( ply )
- STA_BaseTable = STA_BaseTable or {}
- local shootpos = ply:GetShootPos()
- local trace = ply:GetEyeTrace()
- local steamid = ply:SteamID()
- STA_BaseTable[steamid] = STA_BaseTable[steamid] or {}
- STA_BaseTable[steamid].pos = trace.HitPos
- STA_BaseTable[steamid].ang = trace.HitNormal
- STA_BaseTable[steamid].name = ply:Name()
- umsg.Start("_STA_Update3D2DSprayTracker_Clean")
- umsg.End()
- for k,v in pairs(STA_BaseTable) do
- umsg.Start("_STA_Update3D2DSprayTracker_Add")
- umsg.Vector(v.pos)
- umsg.Angle(v.ang)
- umsg.String(k)
- umsg.String(v.name)
- umsg.End()
- end
- end
- hook.Add( "PlayerSpray", "STA_OnPlayerSprayed", STA_OnPlayerSprayed )
- function STA_CheckAdmin( ply )
- if not STA_EnableCustomRanks then return end
- for k,v in pairs(STA_CustomRanks) do
- if ply:IsUserGroup(v) then
- return true
- end
- end
- return false
- end
- function STA_OnPlayerSprayed( ply )
- STA_BaseTable = STA_BaseTable or {}
- timer.Simple(5,function()
- umsg.Start("_STA_Update3D2DSprayTracker_Clean")
- umsg.End()
- for k,v in pairs(STA_BaseTable) do
- umsg.Start("_STA_Update3D2DSprayTracker_Add")
- umsg.Vector(v.pos)
- umsg.Angle(v.ang)
- umsg.String(k)
- umsg.String(v.name)
- umsg.End()
- end
- end)
- end
- hook.Add("PlayerInitialSpawn","STA_OnPlayerSprayed",STA_OnPlayerSprayed)
- function STA_PlayerSay_ToggleSTA( ply, text, team )
- if( string.sub(text,1,13) == "/spray" or string.sub(text,1,13) == "!spray" or string.sub(text,1,10) == ":spray" ) then
- if STA_IsRankNeeded then
- if( ( not STA_EnableCustomRanks and not ply:IsAdmin() ) or ( STA_EnableCustomRanks and not STA_CheckAdmin(ply) ) ) then
- return false
- end
- end
- if ply.STA_Enabled then
- chat.AddText(Color(255, 255, 255), "Spray Tracking has been ", Color(255, 51, 51), "Disabled",Color(255, 255, 255), ".")
- ply:SendLua([[STA_Is_Enabled = false
- surface.PlaySound("buttons/button15.wav")]])
- ply.STA_Enabled = false
- else
- chat.AddText(Color(255, 255, 255), "Spray Tracking has been ", Color(153, 255, 153), "Enabled", Color(255, 255, 255), " for your own personal use.")
- ply:SendLua([[STA_Is_Enabled = true
- surface.PlaySound("buttons/button15.wav")]])
- ply.STA_Enabled = true
- end
- return false
- end
- end
- hook.Add("PlayerSay","STA_PlayerSay_ToggleSTA",STA_PlayerSay_ToggleSTA)
- else
- --include("sta_core.lua")
- function STA_PaintHUDSprays()
- if not STA_Is_Enabled then return end
- STA_ClientBaseTable = STA_ClientBaseTable or {}
- for k,v in pairs(STA_ClientBaseTable) do
- local pos = (v[1]):ToScreen()
- local distance = (v[1]-LocalPlayer():GetShootPos()):Length()
- local alpha = math.Clamp(300-distance,0,255)
- draw.DrawText("User: ", "TabLarge", pos.x, pos.y-15, Color(255, 255, 255, alpha), TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT )
- draw.DrawText(v[3], "TabLarge", pos.x, pos.y, Color(255, 255, 255, alpha), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
- draw.DrawText("("..k..")", "TabLarge", pos.x, pos.y+15, Color(255, 255, 255, alpha), TEXT_ALIGN_CENTER, TEXT_ALIGN_RIGHT )
- end
- end
- hook.Add("HUDPaint","STA_PaintHUDSprays",STA_PaintHUDSprays)
- function STA_Update3D2DSprayTracker( data )
- STA_ClientBaseTable = STA_ClientBaseTable or {}
- local pos = data:ReadVector()
- local ang = data:ReadAngle()
- local id = data:ReadString()
- local name = data:ReadString()
- STA_ClientBaseTable[id] = {pos,ang,name}
- end
- usermessage.Hook("_STA_Update3D2DSprayTracker_Add",STA_Update3D2DSprayTracker)
- function STA_Update3D2DSprayTracker( data )
- STA_ClientBaseTable = {}
- end
- usermessage.Hook("_STA_Update3D2DSprayTracker_Clean",STA_Update3D2DSprayTracker)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement