Extend GamePanelX functionality with custom plugins
The plugin system in GamePanelX V3 allows you to extend the control panel’s functionality by hooking into predefined action points throughout the interface. Plugins can add custom content, modify behavior, and integrate third-party services.
Create a new directory in plugins/ with your plugin’s internal name:
mkdir plugins/my_custom_plugin
2
Create metadata file
Create plugin.json.txt with your plugin information:
{ "name": "My Custom Plugin", "intname": "my_custom_plugin", "description": "Adds custom features to the home page"}
3
Create main plugin file
Create my_custom_plugin.php with your plugin code:
<?php// Define your functionfunction my_custom_function(){ echo "Custom content displayed on the home page!";}// Hook into an action point$this->set_action('home_top', 'my_custom_function');?>
4
Activate plugin
Enable your plugin through the GamePanelX admin interface under Settings > Plugins.
$function_name - The name of your function to execute
Example:
function display_welcome_message(){ echo '<div class="welcome">Welcome to our game server panel!</div>';}$this->set_action('home_top', 'display_welcome_message');
<?phpfunction log_user_activity(){ if (isset($_SESSION['gpx_username'])) { $username = $_SESSION['gpx_username']; $timestamp = date('Y-m-d H:i:s'); // Log to file or database error_log("User $username active at $timestamp"); }}$this->set_action('index_init', 'log_user_activity');?>
For plugins with complex HTML or database queries:
function complex_plugin_output(){ ob_start(); // Your complex code here $data = fetch_some_data(); ?> <div class="custom-content"> <?php foreach($data as $item): ?> <p><?php echo $item; ?></p> <?php endforeach; ?> </div> <?php return ob_get_clean();}
Handle errors gracefully
Always validate data and handle potential errors:
function safe_plugin_function(){ try { // Your plugin code if (!function_exists('required_function')) { throw new Exception('Required function not available'); } // Process data echo 'Plugin content'; } catch (Exception $e) { if (GPXDEBUG) { echo 'Plugin Error: ' . $e->getMessage(); } }}
Avoid stray output
Don’t use echo statements outside of functions:
<?php// ❌ WRONG - This will not be displayedecho "This is stray output that won't appear!";// ✅ CORRECT - Use functionsfunction my_output(){ echo "This output will be displayed correctly!";}$this->set_action('home_top', 'my_output');?>
Use unique function names
Prefix your functions to avoid conflicts:
// ✅ Good - Prefixed with plugin namefunction myplugin_display_header() { }function myplugin_get_data() { }// ❌ Bad - Generic names may conflictfunction display_header() { }function get_data() { }