PDA

View Full Version : [KT] Thắc mắc về hàm di chuyển trong gmcard



djhtpro9x
15-03-14, 02:17 PM
function tbGMCard:DichuyenOnDialog()
local tbOpt = {
{"Đảo Tẩy Tủy", me.NewWorld, 255, 1652, 3389},
{"Hoàng Lăng", me.NewWorld, 1536, 1567, 3629},
};
Dialog:Say("Chọn nơi muốn đến!", tbOpt);
end

Đây là hàm dùng để teleport tới 1 nơi theo ý mình, trong hàm trên thì mình chỉ hiểu con số 255 và 1536 là id của map, còn các con số phía sau thì mình ko hiểu!
Giả dụ bây giờ muốn thêm hàm di chuyển tới Hậu Sơn Phục Ngưu trong Quân Doanh thì làm thế nào hả các bác?

accelan006
15-03-14, 02:22 PM
phía sau là tọa độ x y
.........................................

djhtpro9x
15-03-14, 02:24 PM
phía sau là tọa độ x y
.........................................

Lấy cái tọa độ đó ở đâu hả bạn? Hay tự chế ra?
Mình sợ add lung tung vào thì lỗi!!!

Sesshomaru
15-03-14, 02:27 PM
Xóa hết plugin,vào game bấm Alt+1

__Jie__
15-03-14, 02:38 PM
<b><font color=red>[Chỉ có thành viên mới xem link được. <a href="register.php"> Nhấp đây để đăng ký thành viên......</a>]</font></b>


local self = tbGetIdNpc;


local tbGetIdNpc = Map.tbGetIdNpc or {};
Map.tbGetIdNpc = tbGetIdNpc;
local CountThat = 0;


local szCmd = [=[
Map.tbGetIdNpc:GetIdNpcSwitch();
]=];
UiShortcutAlias:AddAlias("GM_C1", szCmd);


function tbGetIdNpc:GetIdNpcSwitch()
local nMyMapId, nMyPosX, nMyPosY = me.GetWorldPos();
me.Msg("Get ID Map<enter><color=green>Mã bản đồ: <color=orange>"..nMyMapId.."<color><enter>Mã tọa độ: <color=orange>"..nMyPosX.." / "..nMyPosY.."<color><enter>Mã màn hình: <color=orange>"..(nMyPosX*32).." / "..(nMyPosY*32));
local _, x, y = me.GetWorldPos();
local nMapId = me.nTemplateMapId
local szPosTexta = "";
local szPosText = "";
szPosText = string.format("<link=pos:%s(%d.%d),%d,%d,%d>",
GetMapNameFormId(nMapId), x / 8, y / 16, nMapId, x, y);
local tbAroundNpc = KNpc.GetAroundNpcList(me, 10);
local nMinLenSquare = math.huge;
local pNearNpc = nil;
for _, pNpc in ipairs(tbAroundNpc) do
if (pNpc.nKind ~= 1) then
local _, nNpcX, nNpcY = pNpc.GetWorldPos();
local nThisLenSquare = (nNpcX - x) ^ 2 + (nNpcY - y) ^ 2;
if (nThisLenSquare < nMinLenSquare) then
nMinLenSquare = nThisLenSquare;
pNearNpc = pNpc;
end
end
end
if (not pNearNpc) then
me.Msg("Get ID NPC<enter><color=green>Không tìm thấy Npc đứng gần");
return;
end
szPosText = string.format("<color=green>Mã NPC: <color=orange>%d - %s", pNearNpc.nTemplateId, pNearNpc.szName);
me.Msg("Get ID NPC<enter>"..szPosText);
end


function tbGetIdNpc:GetAroundNpcId(nTempId)
local tbAroundNpc = KNpc.GetAroundNpcList(me, 10);
for _, pNpc in ipairs(tbAroundNpc) do
if (pNpc.nTemplateId == nTempId) then
return pNpc.nIndex
end
end
return
end




Save thành 1 file lua bỏ vào thư mục Plugin bất kì phím tắt Alt + 1

djhtpro9x
15-03-14, 02:47 PM
<b><font color=red>[Chỉ có thành viên mới xem link được. <a href="register.php"> Nhấp đây để đăng ký thành viên......</a>]</font></b>


local self = tbGetIdNpc;


local tbGetIdNpc = Map.tbGetIdNpc or {};
Map.tbGetIdNpc = tbGetIdNpc;
local CountThat = 0;


local szCmd = [=[
Map.tbGetIdNpc:GetIdNpcSwitch();
]=];
UiShortcutAlias:AddAlias("GM_C1", szCmd);


function tbGetIdNpc:GetIdNpcSwitch()
local nMyMapId, nMyPosX, nMyPosY = me.GetWorldPos();
me.Msg("Get ID Map<enter><color=green>Mã bản đồ: <color=orange>"..nMyMapId.."<color><enter>Mã tọa độ: <color=orange>"..nMyPosX.." / "..nMyPosY.."<color><enter>Mã màn hình: <color=orange>"..(nMyPosX*32).." / "..(nMyPosY*32));
local _, x, y = me.GetWorldPos();
local nMapId = me.nTemplateMapId
local szPosTexta = "";
local szPosText = "";
szPosText = string.format("<link=pos:%s(%d.%d),%d,%d,%d>",
GetMapNameFormId(nMapId), x / 8, y / 16, nMapId, x, y);
local tbAroundNpc = KNpc.GetAroundNpcList(me, 10);
local nMinLenSquare = math.huge;
local pNearNpc = nil;
for _, pNpc in ipairs(tbAroundNpc) do
if (pNpc.nKind ~= 1) then
local _, nNpcX, nNpcY = pNpc.GetWorldPos();
local nThisLenSquare = (nNpcX - x) ^ 2 + (nNpcY - y) ^ 2;
if (nThisLenSquare < nMinLenSquare) then
nMinLenSquare = nThisLenSquare;
pNearNpc = pNpc;
end
end
end
if (not pNearNpc) then
me.Msg("Get ID NPC<enter><color=green>Không tìm thấy Npc đứng gần");
return;
end
szPosText = string.format("<color=green>Mã NPC: <color=orange>%d - %s", pNearNpc.nTemplateId, pNearNpc.szName);
me.Msg("Get ID NPC<enter>"..szPosText);
end


function tbGetIdNpc:GetAroundNpcId(nTempId)
local tbAroundNpc = KNpc.GetAroundNpcList(me, 10);
for _, pNpc in ipairs(tbAroundNpc) do
if (pNpc.nTemplateId == nTempId) then
return pNpc.nIndex
end
end
return
end




Save thành 1 file lua bỏ vào thư mục Plugin bất kì phím tắt Alt + 1
Tuyệt vời! Thank bác Toại! :))
Nhưng rất tiếc là ko làm đc!!