#include #include #include // #include "../src/external.h" static void log_to_file(const char *message) { FILE *log_file = fopen("bin/server_logs.log", "a"); if (log_file) { fprintf(log_file, "%s\n", message); fclose(log_file); } } void MP_init_plugin() { // say hello to the user! printf("hello from a plugin!\n"); } void MP_modify_server_stats(struct relay_info *server_stats) { // return a random number as motd each time char str[] = "hello! random number: X"; str[ sizeof(str) - 2 ] = (rand() % 10) + '0'; memcpy(server_stats->motd, str, sizeof(str)); } void MP_custom_log(int level, const char *msg) { // log stuff to a file char log_msg[ 512 ]; snprintf(log_msg, sizeof(log_msg), "[level %d] %s", level, msg); log_to_file(log_msg); } void MP_on_server_shutdown() { // goodbye! printf("bye!\n"); }