I don't think there's a way to do a complex autocomplete based on the player argument.. but it's sounding familiar enough to me to defer that subject to Megiddo.
Otherwise, unless I'm mistaken, XGUI relies on the commands' autocomplete table to display available options, obviously. You can modify this table per client at any time by accessing it through a method like this:
ULib.cmds.translatedCmds["ulx votemap"].args[2].completes = xgui.data.votemaps
(This is what XGUI uses to update the client's autocomplete when the votemaps change.)
The only problem here is hooking into when a player is selected in XGUI. You want to access this via the cmds tab, correct? *digs through code* oh man this code is a mess.. So I think there are two ways to go about this.
Method 1: Hook into XGUI's cmds moduleThe easiest and probably most hackish way to do it would be to run some code before XGUI builds the ArgsList panel (which gets called when a player or command without a playerarg is selected). You should be able to "override" this function and add your own code to it, something like this:
--Grab a reference to the XGUI commands module.
--Note: This will most likely be wrong! You should iterate through xgui.modules.tab to find the index where xgui.modules.tab[i].name == "cmds".
local cmdsModule = xgui.modules.tab[0].panel
local oldFunction = cmdsModule.buildArgsList
cmdsModule.buildArgsList = function( cmd )
if (cmd.cmd == "ulx takeitem")
--Set your code that updates the autocomplete table here.
--You can get a list of the selected players using cmdsModule.plist:GetSelected()
end
oldFunction( cmd )
end
Note: This is all clientside code, and should not affect other players.
I am also building this advice from memory and looking at the code- none of this has been tested and it's been a long time since worked with this portion of XGUIOne other thing to note, changing the autocomplete like this may impact the autocomplete feature of your command in the client's console- so you may want to consider resetting the completes to the full table after calling oldFunction( cmd ).
Method 2: Create your own XGUI module and/or custom menuThis part is probably excessive and is what you wanted to avoid doing, but there are five types of modules for XGUI:
- Tab modules (like the bans tab)
- Settings modules (Like the serverside settings or clientside settings tab)
- Gamemode modules (Sandbox tab, only shows up if playing a sandbox-enabled gamemode)
- Server Settings modules (ULX general settings, echos, etc-- the small panels on the "Serverside Settings" tab)
- Client Settings modules (Panels on the Clientside Settings tab)
Unfortunately, the only one that really fits this particular project would be a full Tab module or gamemode module, but that's probably going to be more real estate than you need (unless you have other point-shop related stuff you could put on there). Which leaves my recommendation to a custom menu, but it's not really integrated with XGUI.
I leave the decision on this up to you. Good luck, and let me know if you have more questions! (I'm 90% sure my above code won't work on first try lol)