Jump to content

How to make other players invisible


yesyesok

Recommended Posts

addCommandHandler ( "invisible", 
    function ( player ) 
        for _, v in pairs ( getElementsByType ( "player" ) ) do 
            if ( v ~= player ) then 
                local vehicle = getPedOccupiedVehicle ( v ) 
                if ( isElement ( vehicle ) ) then 
                    setElementAlpha ( vehicle, 0 ) 
                end 
            end 
        end 
    end 
) 

This will make invisible other player's vehicle if you type /invisible.

Also there is resource for race server

https://community.multitheftauto.com/index.php?p= ... s&id=10179

Link to comment
It's better to change the other cars dimension if you want a full hide and this is better to get more fps
addCommandHandler ( "invisible", 
    function ( player ) 
        for _, v in pairs ( getElementsByType ( "player" ) ) do 
            if ( v ~= player ) then 
                local vehicle = getPedOccupiedVehicle ( v ) 
                if ( isElement ( vehicle ) ) then 
                    setElementDimension ( vehicle, 1 )    
                     setElementDimension ( player, 1 )      
                end 
            end 
        end 
    end 
) 

Like this?

Link to comment

addCommandHandler ( "invisible", function ( player ) 
  for _,v in pairs ( getElementsByType ( "player" ) ) do 
    if ( v ~= player ) then 
      if ( getPedOccupiedVehicle ( v ) ) then 
          setElementDimension ( getPedOccupiedVehicle ( v ), 564 )   
          setElementDimension ( v, 564 )   
      end 
    end 
  end 
end ) 
Link to comment
addCommandHandler ( "invisible", function ( player ) 
  for _,v in pairs ( getElementsByType ( "player" ) ) do 
    if ( v ~= player ) then 
      if ( getPedOccupiedVehicle ( v ) ) then 
          setElementDimension ( getPedOccupiedVehicle ( v ), 564 )   
          setElementDimension ( v, 564 )   
      end 
    end 
  end 
end ) 

Thanks :)

I've one question it won't effect the race gamemode right?

Player will still be able to view checkpoints and complete races

Link to comment
addeventHandler ( "invisible", source, function ( player ) 
        for _, v in pairs ( getElementsByType ( "player" ) ) do 
            if ( v ~= player ) then 
                local vehicle = getPedOccupiedVehicle ( v ) 
                if ( isElement ( vehicle ) ) then 
                    setElementAlpha ( vehicle, 0 ) 
                end 
            end 
        end 
   ) 

not working

Link to comment
addCommandHandler ( "invisible", 
    function ( player ) 
        for _, v in pairs ( getElementsByType ( "player" ) ) do 
            if ( v ~= player ) then 
                local vehicle = getPedOccupiedVehicle ( v ) 
                if ( isElement ( vehicle ) ) then 
                    setElementAlpha ( vehicle, 0 ) 
                end 
            end 
        end 
    end 
) 

But I think it should be client-side... Not sure. Try also:

addCommandHandler ( "invisible", 
    function ( ) 
        for _, v in pairs ( getElementsByType ( "player" ) ) do 
            if ( v ~= localPlayer ) then 
                local vehicle = getPedOccupiedVehicle ( v ) 
                if ( isElement ( vehicle ) ) then 
                    setElementAlpha ( vehicle, 0 ) 
                end 
            end 
        end 
    end 
) 

Check also this code client-side.

Link to comment
addCommandHandler ( "invisible", 
    function ( player ) 
        for _, v in pairs ( getElementsByType ( "player" ) ) do 
            if ( v ~= player ) then 
                local vehicle = getPedOccupiedVehicle ( v ) 
                if ( isElement ( vehicle ) ) then 
                    setElementAlpha ( vehicle, 0 ) 
                end 
            end 
        end 
    end 
) 

I Don't want a command for that it should work when the resource that, the reason i used addeventhandler

Link to comment

Try it clientside

addEventHandler ( "onClientResourceStart", resourceRoot, 
    function ( ) 
        for _, v in pairs ( getElementsByType ( "player" ) ) do 
            if ( v ~= localPlayer ) then 
                local vehicle = getPedOccupiedVehicle ( v ) 
                if ( isElement ( vehicle ) ) then 
                    setElementAlpha ( vehicle, 0 ) 
                end 
            end 
        end 
    end 
) 

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