#How can i get he deviceId of a player??

1 messages · Page 1 of 1 (latest)

fading trellis
#

i want to make a ban sytem but want to ban his PC, this is why i need the device id or something like this to ban the player full

fading trellis
#

okay, but

fading trellis
quasi minnow
#

try looking in bsdx or minecraft server-net

fading trellis
#

okay, thank yu

fading trellis
#

every player on the world has a ID?

quasi minnow
fading trellis
#

okay

quasi minnow
#

i know in java you can assign ids

fading trellis
#

Okay

#

ty

quasi minnow
#

here you can look around in this

fading trellis
#

Thank you very much

scarlet peak
#

learn about bedrock protocal

#

and xbox api.

pale moth
quasi minnow
#

i know

quasi minnow
fading trellis
#

ok

#

works?? : const deviceId = player.getDeviceId() ?

cursive cedar
#

I don't know. Do you have the minecraft/server library installed?

sweet spruce
# fading trellis ok

From @minecraft/server
(property) Entity.id: string
Unique identifier of the entity. This identifier is intended to be consistent across loads of a world instance. No meaning should be inferred from the value and structure of this unique identifier - do not parse or interpret it.

@throws — This property can throw when used.

ex.

const id = player.id
#

I don't know this work as IP

fading trellis
#

and the player id is always the same

sweet spruce
fading trellis
#

i mean

#

i have everytime the id 1234 and the second player has 4321

sweet spruce
fading trellis
#

idk

#

i wanted to ask [ has every player a diffrent id and this id forever ]

sweet spruce
#

How about using scoreboard

fading trellis
#

yea

sweet spruce
#

when player join first
set score(id) to player

fading trellis
#

and if the player joins later the id is the same

sweet spruce
#

use rondom()

fading trellis
#

okay

#

random(0, 999999) ?

sweet spruce
#

Javascript random should be a decimal number between 0 and 1

#

I search. wait for minute

fading trellis
#

but can i get the device id to ban the PC

scarlet peak
#

Youll need to learn xbox api and bedrock protocal

fading trellis
#

but can i get the device id to ban the PCbut can i get the device id to ban the PC

scarlet peak
#

you cannot get the device id but you can get the xuid connected with the microsoft account and if a player joins with the same xuid

#

itll automatically kick them

fading trellis
#

but if he joins with a 2acc

scarlet peak
#

theres not really a work around

#

with xbox api i think you can get the device a player is on

#

idk

#

i think you can

fading trellis
#

okay

long garden
#

Using the Xbox API is better than getting the DeviceId because it can be faked

fading trellis
#

okay

#

tyvm

sweet spruce
#

Is this work?

world.events.playerJoin.subscribe((e) => {
  world.sendMessage(e.playerId)
});
#

this id is same? different?

fading trellis
#

this works

sweet spruce
#
const banid = ["id1","id2"]
world.events.playerJoin.subscribe((e) => {
  if (banid.includes(e.playerId)){
    //  that? You can use /kick?
  }
});
#

can we use /kick on script?

fading trellis
#

you cann use player.kick() or player.runCommandAsync('kick "${player.name}"')

sweet spruce
#
const banid = ["id1","id2"]
world.events.playerJoin.subscribe((e) => {
  if (banid.includes(e.playerId)){
    [...overworld.getPlayers({name:e.playerName})].forEach(player=>{
      player.runCommandAsync(`kick "${player.name}"`)
    })
  }
});

is this work? Idk

#

there aren't player.kick in @minecraft/server on my device

fading trellis
#

okay

sweet spruce
#

wait

#

I tryed it but it doesn't work....

#

e.playerID is same....

fading trellis
#

try ( add variables with the player name to a scoreboard banList like: /scoreboard players set "ban: player" banList 1 ) ```

import { world , system } from '@minecraft/server'

system.runInterval((player) => {
for(player in world.getPlayers()){
for(let i in world.scoreboard.getObjective(banList).getParticipants()){
var banned = world.scoreboard.getObjective(banList).getParticipants())[i].displayName
if(player.name.toLowerCase()==banned.toLowerCase)}{
player.runCommandAsync(kick "${player.name}" "§l§cYou have been banned§r")
}
}
}
})

// idk maybe this works

sweet spruce
#

yes but I tryed login differebt account but id is same

fading trellis
#

okay

sweet spruce
#

so I think it

#

you want to IPban?

fading trellis
#

yes

#

but idk how i get the ip or deviceId

sweet spruce
#

simply
scoreboard players name is the same on same account

#

1.create scoreboard [ban list]

#

2.Add the person you want to ban to this scoreboard (value can be anything)

#

3./kick someone added to the scoreboard

fading trellis
#

but

#

Its a player ban. not a Device ban

#

try ( add variables with the player name to a scoreboard banList like: /scoreboard players set "ban: player" banList 1 ) ```

import { world , system } from '@minecraft/server'

system.runInterval((player) => {
for(player in world.getPlayers()){
for(let i in world.scoreboard.getObjective(banList).getParticipants()){
var banned = world.scoreboard.getObjective(banList).getParticipants())[i].displayName
if(player.name.toLowerCase()==banned.toLowerCase)}{
player.runCommandAsync(kick "${player.name}")
}
}
}
})
BTW with this you can test if the player is in a score as variable

sweet spruce
#

same account => same scoreboard
so i thought it work

fading trellis
#

but if i change my name or have a second acc i dpnt get banned

sweet spruce
fading trellis
#

okayy

sweet spruce
fading trellis
#

Okay

sweet spruce
#

(if it doesn't work I'll reconsider)

fading trellis
sweet spruce
#

BAN commands are executed on scripts.
Therefore, I think that people who want to cancel execution should detect it using an if statement and delete the score

fading trellis
#

okay

#

not bad, btw gtg