-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[enh] simple API plugin framework #167
Comments
Work arounds - if we require a mod name field, use that for the failed transactions filename, the originating mod is then free to safely examine/process/delete this file without conflicting with another mod. Economy API Datafiles:
EconomyAPI.log
Economy.txt
Originating_Mod.failed
Economy API Supporting Mods:
Originating_Mod.failed
Notes:
Reserved codes:
|
This was added back in January. Don't know how well it works. |
Ah ok, so skip the middle man and talk directly to each other in a single variable instead of using placeholder files - |
Added infrastructure for communicating with other Mods. Created new project to handle code for consumpting by other mods to communicate with Economy. Added 1 working API, PayUser.
Replaced the Economy.scripts.sln with a Economy.Mod.sln at the root level. It is also not required in content published to Steam.
Summary: A simplistic system to allow other plugin makers to support money transactions within Frontier Economy.
Synopsis:
3rd party plugins append transaction requests to a global file, economy periodically checks and processes these requests. Economy creates a "flag" file to indicate to other plugins it is running to prevent transactions being queued if it is not present. 3rd party plugins supporting optional economic features check for this file before attempting to issue requests. Code samples for how to interact with this file can be included in the economy manual for mod makers to easily add such support.
Security concerns:
1: Players may create plugins with the express purpose of swindling money. However the command file will only be checked server side, which limits such exploits to plugins the server admin deliberately installed, instead of client side "ghost" plugins, which will be ignored as they are not interacting server side.
2: It may be possible to over draw accounts, or for a transaction to fail. It should never overdraw on the economy side, so 3rd party plugins need a way to detect a transaction has failed.
Basic function:
On launch economy creates a blank file in the global storage area named "Economy.online"
When shutting down economy deletes this file. It serves no other purpose but to indicate to other plugins that economy is currently running on a server.
Communication is essentially one way - plugins can issue commands to economy but economy will not talk back. However such transactions could be logged to a global file allowing 3rd party plugins to check if its request was processed. Economy could also generate a "failed transactions" file in the case the requested player either doesn't exist or lacks enough funds. Economy could also potentially create a economy.processing file, but a simple try catch retry when appending commands to the file should be adequate.
While running economy will periodically check for a global file named for example "economy.txt" this file must contain four things per transaction:
1: payer ID (Source of funds. Either steam name and/or steam ID, or a keyword indicating generate new or NPC)
2: payee ID (Target of funds. Either steam name and/or steam ID, or a keyword indicating destroy funds or NPC)
3: Transaction amount. (OR it could also be an item/qty to allow more flexibility for plugins)
4: Transaction reason - ideally including at least the requesting mod name
The file can contain more than one transaction.
Once processed the transactions (or entire file) will be deleted to prevent double processing.
3rd party mod restrictions:
mods talking to economy should only ever APPEND to the file
mods should only READ the transaction log or failed transactions file
Concerns:
failed transaction file may become very large, it may be necessary to require 3rd party mods delete any failed transactions they have already processed to reduce potential performance impact.
If more than one 3rd party plugin exists simply deleting the failed transaction file will cause problems, it may also be necessary for 3rd party plugins to generate a transaction ID so they only delete their own failed transactions.
Ideally a simple communication framework negating the need for a transaction file entirely is preferable - although the online flag file can probably still be used.
In this case a transaction would be along the lines of:
3rd party plugin sends Payer, Payee, amount, reason, requesting mod, optional transaction ID.
Economy responds to requesting mod with Payer, Payee, amount, reason, approved/failed, optional transaction ID
Example 3rd party plugins:
Stargate mod - charge a fee per trip
Frontier Territory mod - charge an entry tax when crossing into another factions territory.
Gateway lobby mod - charge a fee to travel to another sector
Mail order ships mod - charge a fee to spawn in a prefab (eg something like the midspace admin helper mod /addprefab # command)
NPC courier mod - charge a fee to transport goods etc
Jobs Mod - pay a player a wage for performing tasks
Rewards/Gifts/Prizes mods - pay a player a prize in money or goods (eg tier 10 weapon tokens etc)
The text was updated successfully, but these errors were encountered: