StileDevs / GrowServer

A Growtopia private server using NodeJS
MIT License
50 stars 28 forks source link

How can I lock items like Dgate, Portcullis? #12

Closed nob345 closed 3 months ago

nob345 commented 7 months ago

Problems

Place.ts

Player.ts

GatewayEnd.ts

Information

JadlionHD commented 7 months ago

SWITCHEROO

you need to handle onDamage method so when if a player punches dgate it will change the value of the toggleable. example:

// boolean
block.toggleable.open = !block.toggleable.open;
Place.tileUpdate(this.base, this.peer, itemMeta?.type || 0, block, this.world);

Tile Flags

to be able player & other player see if the dgate are open/closed, you need to set the flags of the block to these flags Flags

case ActionTypes.SWITCHEROO: {
  let flag = 0x0;
  buf = Buffer.alloc(8);

  if (block.toggleable?.open) flag |= Flags.FLAGS_OPEN; // if the block was closed then dont give FLAGS_LOCKED since its for door only.
  if (block.toggleable?.openToPublic) flags |= Flags.FLAGS_PUBLIC;

  buf.writeUInt32LE(block.fg | (block.bg << 16));
  buf.writeUint16LE(lockPos, 4);
  buf.writeUint16LE(flag, 6);
  break;
}

also for FLAGS_PUBLIC I'll assuming that player no access might be able to punch it, maybe TIAS.

nob345 commented 7 months ago

I don't fully understand how to do this and I feel like an idiot. Can you please help me if you are not busy? I added your code under the SEED action in the onPunch event and it didn't work. Normally I am more resourceful .d

JadlionHD commented 3 months ago

added https://github.com/JadlionHD/GrowServer/commit/85402ec2bd623a5f162db16b4ca9e57e7a8105aa