danielbsantanna

  • Content Count

    3
  • Joined

  • Last visited

Community Reputation

1 Neutral

About danielbsantanna

  • Rank
    Junior Member
...
  1. I Just find a workaround, maybe the correct way to do this. It's just a exemple code. local TheNet = GLOBAL.TheNet local SERVER_SIDE, DEDICATED_SIDE, CLIENT_SIDE, ONLY_CLIENT_SIDE if TheNet:GetIsServer() then SERVER_SIDE = true if TheNet:IsDedicated() then DEDICATED_SIDE = true CLIENT_SIDE = false else CLIENT_SIDE = true DEDICATED_SIDE = false end elseif TheNet:GetIsClient() then SERVER_SIDE = false CLIENT_SIDE = true ONLY_CLIENT_SIDE = true end local OnPlayerSpawn = function(player) player.prev_onNewSpawnClient = player.OnNewSpawn player.prev_OnNewSpawn = player.OnNewSpawn player.OnNewSpawn = function() player.myNetVarFirstSpawn:set(true) DoStartStuff(player) if player.prev_OnNewSpawn ~= nil then player:prev_OnNewSpawn() player.prev_OnNewSpawn = nil end end end local function OnPlayerPostInit(player) OnPlayerSpawn(player) player.myNetVarFirstSpawn = _G.net_bool(player.GUID, "PlayerFirstSpawn", "PlayerFirstSpawnDirty") -- true or false player.myNetVarFirstSpawn:set(false) if CLIENT_SIDE then player:ListenForEvent("PlayerFirstSpawnDirty", function(player) if player.myNetVarFirstSpawn:value() then DoStartStuff(player) end end) end end AddPlayerPostInit(OnPlayerPostInit) How to set the topic as solved?
  2. I didn't post the complete code, but I already got this. My problem is how to check if is first spawn for Client_Side too, because OnNewSpawn Function is only executing when is server side. local TheNet = GLOBAL.TheNet local SERVER_SIDE, DEDICATED_SIDE, CLIENT_SIDE, ONLY_CLIENT_SIDE if TheNet:GetIsServer() then SERVER_SIDE = true if TheNet:IsDedicated() then DEDICATED_SIDE = true CLIENT_SIDE = false else CLIENT_SIDE = true DEDICATED_SIDE = false end elseif TheNet:GetIsClient() then SERVER_SIDE = false CLIENT_SIDE = true ONLY_CLIENT_SIDE = true end
  3. I'm trying to check if is player first spawn for do some things for Client and server. I already can do for Server, but I don't know how to do this for client. I think that when the function is executed by the server, it will not be executed by the client. When Cliente_Side is outslide OnNewSpawn function, is executed every time a player join server. English is not my main language so may have translation erros. My code looks like: local OnPlayerSpawn = function(player) player.prev_OnNewSpawn = player.OnNewSpawn player.OnNewSpawn = function() if SERVER_SIDE then --do Things in server_side end if CLIENT_SIDE then --do Things in client_side end if player.prev_OnNewSpawn ~= nil then player:prev_OnNewSpawn() player.prev_OnNewSpawn = nil end end end local function OnPlayerPostInit(player) OnPlayerSpawn(player) end AddPlayerPostInit(OnPlayerPostInit) This must be something simple, but I'm missing it.