XTask
Browse AddonsDownload RLIB
  • Introduction
  • Showcase
  • Changelog
    • 🟥v4.5.0.0
    • 🟥v4.4.0.0
  • FAQ
    • 🟥Addon Won't Show
    • 🟥Incompatible Addons
    • 🟥Modified Script
    • 🟥Refunds
    • 🟥Script Errors
    • 🟥When Are Updates?
  • ❱ Setup
    • 🟪Install
    • 🟪Verify
    • 🟪Workshop
    • 🟪Docs / Web
  • ❱ Configuration
    • 🟪Settings
    • 🟪Achievements
      • 🧢XTASK.enabled
      • 🧢XTASK.title
      • 🧢XTASK.desc
      • 🧢XTASK.author
      • 🧢XTASK.icon
      • 🧢XTASK.cat
      • 🧢XTASK.cat_clr
      • 🧢XTASK.po_enabled
      • 🧢XTASK.po
      • 🧢XTASK.maxreq
      • 🧢XTASK.stat
      • 🧢XTASK.family
      • 🧢XTASK.gamemode
      • 🧢XTASK.trigger
      • 🧢XTASK.onClient
      • 🧢XTASK.onShared
      • 🧢XTASK.onServer
      • 🧢XTASK.family
    • 🟪Languages
  • ❱ First Use
    • 🟪Binds
  • ❱ Developers
    • 🟪Env
Powered by GitBook
On this page
  • ▸ Data Type
  • ▸ Description
  1. ❱ Configuration
  2. Achievements

XTASK.family

Allows achievements to be grouped in families

PreviousXTASK.onServerNextLanguages

Last updated 2 years ago

SHARED

▸ Data Type

string

▸ Description

Used in circumstances where you must monitor a client-side hook and send the data server-side. This allows you to increase the progress on a group of achievements that all do the same thing with different numbers.

If the hook can be ran server-side, then there's no reason to use this feature. Hook will execute and count all achievements of the same type together.

// server scope function
XTASK.onServer = function( id, id_hook, path )
    local network_id = sf( 'xtask_cl_sv_ach_%s', id )

    util.AddNetworkString( network_id )
    net.Receive( network_id, function( len, pl )
        local ach_id        = net.ReadString( )
        local val           = net.ReadUInt( 32 )
        local family        = mod:GetFamily( XTASK.family )

        if XTASK.family and istable( family ) then
            for k, v in pairs( family ) do
                pl:ach_execute( mod:GetByID( v.id ), val )
            end
        else
            pl:ach_execute( mod:GetByID( ach_id ), val )
        end
    end )
end

// client scope function
XTASK.onClient = function( id, id_hook, path )
    local network_id = sf( 'xtask_cl_sv_ach_%s', id )

    /*
        count SpawnMenu toggles
    */

    local count = 0
    local function spawnmenu_onOpen(  ply, mdl, ent )
        count = count + 1
    end
    hook.Add( 'SpawnMenuOpen', id_hook, spawnmenu_onOpen )

    /*
        network
    */

    local timer_id = sf( 'xtask_cl_ach_%s', id_hook )
    timex.create( timer_id, 15, 0, function( )
        if not isstring( id ) then return end
        count = isnumber( count ) and count or 0

        net.Start( network_id )
            net.WriteString( id )
            net.WriteUInt( count, 32 )
        net.SendToServer( )

        count = 0
    end )
end
🟪
🧢
🟦