Type /keys in the chat to open a menu with all your keys. In the menu you can:
Give the key to a nearby player
Use the key
Remove the key
Update v0.2
Added “eventtype” & “eventname” when generating a key. This will trigger an event when the key is used, you can use this instead of “loaf_keysystem:setUsage”.
You can download the new update on GitHub.
Update v0.3
Major rewrite on the server code.
Remade the databse structure, combined the tables into one
Added “removeAllKeys” which removes all keys with specific key id
Users can now remove a key by their own
New update found on GitHub.
Update v0.3.1
Fixed issue when giving key to nearby player (previously gave all keys, now only gives selected key)
Added a notification for the user when a key has been generated
New update found on GitHub.
Update v1.0.0
Performance increased a lot, keys are now “cached” on the server and are not fetched from the database each time you want to get the keys.
Added exports HasKey & GetKeys, can be used both from the server & client side
Added event “loaf_keysystem:openMenu” which can be used by other scripts to open the menu
Added Config.Command, there you can change the command or disable command completely by setting it to false.
New update found on GitHub.
Features:
Set the callback for what should happen when you use a key (client)
Generate a key (server)
Get keys (server & client)
Remove a key (server)
Transfer key to another user (client)
If you find any issues, please report them to me on the forums, or open an issue on the GitHub repository.
This is not a car key resource, it is more an “API” made to be used by other resources. On its own, this resource does nothing, resource developers will have to implement it. You could make a resource using this to lock / unlock vehicles, and make it so you need a key to be able to start the car engine etc.
Hey Loaf! Thank you so much for releasing this script, I have a question. Trying to sync it so that when you sell a car you should get a key, use me from "esx_vehicleshop"
Hello! Did you follow the guide for using the script on older versions of ESX? If not, please follow the guide. If you are getting any errors, please send them and I will help you with them
If you have followed the guide, try disabling the distance check in the config or increasing the distance
I think you have an error in the mod, when deleting keys it did not work for me, I have checked the code and there is a variable “playerid” in line 234 which is not defined, eliminating it seems to work correctly:
Original:
RegisterNetEvent("removeKey")
AddEventHandler("removeKey", function(key, cb)
local src = source
if type(src) == "string" then -- if it was triggered by the server
if playerid and type(playerid) == "number" and key and type(key) == "string" then
RemoveKey(key)
if cb then cb(GetKeys(playerid)) end
end
end
end)
New:
RegisterNetEvent("removeKey")
AddEventHandler("removeKey", function(key, cb)
local src = source
if type(src) == "string" then -- if it was triggered by the server
if key and type(key) == "string" then
RemoveKey(key)
if cb then cb(GetKeys(playerid)) end
end
end
end)
Hey @Loaf-Scripts im new into this scripting/coding universe and wonder how i can implement the keysystem into your loaf_housing script, i read the README but I understand only a little bit. Anyone out there who can explain how to do it? I really wanna learn it.
I asked the owner and it probably was a leak, but now we bought both scripts and are really afraid of your work, only thing is a problem with the furniture, already posted the Problem at your housing script page in the forum