====== Lớp Người Chơi ====== Lớp cho giao diện Người Chơi [[developer_center:developer_editor:script|Trở về trang trước]] ------ ==== Cách Viết Sự Kiện ===== ScriptSupportEvent:registerEvent([[Tên Sự Kiện]],tên_hàm_thực_hiện) ==== Ví Dụ ==== function BuffAdded(event) local playerid , buffid , bufflvl = event.eventobjid , event.buffid , event.bufflvl end ScriptSupportEvent:registerEvent([[Player.AddBuff]],BuffAdded) ===== Danh Sách Sự Kiện ===== ^ Tên Sự Kiện ^ Giá Trị Nhận Được ^ Miêu Tả ^ | Game.AnyPlayer.Defeat | eventobjid: kiểu số, shortix,x,y,z |Bất kỳ người chơi bị đánh bại| | Game.AnyPlayer.EnterGame | eventobjid: kiểu số, shortix,x,y,z |Bất kỳ người chơi nào vào trò chơi| | Game.AnyPlayer.LeaveGame | eventobjid: kiểu số, shortix,x,y,z |Bất kỳ người chơi nào rời khỏi trò chơi| | Game.AnyPlayer.Victory | eventobjid: kiểu số, shortix,x,y,z |Bất kỳ người chơi nào thắng trò chơi| | Player.AddBuff | eventobjid: kiểu số, buffid: kiểu số, bufflvl: kiểu số |Người chơi có hiệu ứng trạng thái| | Player.AddItem | eventobjid: kiểu số, itemid: kiểu số, itemnum: kiểu số |Người chơi nhận được một vật phẩm| | Player.AreaIn | eventobjid: kiểu số, areaid: kiểu số |Người chơi bước vào khu vực| | Player.AreaOut | eventobjid: kiểu số, areaid: kiểu số |Người chơi rời khỏi khu vực| | Player.AttackHit | eventobjid: kiểu số, targetactorid: kiểu số |Người chơi tấn công mục tiêu| | Player.Attack | eventobjid: kiểu số, shortix: kiểu số, x: kiểu số, y: kiểu số, z: kiểu số |Người chơi tấn công| | Player.BackPackChange | eventobjid: kiểu số, itemid: kiểu số, itemnum: kiểu số, itemix: kiểu số |Balo thay đổi| | Player.BeHurt | eventobjid: kiểu số, hurtlv: kiểu số |Người chơi nhận thiệt hại| | Player.ChangeAttr | eventobjid: kiểu số, shortix: kiểu số, playerattr: kiểu số, playerattrval: kiểu số, x: kiểu số, y: kiểu số, z: kiểu số |Thay đổi thuộc tính người chơi| | Player.ClickActor | eventobjid: kiểu số, toobjid : kiểu số, targetactorid: kiểu số |Người chơi nhấp vào vật thể| | Player.ClickBlock | eventobjid: kiểu số, blockid: kiểu số, x: kiểu số, y: kiểu số, z: kiểu số |Người chơi nhấp vào một khối| | Player.Collide | eventobjid: kiểu số, toobjid: kiểu số |Người chơi va chạm với người chơi/mob khác| | Player.ConsumeItem | eventobjid: kiểu số, itemid: kiểu số, itemnum: kiểu số |Người chơi tiêu thụ một vật phẩm| | Player.DamageActor | eventobjid: kiểu số, toobjid: kiểu số, targetactorid: kiểu số, hurtlv: kiểu số |Người chơi gây ra thiệt hại cho mục tiêu| | Player.DefeatActor | eventobjid: kiểu số, toobjid: kiểu số, targetactorid: kiểu số |Người chơi đánh bại mục tiêu| | Player.Die | eventobjid: kiểu số, shortix: kiểu số, x: kiểu số, y: kiểu số, z: kiểu số |Người chơi chết| | Player.DiscardItem | eventobjid: kiểu số, itemid: kiểu số, itemnum: kiểu số, toobjid: kiểu số |Người chơi loại bỏ một vật phẩm| | Player.DismountActor | eventobjid: kiểu số, targetactorid: kiểu số |Người dừng cưỡi một vật thể| | Player.EquipChange | eventobjid: kiểu số, itemid: kiểu số, itemnum: kiểu số, itemix: kiểu số |Thay đổi trang bị| | Player.EquipOff | eventobjid: kiểu số, itemid: kiểu số, itemnum: kiểu số, itemix: kiểu số |Người chơi cởi trang bị| | Player.EquipOn | eventobjid: kiểu số, itemid: kiểu số, itemnum: kiểu số, itemix: kiểu số |Người chơi mặc một trang bị | | Player.InputContent | eventobjid: kiểu số, content: string |Người chơi nhập một chuỗi| | Player.InputKeyDown | eventobjid: kiểu số, vkey: kiểu số |Người chơi nhấn một phím| | Player.InputKeyOnPress | eventobjid: kiểu số, vkey: kiểu số |Người chơi nhấn từ lâu| | Player.InputKeyUp | eventobjid: kiểu số, vkey: kiểu số |Người chơi thả một phím| | Player.LevelModelUpgrade | eventobjid: kiểu số |Thay đổi cấp độ của người chơi| | Player.MotionStateChange | eventobjid: kiểu số, playermotion: kiểu số |Trạng thái chuyển động của người chơi thay đổi| | Player.MountActor | eventobjid: kiểu số, targetactorid: kiểu số |Người chơi cưỡi vật thể| | Player.MoveOneBlockSize | eventobjid: kiểu số, shortix: kiểu số, x: kiểu số, y: kiểu số, z: kiểu số |Người chơi di chuyển một khối| | Player.NewInputContent | eventobjid: kiểu số, content: string |Người chơi nhập tin nhắn| | Player.PickUpItem | eventobjid: kiểu số, toobjid: kiểu số, itemid: kiểu số, itemnum: kiểu số |Người chơi nhặt một vật phẩm| | Player.PlayAction | eventobjid: kiểu số, act: kiểu số |Người chơi thực hiện một Emote/Hành động| | Player.RemoveBuff | eventobjid: kiểu số, buffid: kiểu số, bufflvl: kiểu số |Người chơi bị mất hiệu ứng trạng thái cụ thể| | Player.Revive | eventobjid: kiểu số, shortix: kiểu số, x: kiểu số, y: kiểu số, z: kiểu số |Người chơi hồi sinh| | Player.SelectShortcut | eventobjid: kiểu số, itemid: kiểu số, itemnum: kiểu số |Lựa chọn thanh phím tắt| | Player.ShortcutChange | eventobjid: kiểu số, itemid: kiểu số, itemnum: kiểu số, itemix: kiểu số |Thay đổi thanh công cụ| | Player.UseGiftPack | eventobjid: kiểu số, itemid: kiểu số, itemnum: kiểu số |Người chơi sử dụng gói quà tặng| | Player.UseItem | eventobjid: kiểu số, itemid: kiểu số, itemnum: kiểu số, itemix: kiểu số |Người chơi sử dụng một vật phẩm| ===== Danh Sách API ===== ^ API ^ Danh Sách API ^ Miêu Tả ^ | Player:getAttr(objid: kiểu số, attrtype: kiểu số) | ErrorCode.OK, value: kiểu số |Nhận thuộc tính người chơi| | Player:setAttr(objid: kiểu số, attrtype: kiểu số, val: kiểu số) | ErrorCode.OK |Cài đặt thuộc tính người chơi| | Player:getHostUin() | ErrorCode.OK, uin: kiểu số |Nhận uid chủ phòng| | Player:isMainPlayer(objid: kiểu số) | ErrorCode.OK, isMainPlayer: bool |Kiểm tra xem người chơi có phải là người chơi địa phương không| | Player:getMainPlayerUin() | ErrorCode.OK, uin: kiểu số |Nhận UIN của người chơi địa phương| | Player:getGameResults(objid: kiểu số) | ErrorCode.OK, value: kiểu số |Nhận kết quả trò chơi của người chơi| | Player:setGameResults(objid: kiểu số, result: kiểu bất kỳ) | ErrorCode.OK |Đặt kết quả trò chơi của người chơi| | Player:getGameScore(objid: kiểu số) | ErrorCode.OK, value: kiểu số |Nhận điểm trò chơi của người chơi| | Player:setGameScore(objid: kiểu số, score: kiểu số) | ErrorCode.OK |Đặt điểm trò chơi của người chơi| | Player:getGameRanking(objid: kiểu số) | ErrorCode.OK, rank: kiểu số |Nhận thứ hạng của người chơi| | Player:setGameRanking(objid: kiểu số, rank: kiểu số) | ErrorCode.OK |Đặt thứ hạng của người chơi| | Player:gainItems(objid: kiểu số, itemid: kiểu số, num: kiểu số, prioritytype: kiểu số) | ErrorCode.OK |Thêm đạo cụ cho người chơi| | Player:teleportHome(objid: kiểu số) | ErrorCode.OK |Dịch chuyển đến điểm sinh| | Player:getCurToolID(objid: kiểu số) | ErrorCode.OK, ret: kiểu sốs |Nhận ID mục hiện đang được giữ bởi người chơi| | Player:getNickname(objid: kiểu số) | ErrorCode.OK, name: kiểu chuỗi |Nhận biệt danh của người chơi| | Player:removeBackpackItem(objid: kiểu số, itemid: kiểu số, num: kiểu số) | ErrorCode.OK |Xóa các mục trong ba lô| | Player:getDieTimes(objid: kiểu số) | ErrorCode.OK, value: kiểu số |Nhận được số người chơi cái chết| | Player:getLeftLifeNum(objid: kiểu số) | ErrorCode.OK, value: kiểu số |Có được số lượng cuộc sống mà người chơi còn lại| | Player:setTeam(objid: kiểu số, teamid: kiểu số) | ErrorCode.OK |Đặt đội của người chơi| | Player:getTeam(objid: kiểu số) | ErrorCode.OK, value: kiểu số |Nhận đội của người chơi| | Player:getFoodLevel(objid: kiểu số) | ErrorCode.OK, value: kiểu số |Nhận cảm giác no hiện tại của người chơi| | Player:setFoodLevel(objid: kiểu số, foodLevel: kiểu số) | ErrorCode.OK |Đặt cảm giác no của người chơi| | Player:getCurShotcut(objid: kiểu số) | ErrorCode.OK, scutIdx: kiểu số |Nhận chỉ mục của phím thanh phím tắt hiện đang được sử dụng| | Player:onCurToolUsed(objid: kiểu số, num: kiểu số) | ErrorCode.OK |Đặt mức tiêu thụ các đạo cụ do người chơi hiện tại nắm giữ| | Player:setSkillCD(objid: kiểu số, itemid: kiểu số, cd: kiểu số) | ErrorCode.OK |Đặt thời gian hồi chiêu cho một kỹ năng| | Player:reviveToPos(objid: kiểu số, x: kiểu số, y: kiểu số, z: kiểu số) | ErrorCode.OK |Hồi sinh người chơi về điểm được chỉ định| | Player:setRevivePoint(objid: kiểu số, x: kiểu số, y: kiểu số, z: kiểu số) | ErrorCode.OK |Thay đổi vị trí của điểm phục sinh của người chơi| | Player:mountActor(playerid: kiểu số, objid: kiểu số, posindex: kiểu số) | ErrorCode.OK |Người chơi cưỡi trên núi| | Player:playAct(objid: kiểu số, actid: kiểu số) | ErrorCode.OK |Người chơi chơi hoạt hình| | Player:notifyGameInfo2Self(objid: kiểu số, info: kiểu chuỗi) | ErrorCode.OK |Hiển thị văn bản cửa sổ bay cho người chơi| | Player:useItem(objid: kiểu số, itemid: kiểu số, status: kiểu số, onshift: boolean) | ErrorCode.OK |Cho phép người chơi sử dụng các đạo cụ hiện tại| | Player:rotateCamera(objid: kiểu số, yaw: kiểu số, pitch: kiểu số) | ErrorCode.OK |Xoay camera của người chơi| | Player:changeViewMode(objid: kiểu số, viewmode: VIEWPORTTYPEkiểu số, islock: boolean) | ErrorCode.OK |Thay đổi chế độ phối cảnh của người chơi| | Player:setActionAttrState(objid: kiểu số, actionattr: PLAYERATTR_ENABLEkiểu số, switch: boolean) | ErrorCode.OK |Đặt trạng thái thuộc tính hành vi của người chơi| | Player:checkActionAttrState(objid: kiểu số, actionattr: PLAYERATTR_ENABLEkiểu số) | ErrorCode.OK |Nhận trạng thái của các thuộc tính đặc biệt của người chơi| | Player:isEquipByResID(objid: kiểu số, resid: kiểu số) | ErrorCode.OK |Kiểm tra xem người chơi có được trang bị một thiết bị không| | Player:setPosition(objid: kiểu số, x: kiểu số, y: kiểu số, z: kiểu số) | ErrorCode.OK |Đặt vị trí của người chơi| | Player:getAimPos(objid: kiểu số) | ErrorCode.OK, aimPos: kiểu bảng{x, y, z} |Nhận vị trí của người chơi crosshair| | Player:setItemAttAction(objid: kiểu số, itemid: kiểu số, attrtype: PLAYERATTR_ITEMkiểu số, switch: boolean) | ErrorCode.OK |Đặt thuộc tính đạo cụ của người chơi: Discard, Drop| | Player:playMusic(objid: kiểu số, musicId: kiểu số, volume: kiểu số, pitch: kiểu số, isLoop: bool) | ErrorCode.OK |Chơi nhạc nền cho người chơi| | Player:stopMusic(objid: kiểu số) | ErrorCode.OK |Ngừng chơi nhạc nền của người chơi| | Player:setGameWin(objid: kiểu số) | ErrorCode.OK |Làm cho người chơi giành chiến thắng trong trò chơi| | Player:openDevStore(objid: kiểu số) | ErrorCode.OK |Mở cửa hàng nhà phát triển| | Player:getPropsType(objid: kiểu số) | ErrorCode.OK, value: kiểu số |Nhận loại đạo cụ do người chơi nắm giữ| | Player:setCheckBoxScale(objid: kiểu số, range: kiểu số) | ErrorCode.OK |Đặt bán kính phát hiện các đối tượng rơi| | Player:openBoxByPos(objid: kiểu số, x: kiểu số, y: kiểu số, z: kiểu số) | ErrorCode.OK |Mở hộp có thể hoạt động tại vị trí được chỉ định| | Player:forceOpenBoxUI(objid: kiểu số, itemid: kiểu số) | ErrorCode.OK |Các khối có thể mở có thể mở như hộp công cụ| | Player:openDevGoodsBuyDialog(objid: kiểu số, devGoodsId: kiểu số, customDesc: kiểu chuỗi) | ErrorCode.OK |Mở cửa sổ bật lên của sản phẩm cửa hàng phát triển| | Player:changePlayerMoveType(objid: kiểu số, moveType: kiểu số) | ErrorCode.OK |Thay đổi cách người chơi di chuyển| | Player:setImmuneType(objid: kiểu số, immunetype: kiểu số, isadd: bool) | ErrorCode.OK |Đặt loại thiệt hại miễn dịch của người chơi| | Player:shakeCamera(objid: kiểu số, duration: kiểu số, power: kiểu số) | ErrorCode.OK |Lắc camera người chơi| | Player:stopShakeCamera(objid: kiểu số) | ErrorCode.OK |Ngừng lắc máy ảnh người chơi| | Player:playQQMusic(objid: kiểu số, musicId: kiểu số, volume: kiểu số, isLoop: boolean) | ErrorCode.OK |Người chơi chơi nhạc QQ| | Player:operateQQMusic(operate: kiểu số, objid: kiểu số) | ErrorCode.OK |Tạm dừng/Sơ yếu lý lịch/Dừng nhạc QQ của người chơi| | Player:OpenAppraiseView(objid: kiểu số) | ErrorCode.OK |Mở giao diện đánh giá (chỉ có thể được kích hoạt sau khi chơi trò chơi trong hơn 3 phút. CD mười phút sau khi kích hoạt)| | Player:OpenCollectionView(objid: kiểu số) | ErrorCode.OK |Mở giao diện thu thập (chỉ có thể được kích hoạt sau khi chơi trò chơi trong hơn 3 phút. CD mười phút sau khi kích hoạt)| | Player:IsMiniVip(objid: kiểu số) | ErrorCode.OK |Xác định xem đó có phải là thành viên nhỏ không| | Player:SendFriendApply(playerid: kiểu số, playerid2: kiểu số) | ErrorCode.OK |Gửi yêu cầu kết bạn| | Player:HasFriend(playerid: kiểu số, playerid2: kiểu số) | ErrorCode.OK |Xác định xem PlayerID có bạn bè playerid2 không| | Player:PlayActInHand(playerid: kiểu số, animid: kiểu số, playmode: kiểu số) | ErrorCode.OK |Người chơi giữ các đạo cụ thu nhỏ để chơi hoạt hình| | Player:openDevStoreNew(objid: kiểu số) | ErrorCode.OK |Người chơi mở cửa hàng nhà phát triển (chỉ dành cho nhà phát triển)| | Player:OpenBuiltinRank(objid: kiểu số, id: kiểu số) | ErrorCode.OK |Mở bảng xếp hạng tích hợp| | Player:HideBuiltinRank(objid: kiểu số) | ErrorCode.OK |Ẩn bảng xếp hạng tích hợp| | Player:openDevGoodsBuyDetailedDialog(objid: kiểu số, devGoodsId: kiểu số) | ErrorCode.OK |Mở trang chi tiết sản phẩm của cửa hàng nhà phát triển| | Player:setMobileVibrate(playerid: kiểu số, time: kiểu số, amplitude: kiểu số) | ErrorCode.OK |Điện thoại di động của người chơi rung động| | Player:SetCameraPosTransformBy(playerid: kiểu số, vec: kiểu bảng, animid: kiểu số, time: kiểu số) | ErrorCode.OK |Máy ảnh của người chơi thay đổi vị trí tương đối| | Player:SetCameraPosTransformTo(playerid: kiểu số, vec: kiểu bảng, animid: kiểu số, time: kiểu số) | ErrorCode.OK |Camera người chơi thay đổi vị trí| | Player:SetCameraRotTransformBy(playerid: kiểu số, vec: kiểu bảng, animid: kiểu số, time: kiểu số) | ErrorCode.OK |Góc tương đối của vòng quay camera của người chơi| | Player:SetCameraRotTransformTo(playerid: kiểu số, vec: kiểu bảng, animid: kiểu số, time: kiểu số) | ErrorCode.OK |Camera người chơi được xoay vào góc| | Player:SetCameraFovTransformBy(playerid: kiểu số, value: kiểu số, animid: kiểu số, time: kiểu số) | ErrorCode.OK |Giá trị tương đối của chuyển đổi FOV của máy ảnh người chơi| | Player:SetCameraFovTransformTo(playerid: kiểu số, value: kiểu số, animid: kiểu số, time: kiểu số) | ErrorCode.OK |Máy ảnh người chơi FOV được chuyển đổi thành giá trị| | Player:SetCameraAttrState(playerid: kiểu số, attr: kiểu số, enable: boolean) | ErrorCode.OK |Đặt công tắc cài đặt camera của người chơi| | Player:SetCameraRotMode(playerid: kiểu số, attr: kiểu số) | ErrorCode.OK |Đặt chế độ xoay camera của người chơi| | Player:SetCameraMountObj(playerid: kiểu số, objid: kiểu số) | ErrorCode.OK |Đặt camera của người chơi để gắn vào đối tượng| | Player:SetCameraMountPos(playerid: kiểu số, pos: kiểu bảng) | ErrorCode.OK |Đặt camera của người chơi vào vị trí| | Player:ResetCameraAttr(playerid: kiểu số) | ErrorCode.OK |Đặt lại camera người chơi|