Skip to content

Getting the Value of Placeholder(s)

APickledWalrus edited this page Jun 22, 2022 · 10 revisions

Basics

If you want to get the value of a placeholder, you can use the parse placeholder expression. This expressions parses placeholders for both PlaceholderAPI and MVdWPlaceholderAPI.

[the] ([value of] placeholder[s]|placeholder [value] [of]) %strings% [(from|of) %-players/offlineplayers%] [(1¦without color)]
parse placeholder[s] %strings% [(for|as) %-players/offlineplayers%] [(1¦without color)]

send "Your Ping: %placeholder ""player_ping"" from player%" # PlaceholderAPI Example
send "Your Ping: %placeholder ""{ping}"" from player%" # MVdWPlaceholderAPI Example

*** NOTICE ***

If you are on newer version of Skript (2.6 and later), you do NOT need to double your quotes within expressions within strings!
For example, if you're on a newer version, you would just do:

send "Your Ping: %placeholder "player_ping" from player%" # PlaceholderAPI Example

*** NOTICE ***

set {_pings::*} to placeholder "player_ping" and "{ping}" from all players 
# You can also get the values of one or more placeholders from multiple players.
# This example would add each player's ping to the list twice.

Placeholders from PlaceholderAPI must be formatted like player_ping or %%player_ping%% (using no ends or using percent signs)

Placeholders from MVdWPlaceholderAPI must be formatted like {ping} (using curly brackets)

Note: If you don't specify the player(s), it will default to the player/executor.

Formatting Entire Strings

Entire strings can be formatted using this expression too. This means that you can replace one or more placeholders in a message, regardless of where they are in the string. Right now, this does not work properly for MVdW placeholders. Hopefully it will be supported in the future.

Here's a snippet of this in practice:

send the value of placeholder "Your seconds lived are %%player_seconds_lived%%. That is AWESOME!" from player to player

If you have any questions, feel free to ask here or in the Skript Chat discord.