Jump to content

[REL] pAttach (optimized bone attach)


Patrick

Recommended Posts

  • Moderators
3 minutes ago, cocowen said:

most function is shared

whats the different from using function from client or server , do it same ? or client just work for local player

On client side functions return true or false, depeding on it was successful or not. (For example: attach returns true if objects attached successfully, and false if not)
But on server side (almost) always returns true, even if it failed. (because it returns the result of triggerClientEvent)

Link to comment
12 minutes ago, Patrick said:

On client side functions return true or false, depeding on it was successful or not. (For example: attach returns true if objects attached successfully, and false if not)
But on server side (almost) always returns true, even if it failed. (because it returns the result of triggerClientEvent)

if i set attach from localplayer client , other player will see the attached object ,too?

Link to comment
Just now, Patrick said:

If you attach object on client-side? No, others can't see it, only the client.

ok , i understand ,thanks u

	local object = createObject(371, 0, 0, 0)
	setElementDimension(object,1)
    pAttach:attach(object, element, "backpack", 0, -0.15, 0, 90, 0, 0)

WARNING: pAttach\client.lua:265: Bad argument @ 'isElementOnScreen' [Expected element at argument 1]

i set object to dim 1 , but it keep output this error

Link to comment
  • Moderators
1 hour ago, cocowen said:

ok , i understand ,thanks u


	local object = createObject(371, 0, 0, 0)
	setElementDimension(object,1)
    pAttach:attach(object, element, "backpack", 0, -0.15, 0, 90, 0, 0)

WARNING: pAttach\client.lua:265: Bad argument @ 'isElementOnScreen' [Expected element at argument 1]

i set object to dim 1 , but it keep output this error

I can't reproduce it, can you send me a proper example resource?
... btw the problem is the ped (element), not the 'object'. Where 'element' defined, and is it on server or client side?

Link to comment
  • Moderators
2 minutes ago, cocowen said:

maybe i already find the problem: i destroy the ped ? so let info in table of pattach missed it ?

You have to detach objects first with detachAll. (I'll fix it in next release)

Link to comment
29 minutes ago, Patrick said:

You have to detach objects first with detachAll. (I'll fix it in next release)

yes , another question i trans from boneattach to pattch ,bind a weapon ak on player's right hand , when player hold the ak , its work nice ,but when its aim , the rotation is wrong , but its works find in boneattach , not sure if there is something need to do in pattach , do pattach fit for weapon?

Just now, cocowen said:

yes , another question i trans from boneattach to pattch ,bind a weapon ak on player's right hand , when player hold the ak , its work nice ,but when its aim , the rotation is wrong , but its works find in boneattach , not sure if there is something need to do in pattach , do pattach fit for weapon?

by the way ,i use right-hand , not weapon bone

Link to comment
  • Moderators
Just now, cocowen said:

yes , another question i trans from boneattach to pattch ,bind a weapon ak on player's right hand , when player hold the ak , its work nice ,but when its aim , the rotation is wrong , but its works find in boneattach , not sure if there is something need to do in pattach , do pattach fit for weapon?

pAttach and bone_attach use different parameters (different bone IDs / offsets), you have to reposition them. It isn't enough to just copy/paste them.

For weapons mostly you have to use:

addCommandHandler("testweapon", function(player)
    local object = createObject(356, 0, 0, 0)
    exports.pAttach:attach(object, player, "weapon", 0, 0, 0, 0, 0, 0)
end)

 

Link to comment
Just now, Patrick said:

pAttach and bone_attach use different parameters (different bone IDs / offsets), you have to reposition them. It isn't enough to just copy/paste them.

For weapons mostly you have to use:


addCommandHandler("testweapon", function(player)
    local object = createObject(356, 0, 0, 0)
    exports.pAttach:attach(object, player, "weapon", 0, 0, 0, 0, 0, 0)
end)

 

thanks u weapon bone is work nice , seems there are basic work of this bone

  • Like 1
Link to comment
  • Moderators
Just now, cocowen said:

do not need detachAll anymore? just detach ?

No need detachAll before ped destroying anymore, it does it automatically for you. But test it please, the warning still appears or not?

Link to comment
6 minutes ago, Patrick said:

No need detachAll before ped destroying anymore, it does it automatically for you. But test it please, the warning still appears or not?

tested ,seems no error now ! thanks u 

but need to destroy the object by myself?

Link to comment
  • 3 weeks later...

hey , patrick there is a new question i want to ask , i use  pAttach:attach from serverside 

pAttach:attach(object,targetElement,"weapon", 0, 0, 0, 0, -30, 0)

debug the targetElement as ped

NH_Attach attachWeapon to:elem:ped[100]00012848 object:elem:object[1939]00012849

but the pAttach get Wrong message as 

pAttach\client.lua:38: Expected element at argument 2, got userdata00012848

i debug at serverside attach function in exports.lua , find cache[element][1] become userdata

cache[element][1]:userdata: 0A9BC968

i am really confused , why it have been changed from ped to userdata 

Link to comment
  • Moderators
7 minutes ago, cocowen said:

hey , patrick there is a new question i want to ask , i use  pAttach:attach from serverside 


pAttach:attach(object,targetElement,"weapon", 0, 0, 0, 0, -30, 0)

debug the targetElement as ped


NH_Attach attachWeapon to:elem:ped[100]00012848 object:elem:object[1939]00012849

but the pAttach get Wrong message as 


pAttach\client.lua:38: Expected element at argument 2, got userdata00012848

i debug at serverside attach function in exports.lua , find cache[element][1] become userdata


cache[element][1]:userdata: 0A9BC968

i am really confused , why it have been changed from ped to userdata 

Is ped (targetElement) created on server-side?

Link to comment

function creature:create(skin,x,y,z,r)

    --outputDebugString("TRY CREATE creature ");

    local o = {}
    setmetatable(o,self);
    self.__index = self;
    self.source = createPed(skin,x,y,z,r);
    setElementParent(self.source,otherElements) -- bind to parent for data system
    return o;
end

here is the create part , and used by this

 

function human:create(skin,x,y,z,r,holdweapon,walkingstyle
    local o = creature:create(skin,x,y,z,r)
    self.__index = self;
    setmetatable(o,self);
    local humanped = o:getElement()
     ...
    Attach:attachWeapon(humanped,modelID
     ...
end
function creature:getElement()
    return self.source;
end

 

its really really confused because seems only melee weapon have bug 

seems differents resource use create ped have error ,  create ped  onResourceStart have bug 

i use setTimer to make createped more slowly and its works now ,so confused

Edited by cocowen
Link to comment
  • 3 weeks later...
  • 1 month later...

This script is amazing :D, I had been wanting to create new things for a while but the limitations and bugs of the bone_attach they made it difficult for me.

I just have a question, it's possible to fix this little bug? Objects attached to a skin don't keep the brightness of that skin.  I think it's a MTA limitation but I mention it in case it has a solution.

Pics about the issue:

spacer.png

( The head is a custom object exported with Normals )

spacer.png

Same here, 12:00 PM, the collision surface affect the skin brightness but not the parachute attached

  • Thanks 1
Link to comment
  • Moderators
4 hours ago, Weaita said:

I just have a question, it's possible to fix this little bug? Objects attached to a skin don't keep the brightness of that skin.  I think it's a MTA limitation but I mention it in case it has a solution.

Maybe it is possible somehow to get ped's brightness and modify parachute's with shaders, but I have no idea how could you do it.

Btw do you use the latest pAttach release? Don't you have bugs while attaching objects to player's head? ... I mean wierd movement / rotation offsets

Link to comment
12 hours ago, Patrick said:

Btw do you use the latest pAttach release? Don't you have bugs while attaching objects to player's head? ... I mean wierd movement / rotation offsets

Latest release, no problem at all. Although I only used the script on my local server :)

12 hours ago, Patrick said:

Maybe it is possible somehow to get ped's brightness and modify parachute's with shaders, but I have no idea how could you do it.

It would be great, it's a small problem but in certain situations it causes a lot of annoyance

Link to comment

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