Violet

Party

On this page

Read your current party and act on it: list members, create or leave a party, invite / kick / promote by name, apply to a listed party, and respond to incoming invites.

Not in a party

When you're not in a party, is_in_party() returns false, get_party_id() returns 0, get_party_name() returns "", get_members() returns an empty table, and the member actions (leave / kick / promote) return false.

Party Member Structure

get_members() returns an array of objects, one per member currently in the party:

PropertyTypeDescription
idnumberMember character ID
namestringCharacter name (IGN)
levelnumberCharacter level
jobnumberJob code
sub_jobnumberSub-job code (0 for most jobs)
channelnumberChannel the member is on
field_idnumberMap ID the member is in
is_bossbooleantrue for the party leader

State

core.party.is_in_party() -> boolean

Returns true if you are currently in a party.


core.party.is_party_leader() -> boolean

Returns true if you are the party leader (boss).


core.party.get_party_id() -> number

Returns the current party ID, or 0 when not in a party.


core.party.get_party_name() -> string

Returns the party name, or "" when not in a party.


core.party.get_party_boss_id() -> number

Returns the leader's character ID, or 0 when not in a party.


core.party.get_members() -> table<party_member>

Returns an array of the current members (see Party Member Structure). The array is empty when you aren't in a party.

lua
for _, m in ipairs(core.party.get_members()) do
    core.log(string.format("%s Lv.%d%s", m.name, m.level, m.is_boss and " (leader)" or ""))
end

core.party.is_member(who: string | number) -> boolean

Returns true if who is currently in your party. Pass either a character name (string) or a character ID (number).

Actions

core.party.create(name?: string) -> boolean

Creates a new party. name is optional — when omitted (or empty) the server applies the default name. Returns false if you're already in a party.


core.party.leave() -> boolean

Leaves the current party. Returns false if you're not in a party.


core.party.invite(name: string) -> boolean

Invites the player named name to your party. Only the leader can invite (the server enforces this). Returns true if the request was sent.


core.party.kick(name: string) -> boolean

Kicks the member named name. Returns false if name isn't a current member.


core.party.promote(name: string) -> boolean

Promotes the member named name to party leader. Returns false if name isn't a current member.


core.party.apply(party_id: number) -> boolean

Applies to join the listed party with the given party_id (party search).

Invites

on_party_invite(inviter: string, inviter_id: number, level: number, job: number, sub_job: number) -> boolean | nil

Called when a party invite arrives, before the client shows its invite dialog. The return value decides what happens:

ReturnEffect
trueAccept the invite (no dialog shown)
falseDecline the invite (no dialog shown)
nil (or no return)Let the normal invite dialog appear

inviter is the inviter's name; inviter_id is their character ID (keep it if you want to answer later via accept_invite / decline_invite); level / job / sub_job describe the inviter. The first script to return a non-nil value decides — later scripts don't see that invite.


core.party.accept_invite(inviter_id: number)

Accepts a pending invite from inviter_id (the value passed to on_party_invite). Use this to answer outside the hook — e.g. after an async check.


core.party.decline_invite(inviter_id: number)

Declines a pending invite from inviter_id.

Plugin Required

on_party_invite must be part of a plugin with proper metadata structure.

Example

lua
plugin = {
    name = "Party Helper",
    author = "YourName",
    version = "1.0",
    description = "Auto-accepts invites from my mules and prints the party",
    load = true
}

local TRUSTED = { MyMule1 = true, MyMule2 = true }

function on_party_invite(inviter, inviter_id, level, job, sub_job)
    if TRUSTED[inviter] then
        core.log("Accepting party invite from " .. inviter)
        return true        -- accept, no dialog
    end
    return nil              -- show the normal dialog for everyone else
end

-- Print the current party
if core.party.is_in_party() then
    core.log(string.format("Party '%s' (id %d):",
        core.party.get_party_name(), core.party.get_party_id()))
    for _, m in ipairs(core.party.get_members()) do
        core.log(string.format("  %s Lv.%d ch.%d%s",
            m.name, m.level, m.channel, m.is_boss and " (leader)" or ""))
    end
end