#How can i get he deviceId of a player??
1 messages · Page 1 of 1 (latest)
I don't think that is possible
okay, but
i want to ban the pc like IP ban.. is this possible
try looking in bsdx or minecraft server-net
okay, thank yu
one last question
every player on the world has a ID?
for java yes, for bedrock maybe,
okay
i know in java you can assign ids
Thank you very much
server-net can only request information I wonder what you would get if you did a http request to the server
i know
it could make a request to whats my ip address.com
I don't know. Do you have the minecraft/server library installed?
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
and the player id is always the same
even different people?
I know that. But does this mean it can't be used?
How about using scoreboard
yea
when player join first
set score(id) to player
and if the player joins later the id is the same
use rondom()
Javascript random should be a decimal number between 0 and 1
I search. wait for minute
but can i get the device id to ban the PC
Youll need to learn xbox api and bedrock protocal
but can i get the device id to ban the PCbut can i get the device id to ban the PC
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
but if he joins with a 2acc
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
okay
Using the Xbox API is better than getting the DeviceId because it can be faked
Is this work?
world.events.playerJoin.subscribe((e) => {
world.sendMessage(e.playerId)
});
this id is same? different?
this works
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?
you cann use player.kick() or player.runCommandAsync('kick "${player.name}"')
but
(e) is [playerjoinevent]
not [player]
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
okay
if you use e.id.. the id isnt 1 or 2, its something like -32833ß3
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
yes but I tryed login differebt account but id is same
okay
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
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
same account => same scoreboard
so i thought it work
but if i change my name or have a second acc i dpnt get banned
I changed playername(offline name maybe it also work online name[xbox?switch?]) but scoreboard is same
ex.
i tryed add scoreboard and relogin after change name
before change(it is scoreboard....)
BANLIST
hacker 0
After change
BANLIST
not hacker 0
okayy
I recommend checking it out in multiplayer.
Okay
(if it doesn't work I'll reconsider)
btw how do you want to unban him
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