Git Product home page Git Product logo

esx-getsharedobject-fix's Introduction

Old esx:getSharedObject Event Fix

This repository contains a fix for the old esx:getSharedObject event for the new ESX Legacy versions. The esx:getSharedObject event was previously used to obtain a shared object in ESX resources, but it was deprecated in version 1.9 and replaced with a new export/import method instead.

However, some older resources still rely on the old esx:getSharedObject event and may break when updated to the latest version of ESX. This repository provides a fix for this issue by restoring the old esx:getSharedObject event so that older resources can continue to function as intended.

Installation

Open both the common.lua files located in the client and server folders. Replace both the Event Handlers at the top of both files with the following code:

AddEventHandler("esx:getSharedObject", function(cb)
    cb(ESX) 
end)

Usage

After installing the fix, restart your server, and you can use the esx:getSharedObject event as you would normally in older resources. For example, you can use the following code to get the ESX shared object in a client script:

ESX = nil

TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)

Citizen.CreateThread(function()
    while ESX == nil do
        Citizen.Wait(0)
    end
    -- Do something with the ESX shared object
end)

Contributing

If you encounter any issues or have suggestions for improving this fix, please feel free to open an issue or submit a pull request on GitHub.

License

This repository is licensed under the MIT License. See the LICENSE file for more information.

esx-getsharedobject-fix's People

Contributors

yiruzu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

esx-getsharedobject-fix's Issues

Errors while using

Hi,

I have changed the script accordingly, however, I am still getting these errors:
image

Any idea how to fix?

Doesnt work with any esx version..

i dont know what im doeing from, for me its not working with any esx version.

At first i replaced this code in es_extended/ (1.10.5)client/common.lua

exports("getSharedObject", function()
return ESX
end)

AddEventHandler("esx:getSharedObject", function()
local Invoke = GetInvokingResource()
print(("[^1ERROR^7] Resource ^5%s^7 Used the ^5getSharedObject^7 Event, this event ^1no longer exists!^7 Visit https://documentation.esx-framework.org/tutorials/tutorials-esx/sharedevent for how to fix!"):format(Invoke))
end)

To:
AddEventHandler("esx:getSharedObject", function(cb)
cb(ESX)
end)

And then in server/common.lua

from; AddEventHandler("esx:getSharedObject", function()
local Invoke = GetInvokingResource()
print(("[^1ERROR^7] Resource ^5%s^7 Used the ^5getSharedObject^7 Event, this event ^1no longer exists!^7 Visit https://documentation.esx-framework.org/tutorials/tutorials-esx/sharedevent for how to fix!"):format(Invoke))
end)

exports("getSharedObject", function()
return ESX
end)

To:
AddEventHandler("esx:getSharedObject", function(cb)
cb(ESX)
end)

And thats not working, still getting all the errors. I really need this as some of my "old" scripts dont work with the new implementation. A few one work with the new ESX = exports["es_extended"]:getSharedObject() but sadly some do not.
What am i doeing wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.