Jump to content

2 Screenshots

About This File

Most of the server developers (ones that don't patiently wait for *something large*, though this resource is powerful enough) use their own server-side object attachments implementation that represents some large JSON with all the object and attachment information. This resource lets you cache "static attachments" in the client-side code so thanks to efficient utilization of the shared data it just uses a small shared variable to do the attachment processing without any need to create server-side objects nor send its data.

 

For example, if you want to attach a specific object to specific ped bone with spefic bone offset and object rotation, this will only use a ~4-8 byte shared variable keeping it accurate. User-made implementations I have seen before usually take ~100 bytes per an object.

 

API: Client-side

  • mp.attachmentMngr.register(attachmentId, model, bone, offset, rotation)
  • mp.attachmentMngr.addLocal(attachmentId) (synced!)
  • mp.attachmentMngr.removeLocal(attachmentId) (synced!)

 

API: Server-side

  • player.addAttachment(attachmentId, remove)
  • player.hasAttachment(attachmentId)

 

Example Resource

There's an example resource in /client-packages/epic-attachments folder. It lets you toggle attachments (there are like 30 attachments) using a NativeUI-based menu. Thanks to root for his contributions made to the example resource.

 

 

 


What's New in Version 1.0.4   See changelog

Released

Bug fix

  • Like 11

User Feedback

Create an account or sign in to leave a review

You need to be a member in order to leave a review

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

Henning222

· Edited by Henning222

   3 of 3 members found this review helpful 3 / 3 members

Important!

With Ragemp 1.1 you need to make a Timeout before attaching the Item!!!

1.The setTimeout is added from me but its not in the version you can download (1.04). 

2. For Ragemp 1.1 you need to use the code from rootcause, you can find in the comment section of this ressource.

3, After you implemented rootcause code: 

entityStreamIn

is not triggered so you need to use a invervall to make it work.

 

Zitat
	setTimeout(function () {
object.attachTo(entity.handle,
					(typeof(attInfo.boneName) === 'string') ? entity.getBoneIndexByName(attInfo.boneName) : entity.getBoneIndex(attInfo.boneName),
					attInfo.offset.x, attInfo.offset.y, attInfo.offset.z, 
					attInfo.rotation.x, attInfo.rotation.y, attInfo.rotation.z, 
					false, false, false, false, 2, true);

				entity.__attachmentObjects[id] = object;
				}, 500);

 

 

 

Zitat
Zitat
setInterval(checkForStreamInTe, 1000);

function checkForStreamInTe(){
   mp.objects.forEach((object) => {
      if (object.handle) {
         checkForStreamIn(object);
      }
      else {
         checkForStreamOut(object);
      }
   });
}

function checkForStreamIn(object) {
   if (!mp.objects.exists(object)) return;
   if(object.isInStreamRange)return;
   object.isInStreamRange = true;
   mp.events.call('entityStreamIn', object);
}

function checkForStreamOut(object) {
   if (!object.isInStreamRange) return;
   object.isInStreamRange = false;
   mp.events.call('entityStreamOut', object);
}

 

 

Original

· Edited by Original

   4 of 5 members found this review helpful 4 / 5 members

C# when to make it more ok? 

rootcause

   4 of 8 members found this review helpful 4 / 8 members

it's ok

n0minal

· Edited by n0minal

   1 of 2 members found this review helpful 1 / 2 members

Awesome resource, I'll use it on my server.

JamesBeast

   1 of 3 members found this review helpful 1 / 3 members

it's epic

Dimitri Stupakis

· Edited by Dimitri Stupakis

   0 of 2 members found this review helpful 0 / 2 members

Is there a way not only to add/remove an attachment but also just drop the attachment? like pickup a barrel, carry it to another point and drop it there.

Great work by the way!

 

Sethan

   0 of 2 members found this review helpful 0 / 2 members

Great resource, thanks

Jengas

   0 of 2 members found this review helpful 0 / 2 members

Best!

Morbo

   0 of 2 members found this review helpful 0 / 2 members

Thx

hubba

   0 of 2 members found this review helpful 0 / 2 members

it's ok

kemperrr

   0 of 2 members found this review helpful 0 / 2 members

It's ok

pualtabita

  

Is there a list of attatchments?

 

×
×
  • Create New...