Arcade Hooks & Plug-in Functions

Arcade Hooks

integrate_arcade_match
  • Called from: ArcadeGame.php, just after arena match data has been saved.
  • Purpose: Allows you to use the arena score data variables (read only).
  • Accepts: 1 function name.
  • Sends: $id_match, $user_info['id'], $matchInfo['current_round'], $submit_info['score'], $submit_info['duration'], $submit_info['end_time']
    • $id_match - match id number
    • $user_info['id'] - user id of submitted score
    • $matchInfo['current_round'] - round number
    • $matchInfo['name'] - match name
    • $submit_info['score'] - game score
    • $submit_info['duration'] - length of time game was played
    • $submit_info['end_time'] - when the score was submitted


integrate_arcade_score
  • Called from: ArcadeGame.php, just after a game score has been saved.
  • Purpose: Allows you to use the game score data variables (read only).
  • Accepts: 1 function name.
  • Sends: $context['game'], $member, $score
    • $context['game'] - array of game data
    • $member - array of member data (id, name, ip)
    • $score - array of score data (score, duration, endTime)


integrate_arcade_guest
  • Called from: ArcadeGame.php, just after a guest game score has been saved.
  • Purpose: Allows you to use the game score data variables (read only).
  • Accepts: 1 function name.
  • Sends: $context['game'], $submit_info['score']
    • $context['game'] - array of game data
    • $submit_info['score'] - game score


Example usage for adding the above hooks:
add_integration_function('integrate_arcade_match', 'modName_arcade_match');
add_integration_function('integrate_arcade_score', 'modName_arcade_score');
add_integration_function('integrate_arcade_guest', 'modName_arcade_guest');


Example usage for removing the above hooks:
remove_integration_function('integrate_arcade_match', 'modName_arcade_match');
remove_integration_function('integrate_arcade_score', 'modName_arcade_score');
remove_integration_function('integrate_arcade_guest', 'modName_arcade_guest');


Example usage for adding functions to your modification:
Note that functions are provided with arguments which are arrays and/or variables.
You can use var_dump or print_r to see what each array or string contains.

function modName_arcade_match($id_match, $userid, $matchRound, $matchName, $score, $duration, $end_time)
{
  // use above arrays & variables as you wish (read only)
}

function modName_arcade_score($game, $member, $score)
{
  // use arrays as you wish (read only)
  // log_error($score['score']);
}

function modName_arcade_guest($game, $score)
{
  // use above array & variable as you wish (read only)
}



Arcade List Of Games Function

Arcade_gameData($conditions)
This function is available which returns an array containing a list of games in the database.
All game data from the arcade_games table is included. The function allows unique query conditions as a string.
The default conditions are: $conditions = 'WHERE enabled=1 ORDER BY id_game DESC';
This function can be called/used in your modification's PHP files.


Arcade Mod Settings Global Variable

The use of $arcadeModSettings was introduced in SMF-Arcade v2.7.0.2+ voiding the previous use of SMF's $modSettings for any SMF-Arcade generalized settings.
Any old portal blocks or plug-ins that have not been updated may no longer function due to this change.

$arcadeModSettings
This global variable is available for the arcade which is an array containing all forum wide SMF-Arcade settings.
It is used in the exact same way as the SMF global $modSettings but its data is stored in the arcade_modsettings DB table.
All of its data can be manipulated in the same way as $modSettings except the function names for usage are obviously different & are available on site load from ../ArcadeSources/ArcadeHooks.php

updateArcadeSettings($changeArray, $update)
- $changeArray should include: variable => value ( ie. updateArcadeSettings(array('myvar' => $myval)) )
- $update boolean either update current value else replace/create a new value

arcadeSaveDBSettings($config_vars)
- $config_vars is the general array of values created in your typical SMF admin template ( used exactly the same way as saveDBSettings() )

arcadePrepareDBSettingContext($config_vars)
- $config_vars is the general array of values created in your typical SMF admin template ( used exactly the same way as prepareDBSettingContext() )
- also includes data from the 'integrate_prepare_db_settings' integration hook


SMF Hooks For Admin & Profiles

SMF-Arcade does have admin functions that you can use shown below for skins & lists, but you have the option of using SMF's built in hooks for your Admin & User Profile settings.
Please see SMF documentation for instructions regarding the use of those hooks: List of SMF Integration Hooks

Arcade Custom Skins & Mobile Skins

Custom skins & mobile skins can be added to SMF-Arcade via the database and custom source + template files.
Any source files you provide should be located in the "ArcadeSources" directory path & any template files should be located in the default theme path.
Language files can be loaded in your source file using the existing SMF loadLanguage() function.
For this feature, you should have the ability to create your own arcade plug-in that writes the necessary data to the table shown below.
Creating custom source files & templates is also your responsibility if you want to use this option.
The admin_function will store its data in the "arcade_modsettings" DB table & will be available from the $arcadeModSettings global (shown above).
Note: The skin tables have been changed for SMF-Arcade v2.7.0.2 therefore any plug-ins designed for previous SMF-Arcade versions will need to be updated.

Database table for adding skins: arcade_skins
Database table for adding mobile skins: arcade_mobile_skins
Structure for both tables:
id_skin, skin_name, skin_source_file, skin_function, admin_function, lang_function, skin_template, enabled


id_skin is the key column which auto increments when you add a custom skin.

Explanation of columns:
skin_name : The language variable containing your skin name ( ie. $txt['my_unique_skin_name'] = 'Example Skin Name'; )
skin_source_file : name of custom php file located in ../ArcadeSources directory path
skin_function : function being used in your source file (Imo use global $context to store your data for the template)
admin_function : return array of settings available in the arcade admin section (use this function to load your admin language file)
lang_function : use global $txt & load your language file for the skin
skin_template : name of template file located in ../Themes/default directory path
enabled : 0 or 1 to disable/enable template -> when enabled this will appear as an option in the admin & to your users

There is a global variable setting available that will toggle whether the toolbar is shown on the arena and stats pages.
You can set the variable to true if you want the toolbar hidden else it will be shown by default.
Put this setting in your skin source file.

global $arcadeTempSettings;

$arcadeTempSettings['arcade_hide_buttons'] = true;

The Mobile Dark Skin/List plug-in is currently available for the Arcade from the download section. You can peruse its files to get an idea on how to use this feature.

Example of adding the appropriate database entry for a custom skin:
$smcFunc['db_insert']('insert',
    '{db_prefix}arcade_skins',
    array('skin_name' => 'string', 'skin_source_file' => 'string', 'skin_function' => 'string', 'admin_function' => 'string', 'lang_function' => 'string', 'skin_template' => 'string', 'enabled' => 'int'),
    array('my_unique_skin_name', 'Subs-ArcadeSkinCustom1.php', 'myarcade_skin_func1', 'myarcade_skin_settings1', 'myarcade_lang_func1', 'ArcadeCustomSkin1', 1),
    array('id_skin')
);


Arcade Custom Lists & Mobile Lists

Custom lists & mobile lists can be added to SMF-Arcade via the database and custom source + template files.
Any source files you provide should be located in the "ArcadeSources" directory path & any template files should be located in the default theme path.
Language files can be loaded in your source file using the existing SMF loadLanguage() function.
For this feature, you should have the ability to create your own arcade plug-in that writes the necessary data to the table shown below.
Creating custom source files & templates is also your responsibility if you want to use this option.
The admin_function will store its data in the "arcade_modsettings" DB table & will be available from the $arcadeModSettings global (shown above).
Note: The list tables have been changed for SMF-Arcade v2.7.0.2 therefore any plug-ins designed for previous SMF-Arcade versions will need to be updated.

Database table for adding lists: arcade_lists
Database table for adding mobile lists: arcade_mobile_lists
Structure for both tables:
id_list, list_name, list_source_file, list_function, 'admin_function', 'lang_function', list_template, enabled


id_list is the key column which auto increments when you add a custom list.

Explanation of columns:
list_name : The language variable containing your list name ( ie. $txt['my_unique_list_name'] = 'Example List Name'; )
list_source_file : name of custom php file located in ../ArcadeSources directory path (use this function to load your language file)
list_function : function being used in your source file (Imo use global $context to store your data for the template)
admin_function : return array of settings available in the arcade admin section (use this function to load your admin language file)
lang_function : use global $txt & load your language file for the list
list_template : name of template file located in ../Themes/default directory path
enabled : 0 or 1 to disable/enable template -> when enabled this will appear as an option in the admin & to your users

The Mobile Dark Skin/List plug-in is currently available for the Arcade from the download section. You can peruse its files to get an idea on how to use this feature.


Example of adding the appropriate database entry for a custom list:
$smcFunc['db_insert']('insert',
    '{db_prefix}arcade_lists',
    array('list_name' => 'string', 'list_source_file' => 'string', 'list_function' => 'string', 'admin_function' => 'string', 'lang_function' => 'string', 'list_template' => 'string', 'enabled' => 'int'),
    array('my_unique_list_name', 'arcadeCustomList2.php', 'mylistFunc2', 'myadminfunc2', 'mylangfunc2', 'mylisttemplate2', 1),
    array('id_list')
);


Reporting Bugs
Please report bugs to the Official Support Thread!
This helps make this modification better!

Copyright (c) 2004 - 2012, Niko Pahajoki
Copyright (c) 2015 - 2024, Chen Zhen
Current support provided by Chen Zhen @ web-develop.ca
SMF-Arcade License: BSD 2