Jump to content

invisible command


Bean666

Recommended Posts

Posted
Server
function toggleInvis(thePlayer) 
    local id = getElementModel(thePlayer) 
    if id == 179 then 
        local alpha = getElementAlpha(thePlayer) 
        if alpha == 255 then  
            setElementAlpha(thePlayer, 0)    
        else            
            setElementAlpha(thePlayer, 255) 
        end 
    else  
        setElementAlpha(thePlayer, 255) 
    end 
end 
addCommandHandler("invis", toggleInvis) 

Client

function showOnShoot() 
    setElementAlpha(source, 255) 
end 
addEventHandler("onClientPlayerWeaponFire", getLocalPlayer(), showOnShoot) 

I can replace your code with few lines.

function invisible ( ) 
    if ( getElementModel ( localPlayer ) == 179 ) then 
        local n = ( getElementAlpha ( localPlayer ) > 0 ) and 0 or 255; 
        setElementAlpha ( localPlayer, n ); 
    end 
end 
addCommandHandler ( "invisible", invisible ) 

Use it client

Leave your script s-side and use this c-side:
addEventHandler ( "onClientPlayerWeaponFire", root, 
    function ( ) 
        setElementAlpha ( source, 255 ); 
    end 
); 

Posted
Leave your script s-side and use this c-side:
addEventHandler ( "onClientPlayerWeaponFire", root, 
    function ( ) 
        setElementAlpha ( source, 255 ); 
    end 
); 

It should be server side because on client side nobody will be able see him even if he shoot

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...