_Marco_ Posted November 5, 2021 Share Posted November 5, 2021 Hi . How To Put All The Commands Inside A Resource In The Database So That None Of Them Are Duplicates Example : Resource Command = /goto . /mechanic . /vehspawn Create Column Whit ALTER TABLE Give Me Example Code Link to comment
The_GTA Posted November 5, 2021 Share Posted November 5, 2021 (edited) Hello _Marco_, since we are not a SQL support forums you can search on other domains if you want a solution based on SQL only. What you are asking though can be achieved inside of Lua. I am going to assume that you habe full access to the resource and want to modify it to provide a /listcommands feature. I am also going to assume that every command that you are interested in is registered during resource start-up. In that case you can make use of meta.xml load order to hook the addCommandHandler function before it is executed and fetch all of these commands into an internal list. For example... meta.xml: <meta> <script src="hook.lua" type="client" /> <script src="client1.lua" type="client" /> ... <script src="clientn.lua" type="client" /> </meta> hook.lua: local _addCommandHandler = addCommandHandler; local cmdlist = {}; function addCommandHandler(cmdname, ...) cmdlist[cmdname] = true; return _addCommandHandler(cmdname, ...); end -- SERVERSIDE. _addCommandHandler("listcommands", function(player) outputChatBox("--- cmdlist ---", player); for m,n in pairs(cmdlist) do outputChatBox("* " .. m); end end ); Can you follow me this far? Now you have a cmdlist variable which contains a table that contains unique command names as table keys that can be retrieved using pairs for-loop. The next step would be to push all the data to a SQL database at resource stop. Good luck! Edited November 5, 2021 by The_GTA 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now