Insert (this is ok) but get (don't know how to do it) from SQL table and use it in client as variable

Environment questions

GTA V version: from Epic Games (current, latest)
Up to date: dunno what it means, 2021-04-03
Legit or Pirate copy: Legit from Epic Games
Purchased where - Steam/Rockstar Launcher/Epic: Epic Games
Windows version: W10 (latest, legit since bought a gaming laptop it was included)
Did you try to delete caches.xml (not cache/!) and try again? No
System specifications: Personal
CitizenFX crash zip file (‘Save information’ on a crash): No crashes
logs/CitizenFX_log files: No logs needed
.dmp files/report IDs: No files needed

If you can’t start the game at all

GTA V folder screenshot:
GTA V/update/x64/dlcpacks screenshot:
Filepath to FiveM folder:
FiveM client folder screenshot:
Which antivirus/firewall software are you using?
Did you try to disable/uninstall your Anti-virus?

Important parts

What is the issue you’re having? I don’t know how to get data from SQL table and make it as variable, use it in client side script as variables.

What are you trying to do? Same answer like first question

What have you tried already to fix the issue? Tried a lot… Nothing helped, no information from forum…

Error screenshot (if any): No screenshot

What did you do to get this issue?

What server did you get this issue on?


Additional comments

There is an example how I insert into SQL table each zombie id, model

CLIENT
allzombies = 0
zombiesmax = 100

Citizen.CreateThread(function()
while true do
Wait(1)
if #peds < zombiesmax and allzombies < zombiesmax then
allzombies = allzombies + 1

ped = CreatePed(4, GetHashKey(EntityModel), newX, newY, z - 3000, 0.0, true, true)

id = allzombies
model = GetHashKey(EntityModel)
TriggerServerEvent(‘create’, id, model) – this is the part where the insertion begins by triggering server event

SERVER
RegisterNetEvent(‘create’)
AddEventHandler(‘create’, function(id, model)
MySQL.Async.execute(“INSERT INTO zombie (id, model) VALUES (@id, @model)”, {[’@id’] = id, [’@model’] = model})
print("inserted ", id, model)
end)

With insertion is everything ok (above this whole text is ok, bottom text is the problem, don’t know how to get data and parse it in client as variable)
The thing I want is to make a script by which I can get id or other data from a zombie as variable in client and use it in if statement or other areas in client script, for example:

if id == 1 then

You will need to make an fetchAll request, then you create a server variable table. With that server table made you just need to send it to client. You can make every client request the server for this table on player loaded.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.