• Near death spectator issue
    5 replies, posted
I downloaded this near death script from the workshop that basically gives an effect near death. Only issue with it is that the effect carries out though to spectators which isn't too great if you plan on using it for TTT (This script was created for DarkRP and other similar gamemodes. So, how would I edit this script so that none of the effects lasted through to spectators? Thanks :) [lua]-----------------------------------------------------------------------= -------------------Close To Death Is Made By Buzzofwar-----------------= --The Idea Is Not Mine It Has Been Made Before I Just Coded It My Self-= -----------------------------------------------------------------------= -----------------------------------------------------------------------= -----------No One Is Allowed To COpy Or Redistribute This--------------= -----------------------------------------------------------------------= -----------------------------------------------------------------------= -----------------------------------------------------------------------= ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| local function BlurVis() if not LocalPlayer().BVis then LocalPlayer().BVis = 1 end if not LocalPlayer().CTDM then LocalPlayer().CTDM = 1 end if LocalPlayer():Health() <= 30 then if LocalPlayer().CTDM > 0 then LocalPlayer().CTDM = LocalPlayer().CTDM - 0.015;if LocalPlayer().CTDM < 0 then LocalPlayer().CTDM = 0 end end if LocalPlayer().BVis > 0.2 then LocalPlayer().BVis = LocalPlayer().BVis - 0.01;LocalPlayer():SetDSP( 4, false );if LocalPlayer().BVis < 0.2 then LocalPlayer().BVis = 0.2 end end else if LocalPlayer().CTDM < 1 then LocalPlayer().CTDM = LocalPlayer().CTDM + 0.015;if LocalPlayer().CTDM > 1 then LocalPlayer().CTDM = 1 end end if LocalPlayer().BVis < 1 then LocalPlayer().BVis = LocalPlayer().BVis + 0.01;LocalPlayer():SetDSP( 0, false );if LocalPlayer().BVis > 1 then LocalPlayer().BVis = 1 end end end ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| if LocalPlayer():Health() <= 30 then local CTDC = {} CTDC[ "$pp_colour_contrast" ] = .5 CTDC[ "$pp_colour_colour" ] = LocalPlayer().CTDM CTDC[ "$pp_colour_brightness" ] = 0 CTDC[ "$pp_colour_addr" ] = 0 CTDC[ "$pp_colour_addg" ] = 0 CTDC[ "$pp_colour_addb" ] = 0 CTDC[ "$pp_colour_mulr" ] = 1 CTDC[ "$pp_colour_mulg" ] = 0 CTDC[ "$pp_colour_mulb" ] = 0 DrawColorModify( CTDC ) end if LocalPlayer():Health() <= 15 then surface.PlaySound("ctd/breath.wav", 500, 200) local CTDC = {} CTDC[ "$pp_colour_contrast" ] = .5 CTDC[ "$pp_colour_colour" ] = LocalPlayer().CTDM CTDC[ "$pp_colour_brightness" ] = 0 CTDC[ "$pp_colour_addr" ] = 0 CTDC[ "$pp_colour_addg" ] = 0 CTDC[ "$pp_colour_addb" ] = 0 CTDC[ "$pp_colour_mulr" ] = 1.1 CTDC[ "$pp_colour_mulg" ] = 0 CTDC[ "$pp_colour_mulb" ] = 0 DrawColorModify( CTDC ) end ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| if LocalPlayer().BVis < 1 then DrawMotionBlur( LocalPlayer().BVis, 1, 0 ) end end hook.Add("RenderScreenspaceEffects","CloseToDeath",BlurVis) ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|[/lua]
GetObserverMode is your friend here. [url]http://wiki.garrysmod.com/page/Player/GetObserverMode[/url]
I'm sorry but I don't fully understand that (I'm Lua dumb). I was going to attempt to put something here but in the fear of it being incredibly stupid and being rated dumb by 100 people that would rather laugh at the lack of Lua knowledge than help me, decided not to.
Who cares if people rate you dumb, it's looks better to attempt rather than not try at all. You're basically going to check if the observer mode is equal to any of the types TTT uses for spectating, which I'm not really sure which ones because I've hardly worked with that gamemode.
Player:GetObserverMode(TEAM_SPECTATOR) This is probably completely wrong but spectator is reffered to as TEAM_SPECTATOR
You'd put one of the enumerations there, you can find a list of them here. [url]http://wiki.garrysmod.com/page/Enums/OBS_MODE[/url]
Sorry, you need to Log In to post a reply to this thread.