Hi,
I’m struggling with a callback. Could someone help me ? I don’t see what’s wrong
server.lua :
TriggerClientEvent('blabla', source, '1+1=10', function(can)
if can then
print('Could')
else
print("Couldn't")
end
end)
client.lua :
RegisterNetEvent('blabla')
AddEventHandler('blabla', function(str, callback)
print(str)
callback(false)
end)
1 Like
You can’t do a callback over an event going from server to the client and back. It just needs to be a 2 way street of events. Trigger client event the trigger a server event back to the server from the client.
That’s a lot of back and forth I was hoping for something simpler
Anyway thank you !
I mean you can make something that kinda simulates it like ESX did but you need to write the code manually to make that simulate well.
You can TriggerServerEvent() from clientside.
Give some input, let the server does his job and TriggerClientEvent() from Serverside.
There you can give the Infos from server to the Client.
Thats the easiest way to communicate between server and client
mikou
April 24, 2019, 6:37pm
6
You can take a look at this:
Hey, i got a global variable called currentTeam
If the player joins (serverside), it does
currentTeam = 'groove' --default team
TriggerEvent('gw:teamGet', source, function(team)
if team == 'groove' then
currentTeam = 'groove'
elseif team == 'ballas' then
currentTeam = 'ballas'
else
currentTeam = currentTeam
end
end)
that works fine!
but If I call the variable in client side
RegisterCommand('currentTeam', function()
…