Jump to content

How do I make an object transparent?


Recommended Posts

I have a script-chec

k, if the player has a sniper rifle in his hands and he is aiming, then a message is displayed in the chat.
In the sight I see the model of the object (id 321) that I replaced and attached using bone_attach. I want it to become transparent in aiming mode. How do I apply setElementAlpha to this object?

I made a transparent texture for the default rifle (id 34). And with the help of bone_attach, I attached the object (id 321), which I replaced with the new SVD model. When I am in aiming mode I see the SVD model, I need to make it transparent (invisible)

Client side:

function aimAction (key, state)
    if (getPedWeapon (localPlayer) ~= 34) then return end
	
    outputChatBox ("You are aiming now", 255, 0, 0)                  
    for control in pairs (getBoundControls(key)) do
        setPedControlState (control, false)
    end
end
bindKey ("mouse2", "down", aimAction)

Server side:

function attachSVD (thePlayer)
    local x, y, z = getElementPosition (thePlayer)
    local objPick = createObject (321, x, y, z)
    setTimer (function (thePlayer)
	giveWeapon ( thePlayer, 34, 200, true )
        exports.bone_attach:attachElementToBone (objPick, thePlayer, 12, 0, 0, 0, 0, -90, 0)
    end, 1000, 1, thePlayer)
end
addCommandHandler ("svd", attachSVD)

Repale models:

function replaceWeapon() -- Invisible defolt sniper riflle
txd = engineLoadTXD ( "mdls/weapons/sniper_rifle/sniper.txd" )
engineImportTXD ( txd, 358)
-- SVD model --
txd = engineLoadTXD ( "mdls/weapons/sniper_rifle/svd.txd" )
engineImportTXD ( txd, 321)
dff = engineLoadDFF ( "mdls/weapons/sniper_rifle/svd.dff")
engineReplaceModel ( dff, 321) 
end
addEventHandler ( "onClientResourceStart", resourceRoot, replaceWeapon)

 

Link to post

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