• Welcome to MX Bikes Official Forum. Please login or sign up.
 
December 05, 2022, 03:39:34 PM

News:

MX Bikes beta18b available! :)


Dedicated server

Started by PiBoSo, October 02, 2014, 02:38:18 PM

Previous topic - Next topic

XenoMordA

Hello!
I have a little problem, i managaed to START a dedi server on my PC... The server is showing in the browser for me , and on the website, and some ppl even managed to connect and play with me. But my friend from the same town cannot join my server. He have connection timeout at every attempt. The thing is that my server doesnt show ping in the browser, could this be the reason he cant connect? I have read about the problem with showing the ping, i think i did everything as the instruction says but to no avail. Can someone help me pls?:)

PiBoSo

March 08, 2022, 12:38:29 PM #106 Last Edit: March 12, 2022, 11:55:02 AM by PiBoSo
First post updated to add the option to write the dedicated server output to a file.

JNS47

Quote from: PiBoSo on July 28, 2020, 12:39:14 PM
Quote from: Paulo Rodrigues on July 22, 2020, 03:44:24 AMhm... i think if some numbers of players call me outside MXB saying the server has a anti-game player i need to do something remotely, like kick or ban.

And another question:

Will be possible (or its possible) to create server plugins with r/w commands and events?
like:

onPlayerJoined(playerObj obj, others attr...)
onPlayerRunStart(playerObj obj, others attr...)
onPlayerQuit(playerObj obj, others attr...)
...
setPlayerName() // usefull if i need to create some roles and prepend some text in the player name while he is in the server (ex: [MOD] Player name, or [VIP] Player name)
setPlayerGate(player, gateNumber) // usefull if i need to create a custom race, x1 (two bikes turn based event), sudden dead
sendPlayerToSpec(player) // usefull if i need to create a custom race, x1 (two bikes turn based event), sudden dead
sendPlayerToGate(player, gateNumber) // usefull if i need to create a custom race, x1 (two bikes turn based event), sudden dead
blockPlayerRaceEntry(all or player) //
setEvent(eventType) //
broadcastMessage(player_NotRequired, message) //
...

Thank you for the requests.
Could you please give more info about the "onPlayer" commands?
Is "two bikes turn based event" straight rhythm?
What would be the use of "blockPlayerRaceEntry"?
Please note that it's not possible to change event type while the server is running, so "setEvent" cannot be implemented.

A few years later and I'm someone else but I'd really like a server plugin interface as well.
My ideas for some interface events and functions are these (sorry, it's a lot xd):
Code (cpp) Select
#include <Windows.h>

typedef struct
{
float x;
float y;
float z;
} Vector3;

enum Shape
{
Box,
Cylinder
};

typedef struct
{
int id;
Vector3 position;
Vector3 size;
Shape shape;
unsigned long color;
} Trigger;

enum PenaltyType
{
Cutting,
JumpStart
};


// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// Events
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

/// <summary>
/// Fired when a player is establishing a connection, before loading any resources.
/// </summary>
/// <param name="player">Pointer to players GUID.</param>
/// <param name="ipAddress">Players IP address.</param>
/// <param name="asSpectator">Whether the player tries to join as spectator.</param>
/// <returns>Whether the event should be cancelled or not.</returns>
/// <remarks>
/// Could be used to prioritize admins, block IPs, ...
/// </remarks>
bool PlayerEstablishingConnection(GUID* player, char* ipAddress, bool asSpectator);

/// <summary>
/// Fired when a player is joining the server after establishing the connection was not cancelled.
/// Starts to load resources now.
/// Player is in the player list now, so you can access a player struct through their GUID
/// This could contain the IP address, spectator state and more.
/// </summary>
/// <param name="player">Pointer to players GUID.</param>
/// <remarks>
/// Could be used to load some player related data, so it's ready once they are connected.
/// </remarks>
void PlayerJoining(GUID* player);

/// <summary>
/// Fired when a player is connected to the server and finished loading all resources (is in pits).
/// </summary>
/// <param name="player">Pointer to players GUID.</param>
/// <remarks>
/// Could be used for logging purposes or to write a welcome message saying
/// e.g.: "[PlayerX] connected from [CountryY], they have [PlaytimeZ] hours on this server.",
/// to replace their name with an alias or change their race number.
/// </remarks>
void PlayerConnected(GUID* player);

/// <summary>
/// Fired when a player is leaving the server. (directly after clicking back and accepting exiting with "OK")
/// </summary>
/// <param name="player">Pointer to players GUID.</param>
/// <remarks>
/// Could be used for logging purposes or to write a leaving message saying
/// e.g.: "[PlayerX] disconnected after [SessionTimeY] minutes".
/// </remarks>
void PlayerLeaving(GUID* player);

/// <summary>
/// Fired when player is completely disconnected from the server. All their data is getting cleaned up now.
/// </summary>
/// <param name="player">Pointer to players GUID.</param>
/// <remarks>
/// Could be used to clean up the data that about them. (free pointers, ...)
/// </remarks>
void PlayerDisconnected(GUID* player);

/// <summary>
/// Fired when player entered the track.
/// </summary>
/// <param name="player">Pointer to players GUID.</param>
void PlayerEnteredTrack(GUID* player);

/// <summary>
/// Fired when player entered pits.
/// </summary>
/// <param name="player">Pointer to players GUID.</param>
void PlayerEnteredPit(GUID* player);

/// <summary>
/// Fired when player gets a penalty.
/// </summary>
/// <param name="player">Pointer to players GUID.</param>
/// <param name="penaltyType">Type of the penalty (Cutting, JumpStart, ...).</param>
void PlayerGotPenalty(GUID* player, PenaltyType penaltyType);

/// <summary>
/// Fired when two players collide.
/// </summary>
/// <param name="playerA">Pointer to playerAs GUID.</param>
/// <param name="playerB">Pointer to playerBs GUID.</param>
void PlayerWithPlayerCollision(GUID* playerA, GUID* playerB);

/// <summary>
/// Fired when a player collides with the world.
/// </summary>
/// <param name="player">Pointer to players GUID.</param>
void PlayerWithWorldCollision(GUID* player);

/// <summary>
/// Fired when a player crashes (goes down).
/// </summary>
/// <param name="player">Pointer to players GUID.</param>
void PlayerCrash(GUID* player);

/// <summary>
/// Fired when a player starts to reset.
/// </summary>
/// <param name="player">Pointer to players GUID.</param>
/// <returns>Whether the event should be cancelled or not.</returns>
bool PlayerStartReset(GUID* player);

/// <summary>
/// Fired when a player resets (finishes to reset).
/// </summary>
/// <param name="player">Pointer to players GUID.</param>
/// <returns>Whether the event should be cancelled or not.</returns>
bool PlayerReset(GUID* player);

/// <summary>
/// Fired when a player crosses a split.
/// </summary>
/// <param name="player">Pointer to players GUID.</param>
void PlayerSplitCrossed(GUID* player);

/// <summary>
/// Fired when a player crosses the finish line (finishes a lap).
/// </summary>
/// <param name="player">Pointer to players GUID.</param>
void PlayerFinishCrossed(GUID* player);

/// <summary>
/// Fired when a player sends a message in chat (no private message).
/// Can be cancelled before sending to all players.
/// </summary>
/// <param name="player">Pointer to players GUID.</param>
/// <param name="message">the message that was sent.</param>
/// <returns>Whether the event should be cancelled or not.</returns>
bool PlayerChat(GUID* player, char* message);

/// <summary>
/// Fired when a player sends a command.
/// </summary>
/// <param name="player">Pointer to players GUID.</param>
/// <param name="command">Name of the command that was sent (first string before space).</param>
/// <param name="args">Command arguments (space seperated).</param>
/// <returns>Whether the event should be cancelled or not.</returns>
bool PlayerCommand(GUID* player, char* command, char** args);

/// <summary>
/// Fired when a player gets disqualified
/// </summary>
/// <param name="player">Pointer to disqualified players GUID.</param>
/// <param name="issuer">Pointer to GUID of player that disqualified the player.</param>
/// <param name="message">specified reason for the disqualification.</param>
/// <returns>Whether the event should be cancelled or not.</returns>
bool PlayerDisqualified(GUID* player, GUID* issuer, char* reason);

/// <summary>
/// Fired when a player gets kicked
/// </summary>
/// <param name="player">Pointer to kicked players GUID.</param>
/// <param name="issuer">Pointer to GUID of player that kicked the player.</param>
/// <param name="message">specified reason for the kick.</param>
/// <returns>Whether the event should be cancelled or not.</returns>
bool PlayerKicked(GUID* player, GUID* issuer, char* reason);

/// <summary>
/// Fired when a player gets temporarily banned
/// </summary>
/// <param name="player">Pointer to banned players GUID.</param>
/// <param name="issuer">Pointer to GUID of player that banned the player.</param>
/// <param name="seconds">Duration of the temporary ban in milliseconds.</param>
/// <param name="message">specified reason for the ban.</param>
/// <returns>Whether the event should be cancelled or not.</returns>
bool PlayerTempBanned(GUID* player, GUID* issuer, unsigned long long int milliseconds, char* reason);

/// <summary>
/// Fired when a player gets banned
/// </summary>
/// <param name="player">Pointer to banned players GUID.</param>
/// <param name="issuer">Pointer to GUID of player that banned the player.</param>
/// <param name="message">specified reason for the ban.</param>
/// <returns>Whether the event should be cancelled or not.</returns>
bool PlayerBanned(GUID* player, GUID* issuer, char* reason);

/// <summary>
/// Fired when a players spectator state changes.
/// </summary>
/// <param name="player">Pointer to players GUID.</param>
/// <param name="isSpectator">Whether the player changed to spectator. If false they changed to player.</param>
/// <returns>Whether the event should be cancelled or not.</returns>
bool PlayerSpectatorModeChanged(GUID* player, bool isSpectatorState);

/// <summary>
/// Fired when a players entered a trigger.
/// </summary>
/// <param name="player">Pointer to players GUID.</param>
/// <param name="enterPosition">Position at which the player entered the trigger.</param>
/// <param name="trigger">The trigger that was entered.</param>
/// <remarks>
/// Trigger => { int id, Vector3 position, Vector3 size, Shape shape (Box, Cylinder), unsigned long color }
/// Could be used to create minigames, e.g.: easter egg hunt. lol
/// </remarks>
void PlayerEnterTrigger(GUID* player, Vector3 enterPosition, Trigger trigger);

/// <summary>
/// Fired when a players exits a trigger.
/// </summary>
/// <param name="player">Pointer to players GUID.</param>
/// <param name="exitPosition">Position at which the player exited the trigger.</param>
/// <param name="trigger">The trigger that was exited.</param>
/// <remarks>
/// Trigger => { int id, Vector3 position, Vector3 size, Shape shape (Box, Cylinder), unsigned long color }
/// Could be used to create minigames, e.g.: easter egg hunt. lol
/// </remarks>
void PlayerExitTrigger(GUID* player, Vector3 exitPosition, Trigger trigger);

/// <summary>
/// Fired when server is about to start.
/// </summary>
/// <remarks>
/// Could be used to load data from file/database.
/// </remarks>
void ServerStarting();

/// <summary>
/// Fired when server is fully started and players can join.
/// </summary>
void ServerStarted();

/// <summary>
/// Fired when server is about to stop.
/// </summary>
/// <remarks>
/// Could be used to save some data.
/// Could maybe contain stopping reason, error code or exception as parameter.
/// </remarks>
void ServerStopping();

/// <summary>
/// Fired right before server is fully stopped.
/// </summary>
/// <remarks>
/// Could be used to log that the server stopped or clean up data (free pointers, ...).
/// Could maybe contain stopping reason, error code or exception as parameter.
/// </remarks>
void ServerStopped();

/// <summary>
/// Fired each server tick (or maybe a defined frequency).
/// </summary>
/// <remarks>
/// Can be used to send live updates.
/// </remarks>
void ServerTicked();

/// <summary>
/// Fired when the track was reset.
/// </summary>
void TrackReset();

/// <summary>
/// Fired when a session starts.
/// </summary>
/// <remarks>
/// Could be used to start own live timing.
/// </remarks>
void SessionStarted(/*session settings ((practice, qualiy or race), track, duration, ...)*/);

/// <summary>
/// Fired when a session ends.
/// </summary>
/// <remarks>
/// Could be used to stop own live timing and write results.
/// </remarks>
void SessionFinished(/*results, end reason (manually, completed, ...)*/);

/// <summary>
/// Fired when a new poll is started.
/// </summary>
/// <remarks>
/// Can be used to send live updates.
/// </remarks>
/// <returns>Whether the poll should be cancelled (doesn't go through to all players).</returns>
bool PollStarted(/*typed, id, ...*/);

/// <summary>
/// Fired when someone makes a vote for a poll.
/// </summary>
/// <param name="player">Pointer to players GUID.</param>
/// <param name="voteYes">Whether the player voted for or against it.</param>
void PollVote(GUID* player, bool voteYes);

/// <summary>
/// Fired when a poll has ended.
/// </summary>
/// <remarks>
/// Can be used to manipulate poll results.
/// </remarks>
/// <returns>Poll result.</returns>
bool PollEnded(/*type, id, votes, ...*/);


// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// Functions
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

// Player Functions
//-----------------

// Set whether the player should be an admin or not.
void SetIsAdmin(GUID* player, bool isAdmin);

// Returns whether the player is an admin or not.
bool IsAdmin(GUID* player);

// Send a message to a specific player, that looks like a normal message.
void SendNormalMessage(GUID* player, char* message);

// Send a message to a specific player, that includes formatting options (color, bold, italic, underline, ...)
// so you can make some parts of a message stand out more.
void SendFormattedMessage(GUID* player, char* message);

// Send a private message to a specific player.
void SendPrivateMessage(GUID* player, char* message);

// Set whether the player should be a spectator or a player.
void SetIsSpectator(GUID* player, bool isSpectator);

// Returns whether the player is a spectator or not.
bool IsSpectator(GUID* player);

// Disqualify a player, optionally with a reason and an issuer (issuer = nullptr -> server)
// reason and issuer could be added as comment in .ini file, else just being used for the event.
void Disqualify(GUID* player, char* reason = nullptr, GUID* issuer = nullptr);

// Kick a player, optionally with a reason and an issuer (issuer = nullptr -> server)
// reason and issuer could be added as comment in .ini file, else just being used for the event.
void Kick(GUID* player, char* reason = nullptr, GUID* issuer = nullptr);

// TempBan a player for a given time, optionally with a reason and an issuer (issuer = nullptr -> server)
// reason and issuer could be added as comment in .ini file, else just being used for the event.
void TempBan(GUID* player, unsigned long long int milliseconds, char* reason = nullptr, GUID* issuer = nullptr);

// Ban a player, optionally with a reason and an issuer (issuer = nullptr -> server)
// reason and issuer could be added as comment in .ini file, else just being used for the event.
void Ban(GUID* player, char* reason = nullptr, GUID* issuer = nullptr);

// Whitelist a player, optionally with an issuer (issuer = nullptr -> server)
// issuer could be added as comment in .ini file.
void Whitelist(GUID* player, char* reason = nullptr, GUID* issuer = nullptr);

// Blacklist a player, optionally with an issuer (issuer = nullptr -> server)
// issuer could be added as comment in .ini file.
void Blacklist(GUID* player, GUID* issuer = nullptr);

// Create a player specific trigger.
// Trigger => { int id, Vector3 position, Vector3 size, Shape shape (Box, Cylinder), unsigned long color }
void AddTrigger(GUID* player, Trigger trigger);

// Remove a player specific trigger.
// Trigger => { int id, Vector3 position, Vector3 size, Shape shape (Box, Cylinder), unsigned long color }
void DeleteTrigger(GUID* player, Trigger trigger);

// Get the position of a player (maybe also add yaw, pitch, ...).
Vector3 GetPosition(GUID* player);

// Set the position of a player (maybe also add yaw, pitch, ...).
void SetPosition(GUID* player, Vector3, double, double);

// Get the username of a player (full name).
char* GetName(GUID* player);

// Get the alias of a player (if no alias set, use username).
// Used to replace username.
char* GetAlias(GUID* player);

// Set an alias for a player.
void SetAlias(GUID* player, char* alias);

// Get the rider number of a player.
unsigned short int GetRiderNumber(GUID* player);

// Set a rider number for a player.
void SetRiderNumber(GUID* player, unsigned short int number);

// Get the rider name of a player (name on jersey and bike).
char* GetRiderName(GUID* player);

// Set the rider name of a player (name on jersey and bike).
void SetRiderName(GUID* player, char* name);

// Get the start position of a player (on which gate a player is starting).
int GetStartPosition(GUID* player);

// Set the start position of a player (on which gate a player is starting).
void SetStartPosition(GUID* player, int position);

// Pass to a specific player client, to draw elements.
// allows server HUD, might get abused though. Would still be cool though.
void Draw(GUID* player, int _iState, int* _piNumQuads, void** _ppQuad, int* _piNumString, void** _ppString);

// Server Functions
//-----------------

// Pass to all clients, to draw elements.
// allows server HUD, might get abused though. Would still be cool though.
void Draw(int _iState, int* _piNumQuads, void** _ppQuad, int* _piNumString, void** _ppString);

// Send a message to all players.
void SendNormalMessage(char* message);

// Send a message to all players, that includes formatting options (color, bold, italic, underline, ...)
// so you can make some parts of a message stand out more.
void SendFormattedMessage(char* message);

// Start a specific session.
void StartSession(/*Session info (race1, race2, qualy, ...), maybe track, duration and other settings*/);

// Reset track.
void ResetTrack();

// Stop server.
void Stop();

// Create a trigger for all players.
// Trigger => { int id, Vector3 position, Vector3 size, Shape shape (Box, Cylinder), unsigned long color }
void AddTrigger(Trigger trigger);

// Remove a trigger for all players.
// Trigger => { int id, Vector3 position, Vector3 size, Shape shape (Box, Cylinder), unsigned long color }
void DeleteTrigger(Trigger trigger);


// Also:
//
// Some way to (un-)register custom commands.
//
// Getters (and setters where useful) for the other structs used for output plugins as well.
// (SPluginsBikeEvent_t, SPluginsBikeData_t, SPluginsBikeLap_t, SPluginsRaceTrackPosition_t, ...)
// (or some similar structs that have the information about the server/game state)
Tried to make it clear what all of this would be for with the comments.

I'm not that much of a C(++) dev, so implementation wise it might be shit and yours would probably differ a lot.
It's more about the idea of the functions/events and the comments of them. Just take it as a big wishlist (it's christmas in ~2 months 👉👈🥺 😂) of stuff with which I could probably do most stuff. Just some of it would be cool already.

I know that some of that stuff is already possible with UDP sockets but having an option inside the server itself would be nice as well. And I also know that some of that stuff would probably require new features to be added (e.g.: temporary bans, message formatting).

Feel free to reach out if there's something you don't understand the purpose of. 😅

Resolute Kraken

A lot of what you are asking for is already available via the Remote Admin commands, live timing data, and whitelist/blacklist features.  Yes, it would be cool to have an actual plug-in so that UDP wouldn't have to be used - and parsing the current data is a nightmare.  But it seems like this would be a low priority for Pibs with some of this data/commands already available.

PiBoSo

First post updated to:
- add the option to shuffle the tracks list
- add the option to set a bike reset delay