(help)Global Variable is nil in client side

Ok so go back with :

currentTeam = “”

and try:

RegisterCommand('currentTeam', function()
    TriggerServerEvent('gw:currentTeamGet')
    Wait(100)
    currentTeam = currentTeam
    if currentTeam ~= nil then --just for debug
     print('test'..currentTeam)
    print("TEST")
   else  print("Not found")
 end
  
end)
1 Like

same thing, the print is now showing only test
so no currentTeam sadly

Bad debug lol

RegisterCommand('currentTeam', function()
    TriggerServerEvent('gw:currentTeamGet')
    Wait(100)
    if currentTeam ~= ''  then --just for debug
     print(currentTeam)
   )
   else  print("Not found")
 end
  
end)
1 Like

The Event is beeing called.
But no message no print.
That tells us, currentTeam has a value but we can’t read it…

with currentTeam = {} I get as output table:0000003435
a hex code

Can try:

RegisterCommand('currentTeam', function()
    TriggerServerEvent('gw:currentTeamGet')
    Wait(100)
    team = tostsring(currentTeam)
 if currentTeam ~= ''  then --just for debug
     print(team)
   )
   else  print("Not found")
 end
  
end)

1 Like

Oh, I had the old debug my bad.
now

RegisterCommand('currentTeam', function()
    TriggerServerEvent('gw:currentTeamGet')
    Wait(1000)
    if currentTeam ~= '' then --just for debug
        print(currentTeam)
    else  
        print("Not found")
    end
end)

I get Not Found

RegisterCommand('currentTeam', function()
    TriggerServerEvent('gw:currentTeamGet')
    Wait(100)
    team = tostsring(currentTeam)
     print(team)
end)

1 Like
RegisterCommand('currentTeam', function()
    TriggerServerEvent('gw:currentTeamGet')
    Wait(100)
    team = tostring(currentTeam)
    if currentTeam ~= '' then --just for debug
        print(team)
    else  
        print("Not found")
    end
end)

Not Found :frowning:

i’ve edit ^^

1 Like

still not showing.
But I found a way.

currentTeam = ''
local cteam

-- Event to get variable currentTeam in client side
RegisterNetEvent('gw:currentTeamSend')
AddEventHandler('gw:currentTeamSend', function(currentTeam)
    cteam = currentTeam
end)

RegisterCommand('currentTeam', function()
    TriggerServerEvent('gw:currentTeamGet')
    Wait(100)
    -- team = tostring(currentTeam)
    print(cteam)
end)

With cteam its working lol

Lol this for sure a stupid error of me :grin:.
Now i remember.I’ve already encountered this problem,but there focused on the registercommand fonction and miss this.What an asshole :rofl: .

1 Like

I don’t think that “local cteam” is useful.
Every thing’s work like you want?

Yeah it works from now on.
I don’t think either its not useful but can’t do anything else ^^

Alright enjoy!