• GetObserverTarget
    8 replies, posted
I don't know why but when I get my buddies to spectate me it doesn't work. I've been trying for awhile now so I thought it'd just be better to get some help off some lua 13375 here :) What I've got so far :s [CODE]hook.Add( "Think", "ObserverTargetChanges", function() for k, ply in pairs( player.GetAll() ) do if IsValid( ply ) then local obtgt = ply:GetObserverTarget() if obtgt ~= ply.OldObserverTarget then ply.OldObserverTarget = obtgt hook.Call( "OnChangeObserverTarget", GM or GAMEMODE, ply, obtgt ) end end end end) hook.Add( "OnChangeObserverTarget", "ObserverTargetChanges", function( ply, new_target ) if IsValid( new_target ) then -- Player is spectating a new player chat.AddText( Color( 0, 255, 255 ), "Spectate logs: " .. ply:Nick() .. " is now spectating " .. new_target:Nick() ) surface.PlaySound "vo/npc/female01/ohno.wav" else -- Player is no longer spectating chat.AddText( Color( 0, 255, 0 ), "Spectate logs: " .. ply:Nick() .. " is no longer spectating " .. new_target:Nick() ) surface.PlaySound "garrysmod/balloon_pop_cute.wav" end end)[/CODE] Edit: No errors when ran btw
Are they spectating you with an addon (ULX, FAdmin, exsto, assmod, etc.) or do you mean the actual ply:Spectate function? I'm asking because the FAdmin spectate functionality cannot be measured with GetObserverTarget. I've done that on purpose.
[QUOTE=FPtje;46776891]Are they spectating you with an addon (ULX, FAdmin, exsto, assmod, etc.) or do you mean the actual ply:Spectate function? I'm asking because the FAdmin spectate functionality cannot be measured with GetObserverTarget. I've done that on purpose.[/QUOTE] I thought it would be the same for all :s Guess there's multiple ways of doing things.
[QUOTE=TeddyHunter;46776985]I thought it would be the same for all :s Guess there's multiple ways of doing things.[/QUOTE] He does it that way because cheaters can't tell when they are being spectated using his system.
[QUOTE=sasherz;46778768]He does it that way because cheaters can't tell when they are being spectated using his system.[/QUOTE] I kind of guessed that, don't know why he does it tho. Still need help with this if anyones interested, maybe just point me in the right direction?
Look at the code of FAdmin?
No client except the spectator can possibly find out whether someone is spectating in FAdmin. The server simply doesn't send any information or even hints about it. in all other admin mods, however, you can simply use :GetObserverTarget. The code looks good to me by the way. I don't see any errors.
actually theres an error in the else part of the if statement, in the chat.AddText, you use new_target:Nick() even though the code only runs if new_target is invalid
[QUOTE=Sm63;46788160]actually theres an error in the else part of the if statement, in the chat.AddText, you use new_target:Nick() even though the code only runs if new_target is invalid[/QUOTE] Thanks, I'm still very new to lua and coding in general so any help is greatly appreciated :)
Sorry, you need to Log In to post a reply to this thread.