Need help, server export not working

help
export

#1

Hello, I explained to you my problem, I want to use a server function of my script everywhere, since I decided to export, my server_export does not work it,
A little help ??

exports[‘entreprise_jobs_hub’]:refrech_jobs_hub();

__resource.lua


resource_manifest_version '77731fab-63ca-442c-a67b-abc70f28dfa5'

ui_page 'html/ui.html'

files {
    'html/ui.html',

    'html/picture_jobs/brasseur.png',
    'html/picture_jobs/ambulancier.png',
    'html/picture_jobs/ceralier.png',
    'html/picture_jobs/job-icon.png',
    'html/picture_jobs/journaliste.png',
    'html/picture_jobs/poleemploi.png',
    'html/picture_jobs/police.png',
    'html/picture_jobs/sherif.png',
    'html/picture_jobs/president.png',
    'html/picture_jobs/taxi.png',
    'html/picture_jobs/mecano.png',

    'font/pricedown.ttf'
}


client_script 'client/client.lua'
server_script 'server/server.lua'


server_script '@mysql-async/lib/MySQL.lua'

server_export {
    'refrech_jobs_hub'
}

server.lua


function refrech_jobs_hub()
   TriggerEvent('entreprise.refesh.status')
end

RegisterServerEvent('entreprise.refesh.status')
AddEventHandler('entreprise.refesh.status', function()
    local source = source
    local playersSteamID = exports['anti_essential_core']:getIdentifier(source)
    local PlayerInfoGetJobsID = MySQL.Sync.fetchAll('SELECT * FROM users WHERE identifier = @identifier', { ['@identifier'] = playersSteamID })
    local GetEntrepriseName = MySQL.Sync.fetchAll('SELECT * FROM entreprise WHERE id = @entreprise_id', { ['@entreprise_id'] = PlayerInfoGetJobsID[1].entreprise })
    TriggerClientEvent('jobssystem:updateJob', source, GetEntrepriseName[1].custome_name, PlayerInfoGetJobsID[1].grade, GetEntrepriseName[1].entreprise_photo)
end)

Erreur :


#2

That needs to be server_exports


#3

Thank you for the help ! My this still does not work: c

__resource.lua

resource_manifest_version '77731fab-63ca-442c-a67b-abc70f28dfa5'

ui_page ('html/ui.html')

files ({
    'html/ui.html',

    'html/picture_jobs/brasseur.png',
    'html/picture_jobs/ambulancier.png',
    'html/picture_jobs/ceralier.png',
    'html/picture_jobs/job-icon.png',
    'html/picture_jobs/journaliste.png',
    'html/picture_jobs/poleemploi.png',
    'html/picture_jobs/police.png',
    'html/picture_jobs/sherif.png',
    'html/picture_jobs/president.png',
    'html/picture_jobs/taxi.png',
    'html/picture_jobs/mecano.png',

    'font/pricedown.ttf'
})


server_script '@mysql-async/lib/MySQL.lua'


client_script 'client/client.lua'
server_script 'server/server.lua'

server_exports {
    'refrech_jobs_hub'
}


#4

Are you trying to call a server export from the client? I don’t think you are able to do that. You will need to use TriggerServerEvent() for a registered event on the server.


#5

Yes, I tried this still does not work, I change my function refrech_jobs_hub, my this does not work always I show you the changes! if it can help you help me

__ressource.lua

resource_manifest_version '77731fab-63ca-442c-a67b-abc70f28dfa5'

ui_page ('html/ui.html')

files ({
    'html/ui.html',

    'html/picture_jobs/brasseur.png',
    'html/picture_jobs/ambulancier.png',
    'html/picture_jobs/ceralier.png',
    'html/picture_jobs/job-icon.png',
    'html/picture_jobs/journaliste.png',
    'html/picture_jobs/poleemploi.png',
    'html/picture_jobs/police.png',
    'html/picture_jobs/sherif.png',
    'html/picture_jobs/president.png',
    'html/picture_jobs/taxi.png',
    'html/picture_jobs/mecano.png',

    'font/pricedown.ttf'
})


server_script '@mysql-async/lib/MySQL.lua'


client_script 'client/client.lua'
server_script 'server/server.lua'

server_exports {
    'refrech_jobs_hub'
}

server.lua


function refrech_jobs_hub(source)
    local source = source
    local playersSteamID = exports['anti_essential_core']:getIdentifier(source)
    local PlayerInfoGetJobsID = MySQL.Sync.fetchAll('SELECT * FROM users WHERE identifier = @identifier', { ['@identifier'] = playersSteamID })
    local GetEntrepriseName = MySQL.Sync.fetchAll('SELECT * FROM entreprise WHERE id = @entreprise_id', { ['@entreprise_id'] = PlayerInfoGetJobsID[1].entreprise })
    TriggerClientEvent('jobssystem:updateJob', source, GetEntrepriseName[1].custome_name, PlayerInfoGetJobsID[1].grade, GetEntrepriseName[1].entreprise_photo)
end

RegisterServerEvent('entreprise.refesh.status')
AddEventHandler('entreprise.refesh.status', function()
    local source = source
    local playersSteamID = exports['anti_essential_core']:getIdentifier(source)
    local PlayerInfoGetJobsID = MySQL.Sync.fetchAll('SELECT * FROM users WHERE identifier = @identifier', { ['@identifier'] = playersSteamID })
    local GetEntrepriseName = MySQL.Sync.fetchAll('SELECT * FROM entreprise WHERE id = @entreprise_id', { ['@entreprise_id'] = PlayerInfoGetJobsID[1].entreprise })
    TriggerClientEvent('jobssystem:updateJob', source, GetEntrepriseName[1].custome_name, PlayerInfoGetJobsID[1].grade, GetEntrepriseName[1].entreprise_photo)
end)

client.lua

RegisterNetEvent('jobssystem:updateJob')
AddEventHandler('jobssystem:updateJob', function(nameJob, jobs_poste, jobicon)
    local id = PlayerId()
    local playerName = GetPlayerName(id)
    SendNUIMessage({
        updateJob = true,
        job = nameJob,
        job_poste = jobs_poste,
        jobicon = jobicon,
        player = playerName
    })
end)



Citizen.CreateThread(function()
    while true do
        Citizen.Wait(6000)
         print('test_called export')
         exports['entreprise_jobs_hub']:refrech_jobs_hub(source);
    end
end)

#6

You cannot call a server export from the client.

exports[‘entreprise_jobs_hub’]:refrech_jobs_hub(source);

Do not use that ^

Do this:

TriggerServerEvent("entreprise.refesh.status")

#7

I am really sorry xd I did not see my problem despite the ease to find it, I make an export in the client file for esseay if the export worked, problem solved :heart_eyes: