Skip to content
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

Events hooks and other automation features #590

Open
insanemal opened this issue Jan 6, 2025 · 6 comments
Open

Events hooks and other automation features #590

insanemal opened this issue Jan 6, 2025 · 6 comments

Comments

@insanemal
Copy link

I'm running a sever for me and my kids, I'd like to be able to have the server fire off scripts or something when they connect. I know I can poll the API end point to see when they connect but I can't run server commands via the API and there isn't a unix socket to replicate the "console" for other commands that I could use programmatically. I could have a python script launch the server and get access to stdin/stdout but that feels clunky

I also can't see a way to check a player inventory from the server.

What I'd like is to be able to check their *mate/*fluid stocks on login and top them up to 10 of each.

I'm currently looking at using "as cc $i Trifluid x<number to make 10>" obviously with the stuff in <> filled in by the scripting language of my choice (Probably python), but would love something that doesn't require cheats to be enabled.

I think a unix socket to get access to the "console" would get me 80% of the way there. Or possibly 100% of the way, if there is already a way to check their inventory I just don't know about.

I think a way to do automations beyond just rare item alerting would be handy/useful. Also a way to gift things to users without having to use cheats as the user. Could be good for server wide competitions and stuff. (First user to collect 10 red boxes in EP 2 Ultimate before Tuesday, gets a Cell mag. Or something)

Could also be useful to be able to add hooks for custom server chat commands.

Sorry if this is a bit of a ramble.
Thanks

@fuzziqersoftware
Copy link
Owner

fuzziqersoftware commented Jan 6, 2025

I'm considering doing the following:

  • Add the ability to run a shell command via the HTTP server. There would be a new endpoint that accepts the shell command text and returns the response text that the stdin shell would have printed.
  • Make the cc shell command exempt from permissions checks, so cheat commands can always be used even if the player specified by on C-## doesn't have permission to cheat. This seems OK to me since the shell interface is only intended to be accessible to administrators.

Would these two features suffice for your use case? Inventory items were added to the API in a recent change; there hasn't been a release since then, but you can build from source to get that change.

I could also add a new websocket endpoint that would send client connect/disconnect and lobby change events, but this would be a fair amount more work than the above.

@insanemal
Copy link
Author

This would get me what I need! Thanks!

I am currently running a built from source from latest upstream, so which API has inventory items?

@fuzziqersoftware
Copy link
Owner

You should be able to see inventory items in the data returned by /y/clients. For clients who have character data loaded on the server (that is, clients who are in a lobby or game and not at the main menu), you'll get a list called InventoryItems with entries like this:

{
  "Data": "021EC802 52025800 62008E4C (10010002) 00071C0E",
  "Description": "Kabanda LV200 5.94/0.88/0.98/195.98 0% 7IQ PB:E (grey)",
  "Flags": 76,
  "ItemID": 268500994
},

For your use case, you'll probably want to look at the Data field. If you're not familiar with the PSO item format, you can find the relevant item codes in system/item-tables/names-v4.json, the entries of which correspond to the first few bytes in Data.

I probably won't be able to get the changes I mentioned above done very soon; work has been pretty busy these days. I'll try to get it done sometime this week or weekend though.

@insanemal
Copy link
Author

No rush man. Thanks for your replies and awesome software 😃

@fuzziqersoftware
Copy link
Owner

I've added the /y/shell-exec endpoint in the HTTP server (it's the only POST request; see the readme for details). Make sure to specify the Content-Type: application/json header in the request; I forget if I mentioned that elsewhere. I've also made the cc shell command skip permission checks, so anything that would require cheat mode or debug mode should work even if the client specified by on C-X ... doesn't have permissions. Let me know if this works for your use case, or if you find any issues with it.

@insanemal
Copy link
Author

insanemal commented Jan 13, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants