[Help] Need help with getting the data from this table

So idk how to get if they are a owner in the database someone please help

Execute thread

Blockquote MySQL.Async.execute(
‘INSERT INTO zoneowners (owner, label) VALUES (@owner, @label)’,
{
[‘@owner’] = xPlayer.identifier,
}, function(rowsChanged)
end
)

Well that’s not getting anything. its inserting into zoneowners…

yeah i need to know how to get the same data

Like how do i create a check if they are in there as owner is what i need to do i tried but could get it

MySQL.Async.fetchAll("SELECT * FROM zoneowners WHERE owner = @owner", {['@owner'] = xPlayer.identifier}, function(results)
    print(tostring(json.encode(results)))
end)

ill give that a shot thanks :smiley:

I just updated the above code so you can actually see the data printed. Make sure to try the new one.

alright updating now

Then if i wanted it so only if they are owner would i make it results == (player id) then like that?

Well what does the label row hold on the database?

i have it as a null right now cause i cant figure out how to get the config.Zones.label to get put there

well if you are trying to find out what zone they are ownership of you have to do this

MySQL.Async.fetchAll("SELECT * FROM zoneowners WHERE owner = @owner", {['@owner'] = xPlayer.identifier, ['@label'] = labelnameorwhatever}, function(results)
    print(tostring(json.encode(results)))
end)

The first method returns ALL zones they are ownership of.

ok let me try that
20 characters

Oh lol i forgot i removed the labels in the database. guees i dont need that
:smiley:

So would this work

if results == xPlayer then
captured = true
end

this is what i put

RegisterServerEvent(‘Check’)
AddEventHandler(‘Check’, function ()
local xPlayer = ESX.GetPlayerFromId(source)

MySQL.Async.fetchAll("SELECT * FROM zoneowners WHERE owner = @owner", {['@owner'] = xPlayer.identifier}, function(results)
   if results == xPlayer then
    captured = true
   end
end)

end)

doesnt work tho

Do you have multiple zones. Because that will not work if you have multiple zones.

yeah i use esx drugs so like all those zones bui i cant figure out how to get the currentzones label

You need to figure that out before continuing :smiley: otherwise the code wont do what its supposed to.

well so i cant just remove that from the equation? like it just sets owner?

No because it doesn’t know what zone hes ownership of…