[RELEASE] [ESX] Loaf - Keysystem

Loaf - Key system (GitHub)

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.

15 Likes

Looking nice, I hope this project doesn’t get abandoned like other key projects. Keep up the good work!

2 Likes

Good job @Loaf-Scripts

1 Like

Nice release!

1 Like

This currently doesnt do anything to prevent the vehicle from being driven without a key correct?

1 Like

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.

1 Like

Nice to see you on here Loaf :slight_smile:

Fixed an issue with giving keys, new update on github

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"

1 Like

Buy it!

Support Loaf and his great work :slight_smile:
We´re using almost all of his scripts and are very happy with it!

Hey when I press use the key on housing nothing happens

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 :slight_smile:

If you have followed the guide, try disabling the distance check in the config or increasing the distance

1 Like

Neat!

1 Like

/e hug

1 Like

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)
1 Like

Indeed, thanks for letting me know – I will fix that asap.

1 Like

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.

@RitterKeule
My housing script already has this keysystem implemented, unless you are using an old leak :slight_smile:

well im not the server owner, I have to ask him if he bought it or not, i hope so :grimacing:

Thx for the quick answer

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

Thanks for all