#(SpaceSlayer) Flag other players

239 messages · Page 1 of 1 (latest)

surreal girder
#

Hey, How can i give/remove/check flag of another player? I'm trying to use commands but cant figure it out
https://paste.denizenscript.com/View/129475
I scripted this myself so its not the best code ;3

vivid isleBOT
#

(SpaceSlayer) Flag other players

vivid isleBOT
#

Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.

brazen knot
#

You have to convert the argument to a PlayerTag in order to flag it

untold rover
#

!t server.match_player

half masonBOT
untold rover
#

!t server.match_offline_player

half masonBOT
# untold rover !t server.match_offline_player

Returns any player (online or offline) that best matches the input name.
EG, in a group of 'bo', 'bob', and 'bobby'... input 'bob' returns player object for 'bob',
input 'bobb' returns player object for 'bobby', and input 'b' returns player object for 'bo'.
When both an online player and an offline player match the name search, the online player will be returned.

Returns

PlayerTag

untold rover
#

Depending if you want it to work online or both.

brazen knot
#

The way you have the script set up, it’s flagging the arg itself, not the player it represents

#

!c flag

half masonBOT
# brazen knot !c flag
Group

core

Syntax

flag [<object>|...] [<name>([<#>])](:<action>)[:<value>] (expire:<time>)

Short Description

Sets or modifies a flag on any flaggable object.

Description

The flag command sets or modifies custom data values stored on any flaggable object (the server, a player/NPC/entity, a block location, ...).
See also !language flag system.

This command supports data actions, see !language data actions.

Flags by default are added permanently (or for the lifetime of the object they're attached to).
You can optionally specify a system time the flag will expire at, using either a DurationTag or a TimeTag.
If a DurationTag is used, it will be equivalent to: <util.time_now.add[<your_duration_here>]>

brazen knot
#

!objecttype PlayerTag

half masonBOT
# brazen knot !objecttype PlayerTag

A PlayerTag represents a player in the game.

This object type is flaggable.
Flags on this object type will be stored in the file "plugins/Denizen/player_flags/(UUID).dat",
with automatic loading only when the player is online and caching for interacting with offline player flags.

Prefix

p

Base Type

EntityTag

Implements

FlaggableObject

Format

The identity format for players is the UUID of the relevant player.

surreal girder
brazen knot
#

Same way you’re doing now, but replace the “context.args.get” with a PlayerTag

brazen knot
surreal girder
#

so - flag <server.match_player[<name>]> flag123 expire:1m

untold rover
#

!t objecttag.exists

half masonBOT
# untold rover !t objecttag.exists

Returns true if the object exists (is non-null). Returns false if the object doesn't exist, is null, or the tag errored.
This functions as a fallback - meaning, if the tag up to this point errors, that error will be hidden.

Returns

ElementTag(Boolean)

untold rover
#

While it's unlikely to fail, better to be safe.

brazen knot
#

Well yeah,

#

!g don’t trust players

half masonBOT
#
Possible Confusion

Did you mean to search for common mistakes - don't trust players?

surreal girder
# brazen knot Well yeah,

wait i was using
- narrate "<player.flag_expiration[flag123].from_now.formatted>" to check if they have the flag but it doesnt work

brazen knot
#

!t PlayerTag.has_flag

half masonBOT
untold rover
#

If you use <player> tag then it's using the linked player, the person running the command.

surreal girder
brazen knot
#

Double << is always unnecessary, you can just combine the tag together

untold rover
#

has_flag returns a boolean, not a timetag.

brazen knot
#

And the <name> will likely return nothing, as you need something to compare the name too, such as your arguments

#

!g what do tags look like in real usage

half masonBOT
#
Possible Confusion

Did you mean to search for common mistakes - but what if there isn't a tag for the location i want??

surreal girder
#

so - narrate "<server.match_player[<context.args.get[2]>]>.flag_expiration[<flag123>].from_now.formatted>"

brazen knot
#

!g first tags

half masonBOT
brazen knot
#

Right before the “flag_expiration”, just remove that >

untold rover
#

You should also define the targeted player prior.

#

- define target <server.match_player[<context.args.get[2]>]>

So then you can call that definition for other things since you'll need it to check if they have the flag, and then flagging the object.

#

While not necessary, it reduces redundant code.

surreal girder
#

so replace everything with target?

#
- flag target flag123 expire:1m```
untold rover
#

It's a good idea to use a definition, so then you can use it in place of the lengthy match player.

#

That won't work because you're just using the plain text of target.

#

Definitions should be covered in the guide, are you unsure of how to use them?

#

!g how do you use definitions

half masonBOT
#
Possible Confusion

Did you mean to search for what can you do with denizen??

untold rover
#

!g short term memory

half masonBOT
surreal girder
#

ik im stupid, but i defined target as arg 2 while checking for player
then used target to set flag which should set it on that target no?

untold rover
#

Should.

#

!haste

half masonBOT
surreal girder
untold rover
half masonBOT
# untold rover !ds https://paste.denizenscript.com/View/129478
Script Check Results
Script Warnings

On line 17, 49, 58: Invalid tag base target (check !tag ... to find valid tags).
On line 17, 49, 58: Tag tracer: Tag base 'flag123' does not exist.
On line 58: Tag parse error: Invalid tag format, text after closing ']' symbol before '.' symbol

Minor Warnings

On line 20: Stray space after end of line (possible copy/paste mixup. Enable View->Render Whitespace in VS Code).
On line 48, 49, 56, 59, 61: Pointless quotes (arguments quoted but do not contain spaces).

Other Script Information

On line : (Statistics) Total structural lines: 8
On line : (Statistics) Total live code lines: 33
On line : (Statistics) Total comment lines: 4
On line : (Statistics) Total blank lines: 1

Shortened Lines

There are 8 lines that were merged into other lines.

untold rover
#

flag123 is not a valid tag.

#

Remove the tag lines <>

#

Line 58 is wrong.

#

It's not cleanly wrapped.

surreal girder
#

ye forget that

untold rover
#

Line 55 still doesn't use definitions.

surreal girder
#

- flag <[target]> flag123 expire:1m?

#

<[target]> is to call the definition and flag123 is the flag

untold rover
#

That should work.

surreal girder
untold rover
#

Once again.

#

flag123 is not a tag.

#

Just put it in as plain text.

surreal girder
#

nth

#

i removed the <> but no time shows

untold rover
#

Do they have the tag?

#

Flag*?

#

Also

#

!debug

half masonBOT
# untold rover !debug
Info: debug

If you need help with a script issue, one of the most powerful tools Denizen has to offer is full debug output. This is displaying in your console whenever scripts are running until you turn debug off. To share a debug log quickly and easily with helpers, simply run the command /denizen debug -r in-game to begin recording, then run through the part of the script you need help with, then run the command /denizen submit. This will give you a link to a paste of the debug log, which you can then copy/paste back to us!

surreal girder
untold rover
half masonBOT
# untold rover !logcheck https://paste.denizenscript.com/View/129480
Server Version

Paper version 1.21.1-132-b48403b (MC: 1.21.1)

Plugin Version(s)

Citizens: 2.0.35-SNAPSHOT (build 3598) -- (:warning:Outdated build, behind by 61)
Denizen: 1.3.1-SNAPSHOT (build 7081-DEV) -- (:warning:Outdated build, behind by 38)
Depenizen: 2.1.1 (build 865) -- (Outdated build, behind by 2)

Checked For

@untold rover

Online/Offline

Offline, but proxied.

UUID Version

4 (:white_check_mark: Online)

Java Version

21.0.3 :white_check_mark:

Possibly Relevant Plugin(s)

TAB: 5.0.1 - This plugin adds Below_Name scoreboards to NPCs.
ViaVersion: 5.2.0 - Mixed client vs server versions can sometimes cause packet-related issues.
Multiverse-Core: 4.3.1-b861 - Multi-world configuration plugins may affect NPCs in unexpected ways.

Potentially Bad Line(s)

2MinehutCosmetics: 1.0.0, 2MinehutPlugin: 0.0.27-SNAPSHOT, 2BetterJails: 1.5.1, :warning: Free server providers cannot be properly supported. Refer to https://wiki.citizensnpcs.co/Frequently_Asked_Questions#I_have_a_free_server_.28Aternos.2C_Minehut.2C_....29_but_there.27s_problems.

untold rover
#

You're on a unsupported minecraft version.

#

Also

#

Can you

#

Re-paste your script.

#

It's changed since.

surreal girder
untold rover
#

That's not the problem here, but it's something to be aware of.

surreal girder
untold rover
#

Line 49. Target is undefined.

#

You did not define target before this instance.

#

Also line 33, while not necessary you can instead use

#

!t listtag.first

half masonBOT
# untold rover !t listtag.first

Returns the first element in the list.
If the list is empty, returns null instead.
Effectively equivalent to .get[1]
Optionally, specify a number of entries to get, which will return the # first entries, equivalent to .get[1].to[#]

Returns

ObjectTag

Examples
# Narrates "one"
- narrate <list[one|two|three].first>
# Narrates a list of "one" and "two"
- narrate <list[one|two|three].first[2]>
# Narrates a list of "one", "two", and "three"
- narrate <list[one|two|three].first[5]>
# Causes an error, as the list is empty.
- narrate <list.first>
untold rover
#

Also, while you don't need to do this it can be considered better practice to just - stop your script if you're doing a simple if/else, depending on the script.

surreal girder
#

i tried <[char1]> char1 [char1] for good measure, but idk what else to do

#

and i checked ingame with /ex flag 5 is there

untold rover
#

You're submitting the plaintext of char1, which is fine. That's how you usually check for an element.

untold rover
#

Can you debug the script while also narrating the server flag of char1?
/ex narrate <server.flag[char1]>

#

(Also be aware tha we have rules against pinging for help, I don't mind in this case but be aware of that please.)

surreal girder
surreal girder
untold rover
#

Okay so.

#

You're flagging the server with the definition of char1. Which is 5. So you have a server flag of 5 currently.

#

It'll use whatever is inside the definition, not the name of the definition.

surreal girder
#

ye thats correct, i want to flag the server with a number (well in the actual code its a longer number)

#

so i wanted to check if that number already exists, if yes to generate a new one

untold rover
#

Then you'd need to do - flag server char1:<[char1]> if you want to have a server flag of char1 read as 5

#

Otherwise if you do - flag server <[char1]> you're just telling the server to flag the server with 5 as true

surreal girder
#

but wait when i regenerate a new number it says the server already has the flag althought its a new number

untold rover
#

Did you change the script?

surreal girder
untold rover
#

My word.

#

Are you making a UUID?

surreal girder
#

no

#

ye

untold rover
#

!xy

half masonBOT
# untold rover !xy
Info: xy

Your question seems to be an XY Problem - you're asking about your attempted solution rather than your original problem.
Read in detail about the XY Problem here: http://xyproblem.info/

For an example of an XY Problem we've seen in Denizen, the question "how do I make an event for when a flag expires" has no answer, but the same question asked with full background detail will be something more like "I have this script: [LINK HERE], which sets a 3 minute cooldown flag on a player for when they use an ability. I want the player to be notified when the cooldown completes - how do I do this?" which we can then answer quite effectively (in this example, all that was needed was a simple wait command, no events or flag-listening or anything).

untold rover
#

What is this all going to be for in the end?

surreal girder
#

lemme sum up the code, im making a player bank, doing /bank create generates a uique code that only that executor can use

#

using the code the player can do different tasks like deposit, withdraw etc

untold rover
#

That doesn't make sense on why they'd need a special code at all.

surreal girder
#

cuz the player can create accounts with multipel banks

#

and i need a way to seperate each bank

untold rover
#

Different storage at different locations I assume.

surreal girder
#

its mostly virtual

untold rover
#

Yeah I can see something like /bank ironsafe withdraw or /bank goldtown withdraw that makes some sense, but the unique code doesn't make sense to me in this context.

surreal girder
#

thats where the unique code comes in, certain players create a bank ingame, which is added to a list

#

lets say bank owner does /bank create (name) it adds that bank to the list

#

then the player comes in and makes an account with that bank

#

banks are not preset, but made live ingame

#

ive already done that and it works

untold rover
#

Right, you make a bank of say /bank create diamondvillage then what? I don't see how the unique code is needed here.

surreal girder
#

but how do i make the player access their diamondvillage account?

untold rover
#

You mean when they sign up for the bank?

surreal girder
surreal girder
untold rover
#

Okay but where are you adding users to said bank.

surreal girder
#

wym

untold rover
#

Am I misunderstanding something here? Aren't banks suppose to let other players deposit and take items, and not the bank owner?

#

Or is this basically just a virtual stash for every player to create for themself?

surreal girder
#

ye but the bank owner creates the bank i.e puts it in the system so when other players do /bank list and click on their bank it makes an account for them

#

i made the code where u can add a bank to the system but cant figure out how to let players create an account

untold rover
#

I wonder what the advantage of the bank owner has versus just a npc. Huh. That aside..

#

You don't need to generate a number.

#

Just use the players uuid as a identifier.

#

!t playertag.uuid

half masonBOT
surreal girder
#

wdym advantage?

untold rover
#

With the uuid you can use that as an identifier to check whatever is necessary.
- flag server banks.super_custom_bank.accounts.<player.uuid>.cash:0
And whatnot.

#

Also.

#

Line 56. I see you stopping the script but then doing the if/else anyways. There's no need to have the else check if you're doing a stop prior during an if check. It'd be different if you had multiple else if checks.

#
- if !<player.has_flag[my_flag]>:
  - stop
- narrate "They have the flag"
#

It prevents nesting.

surreal girder
#

so add <player.uuid>.cash:0 to this
- flag server bankssaveddata:->:<list[<server.flag[bankname]>|<server.flag[bankowner]>|<server.flag[legalentity]>]>

#

- flag server bankssaveddata:->:<list[<server.flag[bankname]>|<server.flag[bankowner]>|<server.flag[legalentity]>].<player.uuid>.cash:0>

untold rover
#

No. That will not work at all.

#

Why are you using a list?

surreal girder
#

to save the name of the bank, owner and legal entity so it shwos up in the gui

untold rover
#

That makes sense, but why are you using a list and not a map?

surreal girder
#

no clue honestly

untold rover
#

I'm trying to find the lang page on submapping, it's somewhere..

#

!c define

half masonBOT
# untold rover !c define
Group

queue

Syntax

define [<id>](:<action>)[:<value>]

Short Description

Creates a temporary variable inside a script queue.

Description

Definitions are queue-level 'variables' that can be used throughout a script, once defined, by using the <[<id>]> tag.
Definitions are only valid on the current queue and are not transferred to any new queues constructed within the script,
such as by a 'run' command, without explicitly specifying to do so.

Definitions are lighter and faster than creating a temporary flag.
Definitions are also automatically removed when the queue is completed, so there is no worry for leaving unused data hanging...

untold rover
#

Define has examples of how submapping works.

#

This is also supported via flags.

#

Did you notice what I did with my flag example earlier?

untold rover
#

- flag server my_flag.a_custom_key.<player.uuid>:100
This would flag the server with different keys, with the player uuid being the final key with a value of 100.

You would be able to pull up information the same way with narrate.
- narrate <server.flag[my_flag.a_custom_key.<player.uuid> and that should read 100.
- narrate <server.flag[my_flag.a_custom_key]> will show you the maptag with the players uuid being a key and 100 being it's value, and any other entries if they exist

#

Ah, good catch.

#

This is practically necessary for a deep information system like what you're doing.

#

When making your bank I'd suggest constructing the map before flagging the server.

#

!c definemap

half masonBOT
untold rover
#

While you can individually flag each and every value, it's not recommended unless necessary. Case by case basis. In this case it seems unnecessary because you're already trying to define four values. Owner. Entity, and some other stuff.

surreal girder
#

ok so instead of the whole list i make it unique to the executor's uuid (which is the bank owner)

#

and customkey is the bank name?

untold rover
#

Wouldn't you want the bank name to be the unique ID for the bank? It'd be a pain go to through all of those uuids as the very first key for the banks, and then read the bank name to the player on a code level.

#

I mean you can do it sure, I just think it's more work.

surreal girder
#

wait then im confused
- flag server my_flag.a_custom_key.<player.uuid>:100 if i put this in the script it will flag the server with the bank owner's uuid and i can use their uuid to make accounts?

#

or custom key is the code to the personal accounts?

untold rover
#

That will flag the server with the key my_flag with subkeys of a_custom_key.<player_uuid>
Besides the player uuid, the rest is just plaintext. It's an example.

#

Obviously you can make it much deeper.

#

So if you wanted to you could end up doing - flag server banks.piglin_town.accounts.<player_uuid>:0

So piglin_town now has a subkey of accounts which has one account, and is using the players uuid of whoever was running the command to make that.

#

It's all examples, how you want to read the information is up to you. Is the bank only for cash? Is it for items too? You'll have to consider where to slot in the owner information. Something like banks.piglin_town.owner:<player> and such.

surreal girder
#

ye its money only

untold rover
#

Also be aware that I'm not sure if the banks name is gonna be more than one word, things get a little dicier if you make the banks name with spaces and also a key. You're generally not suppose to have spaces in keys when making maps.

#

But you're only getting the second argument and not everything afterwards, so it's fine.

#

( Alternatively, you could let the bank owner change the 'display name' of the bank, making it read differently to whoever is accessing the bank. Making it look nicer than just something like my_perfect_bank )

surreal girder
#

there wont be spaces

#

unless i somehow read multipel args

untold rover
#

You're only getting the second argument in your context args when making a bank, it's fine as is. Or should be.

#

Also.

#

Something I've noticed.

#

You're doing a lot of repeating prefixes for narration.

#

<&color[#3d85c6]>CB of Suncrest <gray>|

#

You don't have to do this.

#

!l format script container

half masonBOT
# untold rover !l format script container

Format script containers are very simple script containers used for formatting messages, usually with the 'narrate' command.


Format_Script_Name:

    type: format

    # The only key is the format. The format can use '<[text]>' as a special def to contain the message being sent.
    # '<[name]>' is available as a special def as well for use with the 'on player chats' event to fill the player's name properly.
    # Note that 'special' means special: these tags behave a little funny in certain circumstances.
    # In particular, these can't be used as real tags in some cases, including for example when using a format script as a determine in the 'player chats' event.
    # | All format scripts MUST have this key!
    format: <[name]> says <[text]>

Group

Script Container System

untold rover
#

!c narrate

half masonBOT
# untold rover !c narrate
Group

player

Syntax

narrate [<text>] (targets:<player>|...) (format:<script>) (per_player) (from:<uuid>)

Short Description

Shows some text to the player.

Description

Prints some text into the target's chat area. If no target is specified it will default to the attached player or the console.

Accepts the 'format:<script>' argument, which will reformat the text according to the specified format script. See !language Format Script Containers.

Optionally use 'per_player' with a list of player targets, to have the tags in the text input be reparsed for each and every player.
So, for example, "- narrate 'hello <player.name>' targets:<server.online_players...

untold rover
#

Narrate can take format scripts.

#

So you can shave off some repeated effort.

#

Although I recommend testing it to be double sure.

surreal girder
#

ok ill get to that later ty

#

to compile the steps

#

Step 1: - flag server banks.piglin_town.accounts.<player_uuid>:0 which creates the bank

#

it creates a bank under the owner's uuid

untold rover
#

It creates the bank under the id of plglin_town, and adds the account of whoever the linked player is with a balance of 0

#

No owner is specified for the bank there.

surreal girder
#

do i replace piglin_town with the banks name?

random remnantBOT
untold rover
#

Yes. It was an example.

surreal girder
#

ok thats how i get the bank in the system

#

lets say i ditch the uuid thing

#

- flag server banks.<context.args.get[#]>.accounts to get the banks name

#

and put it as a subkey to the accounts

#

that should work right?

untold rover
#

Yeah, that'll just make accounts as true Consider setting the value to <map>
- flag server banks.hometown.accounts:<map>

#

Also I think you oopsied the 3

surreal girder
#

wdym

#

opposied 👀

untold rover
#

You did context.args.get[#]

#

Did you mean to put 3?

surreal girder
#

ye

#

wait its arg 2

#

i gtg i give up for today, tysm for ur help <3

true vesselBOT
#
Thread Closing Reminder

Has your issue been resolved, or your question been answered?
If so, please use the </resolved:1028673926114594866> command to close your thread.
Or </invalid:1028673926898909185> if it's not possible to resolve.

If not yet resolved, please reply below to tell us what you still need.

(Note that if there is no reply for a few days, this thread will eventually close itself.)

#

@surreal girder