Jump to content

All player invisible?


Admigo

Recommended Posts

Heey all,

I want to make a f1 key for making all other players invisible.

I made this code(server side):

  
iv = 0 
  
function invis(thePlayer) 
    for index, player in ipairs(getElementsByType("player")) do 
        if (player ~= thePlayer) then 
            if iv == 0 then 
        iv = 1 
        setPlayerNametagShowing(player, false) 
        setElementAlpha(player, 0) 
         else 
        iv = 0 
        setPlayerNametagShowing(player, true) 
        setElementAlpha(player, 255) 
             end 
    end 
    end 
end 
bindKey("F1","down",invis) 

But when i pres f1 nothing happens.

No errors.

Pls help,

Thanks Admigo.

Link to comment
iv = 0 
  
function invis() 
    for index, player in ipairs(getElementsByType("player")) do 
        if (player ~= localPlayer) then 
            if (iv == 0) then 
                iv = 1 
                setPlayerNametagShowing(player, false) 
                setElementAlpha(player, 0) 
            else 
                iv = 0 
                setPlayerNametagShowing(player, true) 
                setElementAlpha(player, 255) 
            end 
        end 
    end 
end 
bindKey("F1","down",invis) 

Link to comment
local bState = { } 
  
function fHide( player ) 
    bState[ player ] = not bState[ player ] 
    if bState[ player ] then 
        setPlayerNametagShowing( root, false ) 
        setElementAlpha( root, 0 ) 
    else 
        setPlayerNametagShowing( root, true ) 
        setElementAlpha( root, 255 ) 
    end 
    return true  
end 
  
addEventHandler( 'onPlayerJoin', root,  
    function( ) 
        bindKey( source, 'F1', 'down', fHide ) 
    end 
) 
     
addEventHandler( 'onResourceStart', resourceRoot, 
    function( ) 
        for _,v in pairs( getElementsByType 'player' ) do 
            bindKey( v, 'F1', 'down', fHide ) 
        end  
    end 
)    

Solidsnake14, He want sync it for all.

Edited by Guest
Link to comment

If use it in client side it hide all players only for you ( but all can see you ), if server side anybody hide and anybody can't see each other .

I think you understand.

If you know, you said this words, but you not say.

You say it

I'm not sure if he want's that, but well, let's wait and see who was right .
Edited by Guest
Link to comment

Can you explain?

If use it in client side it hide all players only for you ( but all can see you ), if server side anybody hide and anybody can't see each other .

What you choice?

Client

local state 
  
function fHide( ) 
    state = not state 
    for _, v in pairs( getElementsByType 'player' ) do 
        if v ~= localPlayer then 
            if state then 
                setPlayerNametagShowing( v, false ) 
                setElementAlpha( v, 0 ) 
            else 
                setPlayerNametagShowing( v, true ) 
                setElementAlpha( v, 255 ) 
            end 
        end 
    end 
end 
bindKey( 'F1', 'down',fHide ) 

Link to comment
@kenix :I tested with a friend but f1 dont work. If i press f1 i can show/hide all players. i need it for [DM].

Show meta.

  
local state 
  
function fHide( ) 
    state = not state 
    for _, v in pairs( getElementsByType 'player' ) do 
        if v ~= localPlayer then 
            if state then 
                setPlayerNametagShowing( v, false ) 
                setElementAlpha( v, 0 ) 
            else 
                setPlayerNametagShowing( v, true ) 
                setElementAlpha( v, 255 ) 
            end 
        end 
    end 
end 
bindKey( 'F1', 'down',fHide ) 
  

This code hide/show ( all but not you ).

Edited by Guest
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...