#player id method
1 messages · Page 1 of 1 (latest)
<@&1201956957406109788>
💬 While you wait, take this time to provide more context and details.
✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve
It is in the message - at least an example is given at the bottom
Player Id System
>>> ## Give each player a unique ID
Create a scoreboard in a load function that runs on /reload
# namespace:load
scoreboard objectives add playerid dummy
Create a function to assign a unique id to the player
# namespace:assign_id
scoreboard players add .global playerid 1
scoreboard players operation @s playerid = .global playerid
Create a tick advancement to assign an id to a player when they first join
{
"criteria": { "requirement": { "trigger": "minecraft:tick" }},
"rewards": { "function": "namespace:assign_id" }
}
Check if an entity has the same ID as the player
Create a predicate that compares the id
// namespace:match_id
{ "condition": "minecraft:entity_scores", "entity": "this", "scores": {
"playerid": {
"min": { "type": "minecraft:score", "target": { "type": "minecraft:fixed", "name": "#this" }, "score": "playerid" },
"max": { "type": "minecraft:score", "target": { "type": "minecraft:fixed", "name": "#this" }, "score": "playerid" }
}}
}
To use it in a function, you can do that following
scoreboard players operation #this playerid = @s playerid
say @e[predicate=namespace:match_id] HAVE THE SAME PLAYERID
I dont get the "scoreboard players operation" like do I change anything or?
Using the operation command, you set the #this fakeplayer to the id of the executing player.
In the predicate you match any entity that has that specific score as their own id
and how do I get the players ID?
? It’s a scoreboard value
If you want to look at it you can scoreboard objectives setdisplay sidebar playerid or scoreboard players get @s playerid
<@&1166082198152159386> <@&1202694677766348840>
Please note that you still might not immediately get a response since all helpers are human beings and volunteers (and also might be sleeping right now)