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