MapleStory Worlds/MSW IDE

재접속 시 가장 최근에 있던 맵으로 자동 이동하기

마루설아 2023. 10. 5. 20:11
void OnbeginPlay()
{
    if self.Entity ~= _UserService.LocalPlayer then return end

    local Player = _UserService.LocalPlayer
    local ID = Player.OwnerId

    self:LoadCurrentMap(Player, ID)
}

void OnMapEnter(Entity enteredMap)
{
    if self.Entity ~= _UserService.LocalPlayer then return end

    local Player = _UserService.LocalPlayer
    local ID = Player.OwnerId
    local Map = Player.CurrentMap.Name

    self:SaveCurrentMap(ID, Map)
}

-- server
void SaveCurrentMap(string id, string map)
{
    local UserDB = _DataStorageService:GetUserDataStorage(id)
    log(UserDB)

    UserDB:SetAsync("ID", id, nil)
    UserDB:SetAsync("Map", map, nil)
}

-- server
void LoadCurrentMap(Entity player, string id)
{
    local UserDB = _DataStorageService:GetUserDataStorage(id)

    local callBack = function(errorcode, key, value)	
        if value == nil then return "기본맵이름" end

        if key == "Map" then
            log(tostring(value))
            _TeleportService:TeleportToEntityPath(player, "/maps/" .. tostring(value) .. "/SpawnLocation")
        end 
    end 

    UserDB:GetAsync("Map", callBack)
}

'MapleStory Worlds > MSW IDE' 카테고리의 다른 글

문자열 분할 로직  (0) 2023.10.09
네임태그 RUID  (0) 2023.10.09
현재 접속중인 유저/맵 확인 로직  (0) 2023.09.16
버튼 컴포넌트 서버 실행  (0) 2023.09.16
특정 플레이어만 기능 주기  (0) 2023.09.12