Question about multi-worlds
#14
(11-22-2015, 08:14 PM)Safwat Wrote: How stable is it to have multiple worlds at the moment?

@DrMasik could you provide a link to your problematic plugin?

10-20 minutes and i'm post the code.

(11-22-2015, 08:14 PM)Safwat Wrote: How stable is it to have multiple worlds at the moment?

@DrMasik could you provide a link to your problematic plugin?

Schema ( Player login -> Teleport to wrap world ->Teleport to selected world)
Move player to main world

function teleport_to_wrap_world(a_player)
    local func_name = "teleport_to_wrap_world()";

    -- Get spawn world
    local obj_world = cRoot:Get():GetWorld(g_spawn_world);

    -- Get free SIZO coordinates
    local SpawnX = 14;
    local SpawnZ = 4;

    -- Mark SIZO as beasy

    -- Calculate Y
    -- local ret1, SpawnY = obj_world:TryGetHeight(SpawnX, SpawnZ);

    -- Run function after chunks loaded
    local OnAllChunksAvailable = function()
      console_log(func_name .." -> chunks redy for player ID ".. a_player:GetUniqueID(), 1);

      -- Move to spawn world
      a_player:MoveToWorld(obj_world);

      -- Calculate Y
      local ret1, SpawnY = obj_world:TryGetHeight(SpawnX, SpawnZ);

      if ret1 then
        console_log(func_name .." -> SpawnY detected", 1);
      else
        console_log(func_name .." -> SpawnY NOT detected", 1);
      end

      console_log(func_name .." -> SpawnY =".. SpawnY, 1);

      -- Move to SIZO
--      a_player:TeleportToCoords(SpawnX, SpawnY, SpawnZ);

      -- Set clear player inventory
      -- a_player:GetInventory():Clear();

      -- Set game mode for the plater
      -- a_player:SetGameMode(0);
    end

    -- Prepare chunks for teleportation
    console_log(func_name .." -> prepare chunks", 1);
    obj_world:ChunkStay({{SpawnX/16, SpawnZ/16}}, OnChunkAvailable, OnAllChunksAvailable)

  return 0;
end

Next function called to teleport into some of worlds (survival1):
function teleport_to_survival1(a_player)

  local func_name = "teleport_to_survival1()";

  if not a_player then
    console_log(func_name .." -> a_player is nil", 2);
    return (-1);
  end

  local world_name = "survival1";

  local obj_world = cRoot:Get():GetWorld(world_name);

  if not obj_world then
    console_log(func_name .." -> do not find world ".. world_name, 2);
    return (-1);
  end

  -- Get player respawn point into current world
  local SpawnX = 1024;
  local SpawnZ = 1024;

  -- Get world default spawn points
  local WSpawnX = obj_world:GetSpawnX();
  local WSpawnZ = obj_world:GetSpawnZ();

  -- Save player ID
  local player_id = a_player:GetUniqueID();
  local player = g_players[player_id];

  -- Run function after chunks loaded
  local OnAllChunksAvailable = function()
    console_log(func_name .." -> chunks redy for player ID ".. a_player:GetUniqueID(), 1);

    local ret1, SpawnY = obj_world:TryGetHeight(SpawnX, SpawnZ);
    local ret2, WSpawnY = obj_world:TryGetHeight(WSpawnX, WSpawnZ);

    -- Move to spawn world
    a_player:MoveToWorld(obj_world);

    -- Teleport to coordinates
    a_player:TeleportToCoords(SpawnX, SpawnY, SpawnZ);

    -- Load player inventory
    player:LoadInventory(a_player);

    -- Load player experience
    player:LoadExperience(a_player);

    -- Set game mode for the plater
    a_player:SetGameMode(0);
  end

  -- Prepare chunks for teleportation
  console_log(func_name .." -> prepare chunks", 1);
  obj_world:ChunkStay({{WSpawnX/16, WSpawnZ/16}, {SpawnX/16, SpawnZ/16}}, OnChunkAvailable, OnAllChunksAvailable)

  return 0;
end
Reply
Thanks given by:


Messages In This Thread
Question about multi-worlds - by LogicParrot - 11-22-2015, 04:40 AM
RE: Question about multi-worlds - by NiLSPACE - 11-22-2015, 04:54 AM
RE: Question about multi-worlds - by LogicParrot - 11-22-2015, 04:57 AM
RE: Question about multi-worlds - by LogicParrot - 11-22-2015, 05:49 AM
RE: Question about multi-worlds - by NiLSPACE - 11-22-2015, 05:57 AM
RE: Question about multi-worlds - by LogicParrot - 11-22-2015, 06:19 AM
RE: Question about multi-worlds - by NiLSPACE - 11-22-2015, 06:41 AM
RE: Question about multi-worlds - by DrMasik - 11-22-2015, 07:09 AM
RE: Question about multi-worlds - by Schwertspize - 11-22-2015, 07:09 AM
RE: Question about multi-worlds - by DrMasik - 11-22-2015, 07:18 AM
RE: Question about multi-worlds - by worktycho - 11-22-2015, 09:57 AM
RE: Question about multi-worlds - by LogicParrot - 11-22-2015, 07:15 PM
RE: Question about multi-worlds - by LogicParrot - 11-22-2015, 08:14 PM
RE: Question about multi-worlds - by DrMasik - 11-22-2015, 08:23 PM
More questions - by LogicParrot - 11-24-2015, 04:59 PM
RE: Question about multi-worlds - by LogicParrot - 11-24-2015, 05:15 PM
RE: Question about multi-worlds - by DrMasik - 11-24-2015, 05:28 PM



Users browsing this thread: 4 Guest(s)