oh ok let me work on this then
I couldnt freaking get it to work i gave up on that project thanks for the help
what do i have to put for this one i really hate this my sql stuff i cant figure it out
MySQL.Async.execute(
‘INSERT INTOowned_vehicles
(owner
,vehicle
) VALUES (@owner, @vehicle)’,
{
[‘@owner’] = xPlayer.identifier,
[‘@vehicle’] = json.encode(vehicleProps)
}, function(rowsChanged)
TriggerClientEvent(‘esx:showNotification’, _source, _U(‘vehicle’)… _(‘belongs’))
end
)
thats the creation code what would i need to fetch it this is the error i am getting with this code
code:
MySQL.Async.fetchAll(‘SELECT * FROM
owned_vehicles WHERE
owner,vehicle
VALUES @owner, @vehicle’,
{
[‘@owner’] = xPlayer.identifier,
[‘@vehicle’] = json.encode(vehicleProps)
}, function(results)
error:
You cant use commas and you dont have a space between whereowner
oops didnt notice that no space but i didnt know no commas so do i just remove the commas then?
https://pastebin.com/fwKgZj17
oh so that no space is just the format of the forum i do have one there
MySQL.Async.fetchAll("SELECT * FROM owned_vehicles WHERE owner = @owner and vehicle = @vehicle", {['@owner']=value, ['@vehicle']=value}, function(response) end)
Im on my phone so that isnt completed but you arent setting ut up right…
alright ill try and work with that thanks again and should it say response or result cause im trying to get the data thats in there?
Its just a variable name.
oh ok:D
(20 characters)
ok sweet got it to work minus it wont get the vehicle value but that might just be my code
I use MySQL alot.
but here is how I get all my player characters and how to get a single player character.
-- Gets ALL player characters
CharacterDB.GetPlayerCharacters = function(id)
local results = MySQL.Sync.fetchAll("SELECT * FROM characters WHERE license = @license", {['@license'] = ServerHelpers.FindPlayerIdentifier("license", id)})
return results
end
-- Gets Players Targeted Character
CharacterDB.GetPlayerCharacter = function(id, name, dob)
local results = MySQL.Sync.fetchAll("SELECT * FROM characters WHERE license = @license AND name = @name AND dob = @dob", {
['@license'] = ServerHelpers.FindPlayerIdentifier("license", id),
['@name'] = name,
['@dob'] = dob
})
if results[1] then
return results[1]
else
return false
end
end
Sweet that will help alot in the futrue but i think what the problem is vehicleprops is encoded on entry so do i have to like decode it xD?
yeah because when you encode it its a stringified JSON array.
you have to do json.encode(string) to actually use the array values.
oh ok so how could i check if that == the current vehicle props? idk why but i dont understand that encode stuff
well you aren’t thinking this through at all. You are trying to match like 50+ values… what if the car changes then guess what you can’t find that car anymore.
well my overall goal is to delete a duplicate entry in the database so if the vehicle == vehicle thats what i was thinking. and how can it just change cause the ls customs i have updates it per change i think
ye but how are you gonna save it over another vehicle if you change the vehicle then try to save the vehicle you just changed??
well isnt it only the properties not the vehicle its self the rims etc
I mean are you only gonna allow one car of the same type per player?