ESX (source) returning more than one player

Hi! I need some help with this, if anyone can throw a bit of light on it I’d be very thankful.

I have this garage script which allows users to have individual garages, for some reason whenever I buy a garage it is bought to other people in the server too, then if I sell it, it is also sold for them.

In the database everything is working properly, however I’ve found that the issue might be here, because in that “print(xPlayer…)” line I’m getting every identifier in the server, instead of getting the source player identifier only.
As I understand it, source returns the player object of the current player, so if it’s me who is buying something only my object should be returned, but it’s not happening that way.


ESX.RegisterServerCallback('thegarage:getPurchasedGarages',function(source, cb)
    local xPlayer = ESX.GetPlayerFromId(source)
    print('xPlayer ID in /scripts/server getPurchasedGarages: '.. xPlayer.getIdentifier())
    local takenGarages = {}
    MySQL.Async.fetchAll("SELECT garageID FROM theGarage WHERE garageID LIKE (SELECT garageID FROM users WHERE identifier=@identifier)",{['@identifier'] = xPlayer.getIdentifier() }, function(data)
        for k,v in pairs(data) do
            print('Garage ID inside FOR in getPurchasedGarages: ' .. v.garageID)
            table.insert(takenGarages,{id = v.garageID})
        end
        cb(takenGarages)
    end)
end)

I don’t undertand why this is happening since it’s written very similar to other scripts which actually work.

Thank you for your time and hope we can get to a fix, it doesn’t seem to make sense but it must make it somehow.