Jump to content

Small help


manve1

Recommended Posts

I came up with a problem when i can't properly set the player's alpha. I don't know why but it just wouldn't set it to visible if he was invisible

addEventHandler('onResourceStop', getRootElement( ), 
function( p ) 
if ( getElementAlpha( p ) == 0 ) then 
setElementAlpha( p, 255 ) 
end 
end 
) 

Link to comment

Don't know if script should look like this but:

addEventHandler('onResourceStop', getRootElement( ), 
function( ) 
if getElementsByType('player') and ( getElementAlpha( source ) == 0 ) then 
setElementAlpha( source, 255 ) 
end 
end 
) 

P.S. It's my first time i use getElementAlpha

Link to comment

getElementsByType returns a table of elements, not a element.

addEventHandler ( 'onResourceStop', resourceRoot, 
    function ( ) 
        for _, player in ipairs ( getElementsByType ( "player" ) ) do 
            if ( getElementAlpha ( player ) == 0 ) then 
                setElementAlpha ( player, 255 ) 
            end 
        end 
    end 
) 

Link to comment
getElementsByType returns a table of elements, not a element.
ddEventHandler ( 'onResourceStop', resourceRoot, 
    function ( ) 
        for _, player in ipairs ( getElementsByType ( "player" ) ) do 
            if ( getElementAlpha ( player ) == 0 ) then 
                setElementAlpha ( player, 255 ) 
            end 
        end 
    end 
) 

You forgot an "a" in "addEventHandler".

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