Andrew75t Posted August 23, 2020 Posted August 23, 2020 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)
Gordon_G Posted August 25, 2020 Posted August 25, 2020 you could store the attached weapon object in an element data (setElementData) then retrieve this element data client-sidely (getElementData) once the player is aiming and hiding the object with setElementAlpha OR you could not use element datas (cause it has a lot of security issues and lacks of performance) and send the object manually to client side (triggerClientEvent) Gordon#6977
Zorgman Posted August 27, 2020 Posted August 27, 2020 You can get the weapon element using getAttachedElements(player) and filtering the result, then set alpha to 0. https://wiki.multitheftauto.com/wiki/GetAttachedElements Dystopia alpha 0.75DOWNLOAD
Gordon_G Posted August 27, 2020 Posted August 27, 2020 2 hours ago, Zorgman said: You can get the weapon element using getAttachedElements(player) and filtering the result, then set alpha to 0. https://wiki.multitheftauto.com/wiki/GetAttachedElements GetAttachedElements doesn't work with the bone_attach resource since the attached objects aren't attached with attachElements 1 Gordon#6977
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now