itHyperoX Posted January 4, 2017 Share Posted January 4, 2017 (edited) Hi, i maded a script, when player have armor, object attaching to player.. Everything work, but i added NOT a same position for skins... Server Side: local object = {} addEvent("player:attach", true) addEventHandler("player:attach", root, function(source) local theobject = createObject(1242, 0,0,0) local skin = getElementModel(source) setObjectScale(theobject, 1.85) if (skin) == 310 then exports.bone_attach:attachElementToBone(theobject, source, 3, 0 , 0.035, 0.025, 0, 0, 0) object[source] = theobject elseif (skin) == 300 then exports.bone_attach:attachElementToBone(theobject, source, 3, 0 , 0.80, 0.025, 0, 0, 0) object[source] = theobject elseif (skin) == 250 then exports.bone_attach:attachElementToBone(theobject, source, 3, 0 , 0.80, 0.50, 0, 0, 0) object[source] = theobject end end ) addEvent("player:deattach", true) addEventHandler("player:deattach", root, function(e) exports.bone_attach:detachElementFromBone(object[e]) if isElement(object[e]) then destroyElement(object[e]) end end ) addEventHandler("onPlayerQuit", root, function() if object[e] and isElement(object[e]) then exports.bone_attach:detachElementFromBone(object[e]) if isElement(object[e]) then destroyElement(object[e]) end object[e] = nil end end ) Client Side: local armor = {} armor["created"] = false setTimer( function() local aLevel = getPedArmor(localPlayer) if aLevel > 0 then if not armor["created"] then triggerServerEvent("player:attach", root, localPlayer) armor["created"] = true end else if armor["created"] then triggerServerEvent("player:deattach", root, localPlayer) armor["created"] = false end end end, 500, 0 ) The problem is not changing the object position, when player changing the skin. But when i restart the resource, the position changig. Whats the problem? Edited January 4, 2017 by TheMOG forgot something Link to comment
^iiEcoo'x_) Posted January 4, 2017 Share Posted January 4, 2017 I am not aware enough ... but I expect that the problem of this elseif this else replace it in the following lines 14 17 Link to comment
itHyperoX Posted January 4, 2017 Author Share Posted January 4, 2017 @#_iMr,[E]coo I tried, nothing in debug Link to comment
^iiEcoo'x_) Posted January 4, 2017 Share Posted January 4, 2017 I think I know what the problem is local object = {} addEvent("player:attach", true) addEventHandler("player:attach", root, function(source) local theobject = createObject(1242, 0,0,0) local theobject2 = createObject(1242, 0,0,0) local theobject3 = createObject(1242, 0,0,0) local skin = getElementModel(source) setObjectScale(theobject, 1.85) setObjectScale(theobject2, 1.85) setObjectScale(theobject3, 1.85) if (skin) == 310 then exports.bone_attach:attachElementToBone(theobject, source, 3, 0 , 0.035, 0.025, 0, 0, 0) object[source] = theobject elseif (skin) == 300 then exports.bone_attach:attachElementToBone(theobject2, source, 3, 0 , 0.80, 0.025, 0, 0, 0) object[source] = theobject2 elseif (skin) == 250 then exports.bone_attach:attachElementToBone(theobject3, source, 3, 0 , 0.80, 0.50, 0, 0, 0) object[source] = theobject3 end end ) addEvent("player:deattach", true) addEventHandler("player:deattach", root, function(e) exports.bone_attach:detachElementFromBone(object[e]) if isElement(object[e]) then destroyElement(object[e]) end end ) addEventHandler("onPlayerQuit", root, function() if object[e] and isElement(object[e]) then exports.bone_attach:detachElementFromBone(object[e]) if isElement(object[e]) then destroyElement(object[e]) end object[e] = nil end end ) Link to comment
itHyperoX Posted January 4, 2017 Author Share Posted January 4, 2017 Nah mate not working. I think the problem is in client side, but i dont know where. Link to comment
itHyperoX Posted January 5, 2017 Author Share Posted January 5, 2017 Anyone can help me? Link to comment
^iiEcoo'x_) Posted January 5, 2017 Share Posted January 5, 2017 Do check out the player puts the first object and the second in the third personal deletes the first object and the second and third placed object, and so on In the code that you previously gave you him Link to comment
itHyperoX Posted January 5, 2017 Author Share Posted January 5, 2017 @iPrestege boss can u help me please? Link to comment
^iiEcoo'x_) Posted January 5, 2017 Share Posted January 5, 2017 11 minutes ago, TheMOG said: @iPrestege boss can u help me please? I'm Link to comment
itHyperoX Posted January 5, 2017 Author Share Posted January 5, 2017 @#_iMr,[E]coo not working 1 Link to comment
MR.GRAND Posted January 6, 2017 Share Posted January 6, 2017 Hi bro, You need to edit object scale for be correct with that skins After that edit x, y, z for that object in attach function, So after do all that you will put it in the correct position .Good Luck brother . Link to comment
Syntrax# Posted January 6, 2017 Share Posted January 6, 2017 https://wiki.multitheftauto.com/wiki/GetPedBonePosition Use this to get the torso, attach the armor, done.Why using the bone_attach script when mta does have it by itself Link to comment
itHyperoX Posted January 6, 2017 Author Share Posted January 6, 2017 if you dont know what is the script do, please don't write here. Link to comment
pa3ck Posted January 8, 2017 Share Posted January 8, 2017 Your if statement is not inside a loop or any sort of event that would be called when the skin changed. You'll need to detach - get current skin - attach when the skin is changed, how are you changing skins? Command, GUI? Link to comment
itHyperoX Posted January 8, 2017 Author Share Posted January 8, 2017 yes command dude. 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