Jump to content

Armor Attach problem!


itHyperoX

Recommended Posts

Posted (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 by TheMOG
forgot something
Posted

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
)

 

Posted

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

Posted

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

Posted

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?

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