Fist Posted November 27, 2017 Share Posted November 27, 2017 (edited) Can anyone help me with bone_attach throwing out this error, and sometimes it unattaches every element from player and freezes in mid air and stays there for small amount of time and then attaches back to its player. ERROR: bone_attach\attach_func.lua:113: cannot resume dead coroutine [string "?"] attPed = {}; attBone = {}; attX = {}; attY = {}; attZ = {}; attRX = {}; attRY = {}; attRZ = {}; function attachElementToBone(element, ped, bone, x, y, z, rx, ry, rz) if (not isElement(element) and isElement(ped)) then return false; end if (getElementType(ped) ~= "ped" and getElementType(ped) ~= "player") then return false; end local bone = tonumber(bone); if (not bone or bone < 1 or bone > 20) then return false; end local x,y,z,rx,ry,rz = tonumber(x) or 0,tonumber(y) or 0,tonumber(z) or 0,tonumber(rx) or 0,tonumber(ry) or 0,tonumber(rz) or 0; attPed[element] = ped; attBone[element] = bone; attX[element] = x; attY[element] = y; attZ[element] = z; attRX[element] = rx; attRY[element] = ry; attRZ[element] = rz; if setElementCollisionsEnabled then setElementCollisionsEnabled(element, false); end if script_serverside then triggerClientEvent("boneAttach_attach", root, element, ped, bone, x, y, z, rx, ry, rz); end return true; end function detachElementFromBone(element) if (not element) then return false; end if (not attPed[element]) then return false; end clearAttachmentData(element); if setElementCollisionsEnabled then setElementCollisionsEnabled(element, true); end if (script_serverside) then triggerClientEvent("boneAttach_detach", root, element); end return true; end function isElementAttachedToBone(element) if (not element) then return false; end return isElement(attPed[element]); end function getElementBoneAttachmentDetails(element) if not isElementAttachedToBone(element) then return false; end return attPed[element], attBone[element], attX[element], attY[element], attZ[element], attRX[element], attRY[element], attRZ[element]; end function setElementBonePositionOffset(element,x,y,z) local ped,bone,ox,oy,oz,rx,ry,rz = getElementBoneAttachmentDetails(element); if (not ped) then return false; end return attachElementToBone(element, ped, bone, x, y, z, rx, ry, rz); end function setElementBoneRotationOffset(element,rx,ry,rz) local ped,bone,x,y,z,ox,oy,oz = getElementBoneAttachmentDetails(element); if (not ped) then return false; end return attachElementToBone(element, ped, bone, x, y, z, rx, ry, rz); end if (not script_serverside) then function getBonePositionAndRotation(ped, bone) local bone = tonumber(bone); if (not bone or bone < 1 or bone > 20) then return false; end if (not isElement(ped)) then return false; end if (getElementType(ped) ~= "player" and getElementType(ped) ~= "ped") then return false; end if (not isElementStreamedIn(ped)) then return false; end local x,y,z = getPedBonePosition(ped, bone_0[bone]); local rx,ry,rz = getEulerAnglesFromMatrix(getBoneMatrix(ped, bone)); return x,y,z,rx,ry,rz; end end function clearAttachmentData(element) attPed[element] = nil; attBone[element] = nil; attX[element] = nil; attY[element] = nil; attZ[element] = nil; attRX[element] = nil; attRY[element] = nil; attRZ[element] = nil; end addEventHandler(script_serverside and "onElementDestroy" or "onClientElementDestroy", root, function() if (not attPed[source]) then return; end clearAttachmentData(source); end); function forgetNonExistingPeds() local checkedcount = 0; while true do for i,v in pairs(attPed) do if not isElement(v) then clearAttachmentData(i); end checkedcount = checkedcount + 1; if (checkedcount >= 1000) then coroutine.yield(); checkedcount = 0; end end coroutine.yield(); end end clearing_nonexisting_peds = coroutine.create(forgetNonExistingPeds); setTimer(function() coroutine.resume(clearing_nonexisting_peds) end, 1000, 0); Edited November 27, 2017 by Fist Link to comment
Moderators IIYAMA Posted November 27, 2017 Moderators Share Posted November 27, 2017 I help you over ~2 hours(no time), if you haven't got the awnser yet. 1 Link to comment
Moderators IIYAMA Posted November 27, 2017 Moderators Share Posted November 27, 2017 local clearing_nonexisting_peds = coroutine.create(forgetNonExistingPeds); setTimer(function() if coroutine.status (clearing_nonexisting_peds) == "dead" then clearing_nonexisting_peds = coroutine.create(forgetNonExistingPeds); end coroutine.resume(clearing_nonexisting_peds) end, 1000, 0); Replace line 112 and 113. It should recreate the coroutine when it is dead. 1 Link to comment
Fist Posted November 27, 2017 Author Share Posted November 27, 2017 5 minutes ago, IIYAMA said: local clearing_nonexisting_peds = coroutine.create(forgetNonExistingPeds); setTimer(function() if coroutine.status (clearing_nonexisting_peds) == "dead" then clearing_nonexisting_peds = coroutine.create(forgetNonExistingPeds); end coroutine.resume(clearing_nonexisting_peds) end, 1000, 0); Replace line 112 and 113. It should recreate the coroutine when it is dead. ty man, can't tell you if it works tho, 'cause you can't really tell it instantly. Will put it on server and will see how it goes. 1 Link to comment
Fist Posted November 27, 2017 Author Share Posted November 27, 2017 2 hours ago, IIYAMA said: local clearing_nonexisting_peds = coroutine.create(forgetNonExistingPeds); setTimer(function() if coroutine.status (clearing_nonexisting_peds) == "dead" then clearing_nonexisting_peds = coroutine.create(forgetNonExistingPeds); end coroutine.resume(clearing_nonexisting_peds) end, 1000, 0); Replace line 112 and 113. It should recreate the coroutine when it is dead. there is no errors indeed and works well, but still attached bones sometimes unattaches and stays in mid air for some time and then attaches back to player. Link to comment
Moderators IIYAMA Posted November 27, 2017 Moderators Share Posted November 27, 2017 I don't know what that problem is. I don't think it is in here, more inside of the render core. Might be a gta bug or a bug in the script which hasn't been found out. The only way to find it, is to hard core debug it. Link to comment
Fist Posted November 27, 2017 Author Share Posted November 27, 2017 19 minutes ago, IIYAMA said: I don't know what that problem is. I don't think it is in here, more inside of the render core. Might be a gta bug or a bug in the script which hasn't been found out. The only way to find it, is to hard core debug it. how i could do that without like adding iprint everywhere on the script? Link to comment
Moderators IIYAMA Posted November 27, 2017 Moderators Share Posted November 27, 2017 You can't. Link to comment
Fist Posted November 27, 2017 Author Share Posted November 27, 2017 3 minutes ago, IIYAMA said: You can't. couldn't it be because timer for resuming that coroutine is each second? Link to comment
Moderators IIYAMA Posted November 27, 2017 Moderators Share Posted November 27, 2017 12 minutes ago, Fist said: couldn't it be because timer for resuming that coroutine is each second? I don't think so, because the timer is used to destroy elements, when the ped/player element is destroyed/(leaves the server). But you can test it if you want to be 100% sure. Just increase the timer duration to 50 ms and see if the delay still exist. (don't forget to change back, because 50 ms can lagg) Link to comment
Fist Posted November 27, 2017 Author Share Posted November 27, 2017 (edited) 8 minutes ago, IIYAMA said: I don't think so, because the timer is used to destroy elements, when the ped/player element is destroyed/(leaves the server). But you can test it if you want to be 100% sure. Just increase the timer duration to 50 ms and see if the delay still exist. (don't forget to change back, because 50 ms can lagg) well if it just does that then it explains why fixing that didn't help. I could try removing and adding attachments to players like every second but idk how that would work, i guess i can try and we'll see how it looks. Edited November 27, 2017 by Fist Link to comment
Moderators IIYAMA Posted November 27, 2017 Moderators Share Posted November 27, 2017 True But fixing a warning/error = less lagg. It always helps in a way. 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