📑Miscellaneous Guides
Extra guides and tools are listed here
Keymapping
What is Keymapping?
Allows you to take a REGISTERED command, using the RegisterCommand native, and apply a key binding to it. So instead of having to type in the slash command in the chat, you can just press a single key and execute it. This does NOT work with QBCore.Commands.Add.
example
RegisterKeyMapping('togglelocks', 'Toggle Vehicle Locks', 'keyboard', 'L')
The purpose of this system is so that players can completely customize their experience on the server and not be subjected to hard-coded key binds.
How to change a bind
Open your pause menu in game
Navigate to settings
Select settings —> keybinds
Select FiveM
Find the command you want to change the key for and select it.
Press the desired key you’d like and that’s it
Weapon License
By default only a citizen ID and drivers license is redeemable from City Hall. For a player to get a weapons license he needs to see a police officer who will do /grantlicense [id] weapon for that player to be "granted" access in City Hall.
Police can also do /revoke [id] [licenseType] to revoke a players ability to purchase a hard copy of the specified license. Revoking the license will not remove the hard copy from the players' inventory if they have one, it will simply remove the ability for them to purchase a new one.
If you would like the players to be granted by default look for this set of code in qb-core/server/player.lua
and change ["weapon"] = false to ["weapon"] = true
Once a player has been granted a weapons license they will be able to purchase weapons from gun stores that have the requiresLicense variable set to true. To restrict weapon sales to individuals with a weapons license see the example config below from qb-shops/config.lua
Onesync-infinity
Onesync-infinity should be enabled by default but if you ever need to enable it you would just put set onesync on in your server.cfg
Adapting Your Scripts
This is not an easy thing to describe because the code varies so you have to use your own judgement sometimes. With infinity enabled, there is what is called a "scope" and the client (player/you) has a "scope range". Now everything INSIDE this range the client will load via their machine but if something is OUTSIDE the scope then the client is not aware of it. Easiest example being if i am standing in the city and another player is standing in paleto, my machine has no idea that player is there at all. So if i had a teleport to player that was not setup for this then when i tried to go to them i would go to myself because i can not get the other players coords. Now the server DOES know that players coords so what we have to do as developers is gather that information from the server and send it to the client side. Also another big deal is obviously since we do not know about players outside of our scope, if we need a full list of players in the server then we need to get that info from the server as well.
Getting The Coords
This one is relatively simple, you can use the native GetEntityCoords on the server side and then pass that through an event or a callback. If you want more info on how to use this native then you can view that here
Getting the Players
To get a list of players on the server we must use either a native that is like this
Using the QB function you can do it like this
Spawning A Vehicle At A Distance
If you have a script that requires you to create a vehicle at a distance that is outside the infinity scope, you must use the code like below on the SERVER side
This will spawn the entity and callback the entity id which you can then use on the client side to check if the entity exists. It will NOT exist until a client(player) gets within range of it! While a client is NOT in range, the server “owns” the entity. So whenever a client gets into infinity range it then takes ownership of that entity and can be used by them. I know this one is a bit confusing but there’s no good way to explain it.
Database Connection
txAdmin does this automatically already but if needed then in your server.cfg put this and fill it in with the correct information. For the database wrapper oxmysql
Installation
Download the latest build of oxmysql (not the source code).
Extract the contents of the archive to your resources folder.
Start the resource near the top of your resources in your
server.cfg.If you have a lot of streamed assets, load them first to prevent timing out the connection.
Configuration
You can change the configuration settings by using convars inside your server.cfg. Reference the following for an idea of how to set your connection options. You must include one of the following lines, adjusted for your connection and database settings.
Certain special characters are reserved or blocked and may cause issues when used in your password. For more optional settings (such as multiple statements) you can reference pool.d.ts and connection.d.ts.
You can also add the following convars if you require extra information when testing queries.
Using the UI
Before using the UI first you have to make sure you have the mysql_ui convar set to true:
Also make sure that you have command ace permission access, then you should be able to use the mysql command in game to open up the UI and see your query data.
Server.cfg
Setting up your server.cfg is really simple and is already completed upon a successful txAdmin recipe install! You can also find additional information on server configuration files here. In case of a manual install then here's a template to use
GitHub Pull Request
Visit the resource you would like to propose changes on
Navigate to the exact file within that resource
Click on the pencil icon and you will be able to make edits to the code
Once you are satisfied with your edits, scroll down to the box labeled "Propose Changes"
Write a title and short description of what the changes are
Once that's filled out, press the green "Propose Changes" button
You will see a screen showing your edits compared to the existing code
If you are satisfied with the edits shown, press the green "Create Pull Request" button
Fill in the title and description if necessary
Click on the green "Create Pull Request" button and it's finished!
If you have email notifications enabled, you will get any updates on the pull request by email
Last updated
Was this helpful?
