Tycka Posted April 8, 2015 Share Posted April 8, 2015 Here is code: local elementBackpack = {} function helmetAttach (dataName,oldValue) local skin = getElementModel(source) if getElementType(source) == "player" and dataName =="helmetOn" and skin == 73 then local newValue = getElementData(source,dataName) if elementBackpack[source] then detachElementFromBone(elementBackpack[source]) destroyElement(elementBackpack[source]) elementBackpack[source] = false end local x,y,z = getElementPosition(source) local rx,ry,rz = getElementRotation(source) if newValue == 1 then elementBackpack[source] = createObject(902,x,y,z) attachElementToBone(elementBackpack[source],source,1,0.002,-0.055,-0.650,0,0,90) elseif newValue == 0 then return end end end addEventHandler ( "onElementDataChange", getRootElement(), helmetAttach ) local elementBackpack = {} function helmetAttach (dataName,oldValue) local skin = getElementModel(source) if getElementType(source) == "player" and dataName =="helmetOn" and skin == 287 then local newValue = getElementData(source,dataName) if elementBackpack[source] then detachElementFromBone(elementBackpack[source]) destroyElement(elementBackpack[source]) elementBackpack[source] = false end local x,y,z = getElementPosition(source) local rx,ry,rz = getElementRotation(source) if newValue == 1 then elementBackpack[source] = createObject(902,x,y,z) attachElementToBone(elementBackpack[source],source,1,0.002,-0.055,-0.650,0,0,90) elseif newValue == 0 then return end end end addEventHandler ( "onElementDataChange", getRootElement(), helmetAttach ) Is it possible to connect this 2 functions to one? Because when I put helm when I'm with 73 skin, I can't take it off when I with skin 287. Link to comment
#RooTs Posted April 8, 2015 Share Posted April 8, 2015 I made a small organization in your script try this local elementBackpack = {} local x,y,z = getElementPosition(source) local rx,ry,rz = getElementRotation(source) local skin = getElementModel(source) function helmetAttach (dataName,oldValue) if getElementType(source) == "player" and dataName =="helmetOn" and skin == 73 or skin == 287 then local newValue = getElementData(source,dataName) if elementBackpack[source] then detachElementFromBone(elementBackpack[source]) destroyElement(elementBackpack[source]) elementBackpack[source] = false end if newValue == 1 then elementBackpack[source] = createObject(902,x,y,z) attachElementToBone(elementBackpack[source],source,1,0.002,-0.055,-0.650,0,0,90) elseif newValue == 0 then return end end end addEventHandler ( "onElementDataChange", getRootElement(), helmetAttach ) Is it possible to connect this 2 functions to one? Because when I put helm when I'm with 73 skin, I can't take it off when I with skin 287. Link to comment
Tycka Posted April 9, 2015 Author Share Posted April 9, 2015 Don't work I think I can use something like that: if skin == 73 then attachElementToBone(helmet, source, 1, 0, 0.02, -0.53, 0, 0, 90) elseif skin == 287 then attachElementToBone(helmet, source, 1, 0, 0.01, -0.56, 0, 0, 90) elseif skin == 286 then attachElementToBone(helmet, source, 1, 0.015, 0.025, -0.54, 0, 0, 90) But I don't know how to make it. Link to comment
HUNGRY:3 Posted April 10, 2015 Share Posted April 10, 2015 local elementBackpack = {} function helmetAttach (dataName,oldValue) local skin = getElementModel(source) if getElementType(source) == "player" and dataName =="helmetOn" and skin == 73 then local newValue = getElementData(source,dataName) if elementBackpack[source] then detachElementFromBone(elementBackpack[source]) destroyElement(elementBackpack[source]) elementBackpack[source] = false end local x,y,z = getElementPosition(source) local rx,ry,rz = getElementRotation(source) if newValue == 1 then elementBackpack[source] = createObject(902,x,y,z) attachElementToBone(elementBackpack[source],source,1,0.002,-0.055,-0.650,0,0,90) elseif newValue == 0 then return end end end addEventHandler ( "onElementDataChange", getRootElement(), helmetAttach ) or local elementBackpack = {} function helmetAttach (dataName,oldValue) local skin = getElementModel(source) if getElementType(source) == "player" and dataName =="helmetOn" and skin == 287 then local newValue = getElementData(source,dataName) if elementBackpack[source] then detachElementFromBone(elementBackpack[source]) destroyElement(elementBackpack[source]) elementBackpack[source] = false end local x,y,z = getElementPosition(source) local rx,ry,rz = getElementRotation(source) if newValue == 1 then elementBackpack[source] = createObject(902,x,y,z) attachElementToBone(elementBackpack[source],source,1,0.002,-0.055,-0.650,0,0,90) elseif newValue == 0 then return end end end addEventHandler ( "onElementDataChange", getRootElement(), helmetAttach ) 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