Jump to content

How hide an object from the player(client-side)?


NoName74

Recommended Posts

Code please..

Server-side:

if weapon1 == "M95 BARRETT" then 
    m95a = createObject(1900, x,y,z) 
    attachElementToBone(m95a, source, 12, 0,0,0,0,-90,0) 
    triggerClientEvent (source, "hiderweap", source, m95a) 
end 

Client-side: 
function hiderweap(ident) 
?????????????? 
end 
addEvent("hiderweap", true) 
addEventHandler("hiderweap", getRootElement(), hiderweap) 

It's all I have...

setElementVisibleTo 

This does not work with all entities - vehicles, players and objects are exempt.(с) wiki

Link to comment
Code please..

Server-side:

if weapon1 == "M95 BARRETT" then 
    m95a = createObject(1900, x,y,z) 
    attachElementToBone(m95a, source, 12, 0,0,0,0,-90,0) 
    triggerClientEvent (source, "hiderweap", source, m95a) 
end 

Client-side: 
function hiderweap(ident) 
?????????????? 
end 
addEvent("hiderweap", true) 
addEventHandler("hiderweap", getRootElement(), hiderweap) 

It's all I have...

setElementVisibleTo 

This does not work with all entities - vehicles, players and objects are exempt.(с) wiki

Ow, why don't you create it in client side then and set its alpha to 0?

Link to comment
  
if weapon1 == "M95 BARRETT" then 
    m95a = createObject(1900, x,y,z) 
    attachElementToBone(m95a, source, 12, 0,0,0,0,-90,0) 
    setElementVisibleTo(m95a,root,false) 
    setElementVisibleTo(m95a,source,true) 
end 
  

Function "setElementVisibleTo" not works for the elements with type "player", "vehicle" and "object". .-.

But thanks for answer. ^^,

Link to comment

got it how to do it.

  
  
if weapon1 == "M95 BARRETT" then 
    m95a = createObject(1900, x,y,z) 
    attachElementToBone(m95a, source, 12, 0,0,0,0,-90,0) 
    setElementData(source,"objectperm",true) 
end 
if getElementData(source,"objectperm") == true then 
setElementAlpha(m95a,255)  
else 
setElementAlpha(m95a,0) 
end 
  

Edited by Guest
Link to comment

got it how to do it.

  
  
if weapon1 == "M95 BARRETT" then 
    m95a = createObject(1900, x,y,z) 
    attachElementToBone(m95a, source, 12, 0,0,0,0,-90,0) 
    setElementData(source,"objectperm",true) 
end 
if getElementData(source,"objectperm") == true then 
setElementAlpha(m95a,255)  
else 
setElementAlpha(m95a,0) 
end 
  

Edited by Guest
Link to comment

got it how to do it.

  
  
if weapon1 == "M95 BARRETT" then 
    m95a = createObject(1900, x,y,z) 
    attachElementToBone(m95a, source, 12, 0,0,0,0,-90,0) 
    setElementData(source,"objectperm",true) 
end 
if getElementData(source,"objectperm") == true then 
setElementAlpha(m95a,255)  
else 
setElementAlpha(m95a,0) 
end 
  

Link to comment

got it how to do it.

  
  
if weapon1 == "M95 BARRETT" then 
    m95a = createObject(1900, x,y,z) 
    attachElementToBone(m95a, source, 12, 0,0,0,0,-90,0) 
    setElementData(source,"objectperm",true) 
end 
if getElementData(source,"objectperm") == true then 
setElementAlpha(m95a,255)  
else 
setElementAlpha(m95a,0) 
end 
  

Link to comment
got it how to do it.

Yea, great idea! But... I can't change Alpha of object when I aiming. I'm so stupid. ><

Don't punish yourself, you're just new and I like people who put their efforts in scripting.

This is a client side script

  
function targetingActivated ( target ) 
    if  target  and getElementType (target) == "object" then 
setElementAlpha(target, 0) -- 0 will make it invisible 
    end 
end 
addEventHandler ( "onClientPlayerTarget", getRootElement(), targetingActivated ) 

Can you please explain more what exactly are you trying to do?

Link to comment

I haven't seen your whole code, so I just give you an example so that you can edit it:

local m95a = createObject( 1337, 0, 0, 0) 
attachElements(m95a, localPlayer, 0, 3, 0) 
  
bindKey( "mouse2", "down", function ( ) 
    local slot = getPedWeaponSlot( localPlayer ) 
     
    if slot == 6 then 
        setElementAlpha ( m95a, 0 ) 
    end 
     
end ) 
  
bindKey( "mouse2", "up", function ( ) 
    local slot = getPedWeaponSlot( localPlayer ) 
     
    if slot == 6 then 
        setElementAlpha ( m95a, 255 ) 
    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...