Jump to content

[Solved] Hiding player name on aiming


ManeXi

Recommended Posts

Well I want to hide the name of a player when localPlayer is aiming it, then restore it when it stops aiming it.

function targetingActivated ( target ) 
    if ( target ) then 
        if getElementType(target) == "player" then 
            outputChatBox(getElementType(target),255,255,255) 
            setPlayerNametagShowing ( target, false ) 
        end 
    elseif not (target) then 
        outputChatBox("Heil Hitler!",0,255,0) 
        setPlayerNametagShowing ( target, true ) 
    end 
end 
addEventHandler ( "onClientPlayerTarget", getRootElement(), targetingActivated ) 

For obvious reasons when I stop aiming the enemy the "target" var becomes into false, so I can't hide a name of a undefinied player.

My question is how may I save the previous target?

Edited by Guest
Link to comment
Variables.

Tried this and nothing.

function targetingActivated ( target, prevTarget ) 
    if ( target ) then 
        if getElementType(target) == "player" then 
            outputChatBox(getElementType(target),255,255,255) 
            setPlayerNametagShowing ( target, false ) 
            target = prevTarget 
        end 
    elseif not (target) then 
        outputChatBox("Heil Hitler!",0,255,0) 
        setPlayerNametagShowing ( prevTarget, true ) 
    end 
end 
addEventHandler ( "onClientPlayerTarget", getRootElement(), targetingActivated ) 

Link to comment

try this

function targetingActivated (target) 
    if (target) then     
        if getElementType(target) == "player" then 
            outputChatBox(getElementType(target),255,255,255) 
            setPlayerNametagShowing (target, false) 
            prevTarget = target 
        end      
    else     
        if (prevTarget) then 
            outputChatBox("Heil Hitler!",0,255,0) 
            setPlayerNametagShowing (prevTarget, true) 
        else 
            outputChatBox("There is no target / previous target.") 
        end 
    end 
end 

but this may show player nick only if you aim again and have no target. is that what you want?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...