If I wanted update a player’s dealer_repin metadata through mysql, how could I do that?
I can’t figure out the command since the metadata column under the players table is a large text property (looks like json)
The property lives:
database (db) > players (table) > medadata (column) > { "dealer_rep": 0 ... }
I was hoping I could’ve done something like:
Update metadata.dealerrep in players where id = 1234;
I also tried to achieve this with events in my qb-drugs resource:
QBCore.Commands.Add("changerep", Lang:t("info.increaserep_command_desc"), {{
amount = Lang:t("info.increaserep_command_help1_amount"),
help = Lang:t("info.increaserep_command_help1_help")
}}, true, function(source, args)
local desiredRep = args[1] -- this stores the users input
local ChangedData = {
amount = desiredRep
}
print( 'desiredRep: ', desiredRep) -- prints the user's input
print( 'ChangedData: ', ChangedData.amount) -- prints the same thing as the line above
-- TriggerClientEvent('qb-drugs:client:ChangeRep', source, desiredRep)
TriggerServerEvent('qb-drugs:server:ChangeRep', ChangedData)
end, "admin")
I’ve tried triggering the client event, but I have print logs in that function which never get printed - so I’m assuming it doesn’t make it there.
Below is my server event:
RegisterNetEvent('qb-drugs:server:ChangeRep', function(ChangedData)
local src = source
local Player = QBcore.Functions.GetPlayer(src) -- I'm pretty sure it errors out here
local curRep = Player.PlayerData.metadata["dealerrep"]
print( 'curRep: ', curRep)
print( 'ChangedData from SERVER: ', ChangedData)
-- if ChangedData.amount >= 0 and ChangedData.amount ~= curRep then
Player.PlayerFunctions.SetMetaData('dealerrep', ChangedData.amount)
TriggerClientEvent('QBCore:Notify', src, Lang:t("success.changed_dealer_reputation"), "success")
-- else
Player.PlayerFunctions.SetMetaData('dealerrep', curRep)
TriggerClientEvent('QBCore:Notify', src, Lang:t("error.dealer_rep_change_unsuccessful"), "error")
-- end
end)
Below is my in game error when running /changerep from the chat:
I’m just looking for the easiest way to update metadata. In this case, I’m looking to manually update the rep, so I can verify the different products available at a dealer reputation level.
