Jump to content

Armor Attach problem!


itHyperoX

Recommended Posts

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 by TheMOG
forgot something
Link to comment

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
  • 3 weeks later...

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