NoName74 Posted March 20, 2014 Share Posted March 20, 2014 On the server-side I create the object. I need to hide it from the player(client) on the client side. How? I'm confused. Link to comment
NoName74 Posted March 20, 2014 Author Share Posted March 20, 2014 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
Saml1er Posted March 20, 2014 Share Posted March 20, 2014 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
NoName74 Posted March 20, 2014 Author Share Posted March 20, 2014 Ow, why don't you create it in client side then and set its alpha to 0? This object should see all the players, including the client-player, to which is attached the object. I need to hide the object when the client-player is aiming. That's because object prevents aim. .-. http://i.imgur.com/mlEtLK1.png Link to comment
Anubhav Posted March 20, 2014 Share Posted March 20, 2014 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 Link to comment
NoName74 Posted March 20, 2014 Author Share Posted March 20, 2014 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
Anubhav Posted March 20, 2014 Share Posted March 20, 2014 (edited) 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 March 20, 2014 by Guest Link to comment
Anubhav Posted March 20, 2014 Share Posted March 20, 2014 (edited) 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 March 20, 2014 by Guest Link to comment
Anubhav Posted March 20, 2014 Share Posted March 20, 2014 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
Anubhav Posted March 20, 2014 Share Posted March 20, 2014 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
NoName74 Posted March 20, 2014 Author Share Posted March 20, 2014 got it how to do it. Yea, great idea! But... I can't change Alpha of object when I aiming. I'm so stupid. >< Link to comment
Saml1er Posted March 20, 2014 Share Posted March 20, 2014 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
NoName74 Posted March 20, 2014 Author Share Posted March 20, 2014 Can you please explain more what exactly are you trying to do? http://i.imgur.com/DcWG10K.png - I attach object to player. This object prevents me to aim. I want hide this object from myself when I aiming. The other players must continue to see this object. EDIT: Maybe I should use it? getAttachedElements Link to comment
pa3ck Posted March 20, 2014 Share Posted March 20, 2014 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
NoName74 Posted March 20, 2014 Author Share Posted March 20, 2014 Damn. I just replace triggerClientEvent (source, "hiderweap", m95a) with triggerClientEvent (source, "hiderweap", source, m95a) and now I can change Alpha of object m95a in client-side. .-. Thanks all for answers. You'e the best. ^^, Link to comment
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