player-info-library

#10 - published 7 months ago

Player Info Library

Adds a more advanced and detailed investigate command, and adds the ability to query stored data in other plugins. Once upon a time there was a more detailed investigate command in Unturned, this plugin bassically re-adds that and more.

 

Plugin Dev\’s can also look at the source code for the plugin on git for a better idea of how the plugin works.
https://github.com/cartman-2000/PlayerInfoLib

 

Commands

  • /investigate <\”playername\” | SteamID | IP address > [page number] – Shows list of players that match search query.
  • rnint <\”new instance name\”> – Changes the instance name stored in the database that is used to tie the player info data to this server. This would be used for when you want to change the instance name on the server, you would need to run this command prior to restarting the server after the change. Console only command.
  • delint <Instance ID> – Deletes all the player info data for the given Instance ID, use with caution, and it\’s recommended to make a Database backup first. This command may take some time to complete if there\’s a lot of data to remove. Console only command.

Permissions

  • investigate – allows you to use the investigate command.

Configuration

  • DatabaseAddress – The address to the Mysql database server.
  • DatabaseUserName – Your username on the Mysql server.
  • DatabasePassword – Your username password on the Mysql server.
  • DatabaseName – The database you want the tables stored in.
  • DatabaseTableName – The Name of the tables you want to use for the plugin.
  • KeepaliveInterval – The length of time in minutes between each ping to the mysql server, the plugin uses a persistent connection to the Mysql server. Default 10 minutes.
  • CacheTime – Time in number of minutes that records that were retrieved by steam id should be retrieved out of the cache instead of the database. This will speed up retrieval of data from this plugin in other plugins. Default 180 minutes, or 3 hours.
  • ExpiredCheckInterval – How often to check the cache and and player data for expired data.
  • ExpiresAfter – Used to set how long to keep player info records in the database, in days. Set to 0 to disable this feature.
  • VipCheckGroupName – Use what you have set as the id for the vip group on your server(case sinsitive.), defaults to “vip.”

Plugin Api

Database Class
  • public PlayerData PlayerInfoLib.Database.QueryById(CSteamID steamId, bool cached = true) – For getting data by SteamID. First param is the CSteamID of the player you want to lookup, the second is an optional param, set to false if you want to skip the cache when looking up player data. Returns a PlayerData typed object.
  • public List<PlayerData> PlayerInfoLib.Database.QueryByName(string playerName, QueryType queryType, out uint totalRecods, bool pagination = true, uint page = 1, uint limit = 4) – For getting data by name or ip address. First param is the name of the player or the ip of a player you want to look up, the second is the query type you want to perform, there\’s four possible ones you can use: SteamName, CharName, Both, IP. totalRecords returns the number of records found in the query. The next three are optional params, that are used for pagination of the output. This returns a List of PlayerData typed data.
  • These methods will try to find players that have played on the server it being queried on first before looking for the info for the last server they played on.
PlayerData Class

Properties

  • SteamID, SteamName, CharacterName, IP – The primary data for the player.
  • LastLoginGlobal – The last time They were seen on any server, in DateTime format.
  • TotalPlayTime – The total amount of time that a player has played on the server\’s in seconds.
  • LastLoginLocal – The last time they\’ve played on the server that this data has been queried on, in DateTime format.
  • LastServerName – The name of the last server they played on.
  • Other data:
  • LastServerID – The instance id of the last server the player played on, used in the IsLocal method in the class.
  • ServerID – The instance id of either the local server, the last server the player played on if a local record wasn\’t found for the player, or 0 if no record for the last server they played on was found.
  • CacheTime – Stores the DateTime of when the data was stored in the cache.
  • CleanedBuildables and CleanedPlayerData – For future use in the wrecking ball plugin.

Methods

  • IsLocal() – Checks to see if the data in the class belongs to this server or not.
  • IsValid() – Checks to see if the data is valid, this will be false if the player data wasn\’t found by a steam id search.
  • IsCacheExpired() – Used for checking to see if the data has expired or not(for Caching).
  • IsVip() – Returns if the player has Vip on the server. Searches all groups a player has to find a match to the group name set in the plugin config. For players in higher groups, it requires that these groups inherit the vip group, in the inheritence chain, for this to come back as true.

 

Change Notes

  • 1.3.0.0: This update adds two commands(check the commands secotion on their usege), and an automatic player data cleanup feature player data that is older than the time set in the config. You will need to delete and regenerate the translations file for this update, as it adds more translations lines.
  • 1.3.0.2: Updated the database to handle emoji characters and other special 4 byte UTF8 characters(required conversion of the steam/char name tables to utf8mb4.).
  • 1.3.1.0: Add an IsVip feature to the player data class. Works by searching through set and inherited groups for a group that matches what is in the config.

Default configuration


<?xml version="1.0" encoding="utf-8"?>
<PlayerInfoLibConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <DatabaseAddress>localhost</DatabaseAddress>
  <DatabasePort>3306</DatabasePort>
  <DatabaseUserName>unturned</DatabaseUserName>
  <DatabasePassword>password</DatabasePassword>
  <DatabaseName>unturned</DatabaseName>
  <DatabaseTableName>playerinfo</DatabaseTableName>
  <KeepaliveInterval>10</KeepaliveInterval>
  <CacheTime>180</CacheTime>
  <ExpiredCheckInterval>30</ExpiredCheckInterval>
  <ExpiresAfter>365</ExpiresAfter>
  <VipCheckGroupName>vip</VipCheckGroupName>
</PlayerInfoLibConfig>

Default english translation


<?xml version="1.0" encoding="utf-8"?>
<Translations xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Translation Id="too_many_parameters" Value="Too many parameters." />
  <Translation Id="investigate_help" Value="&lt;&quot;Player name&quot; | SteamID&gt; [page] - Returns info for players matching the search quarry." />
  <Translation Id="delint_help" Value="&lt;&quot;Instance ID&quot;&gt; - Uses the numerical Instance ID for a server to remove all player data saved for that server. !!Use with caution, can't be undone without a database backup!!" />
  <Translation Id="rnint_help" Value="&lt;&quot;New instance name&quot;&gt; - Renames the instance name, in the record for this server, in the database" />
  <Translation Id="invalid_page" Value="Error: Invalid page number." />
  <Translation Id="number_of_records_found" Value="{0} Records found for: {1}, Page: {2} of {3}" />
  <Translation Id="delint_invalid" Value="Error: Invalid Instance ID." />
  <Translation Id="delint_not_found" Value="Error: Failed to find Instance ID in the database." />
  <Translation Id="delint_success" Value="Successfully Removed all data for this Instance ID, if you removed the data for this server, you will need to reload the plugin for it to be operational again." />
  <Translation Id="rnint_success" Value="Successfully changed the instance name for this server in the Database, Server should be restarted now." />
  <Translation Id="rnint_not_found" Value="Error: Failed to set the new instance name to the Database." />
</Translations>

Commands and permissions


/delint <"Instance ID">

Permissions: delint

Uses the numerical Instance ID for a server to remove all player data saved for that server. !!Use with caution, can't be undone without a database backup!!


/rnint <"New instance name">

Permissions: rnint

Renames the instance name, in the record for this server, in the database


/investigate <"Player name" | SteamID> [page]

Permissions: investigate

Returns info for players matching the search quarry.


Git changelog


0460bbc5a6000e4 2018-04-30 00:06:30

Add a IsVip feature to the player data class.

    Download

    Build #10
    By downloading this file, you agree to our license terms.

    Repository

    github.com

    License

    MIT

    Author

    cartman-2000