发新话题
打印

[提问] 求助一个弄了好久没弄出来的效果

求助一个弄了好久没弄出来的效果

复制内容到剪贴板
代码:
NL.RegPartyEvent(nil,"MyPartyEvent");
--Delegate.RegInit("Mypart_Init");

function MyPartyEvent(CharIndex, TargetCharIndex, Type)
        Char.SetWindowTalkedEvent(nil, "MypartM_WindowTalked", CharIndex);
        if(Type==0)then
                local msg = "\\n\\n"..Char.GetData(CharIndex,%对象_名字%).." 申请加入您的队伍。\\n\\n是否同意其入队申请呢?\\n\\n同意入队请选择『是』,拒绝入队请选择『否』。\\n"
                local addpartymsg = NLG.ShowWindowTalked(TargetCharIndex,CharIndex,%窗口_信息框%,%按钮_是否%,1,msg);
                --MypartM_sg(Mypart_index, TargetCharIndex);
                --MypartM_WindowTalked(CharIndex, TargetCharIndex,1,%按钮_否%,msg);
                return 0;
        end
        return 1;
end


-- function MypartM_sg(_NpcIndex,_PlayerIndex)


                -- local msg = "\\n\\n"..Char.GetData(_PlayerIndex,%对象_名字%).." 申请加入您的队伍。\\n\\n是否同意其入队申请呢?\\n\\n同意入队请选择『是』,拒绝入队请选择『否』。\\n"
                -- local addpartymsg = NLG.ShowWindowTalked(_PlayerIndex,_NpcIndex,%窗口_信息框%,%按钮_是否%,1,msg);
                -- return;
-- end


function MypartM_WindowTalked(_me,_tome,_seqno,_select,_data)
        --NLG.SystemMessage(_me,_select);
        if(tonumber(_seqno)==1 and tonumber(_select)==%按钮_否% and _data~="")then
                NLG.SystemMessage(_me,"队长拒绝了您的入队申请!");
                return;
        end
        --Char.JoinParty(_me,_tome);

        return;
end

-- function initmypart_Init(index)
        -- return 1;
-- end

-- function Mypart_create()
        -- if (Mypart_index == nil) then
                -- Mypart_index = NL.CreateNpc(nil, "initmypart_Init");
                -- Char.SetData(Mypart_index,%对象_形象%,10414);
                -- Char.SetData(Mypart_index,%对象_原形%,10414);
                -- Char.SetData(Mypart_index,%对象_X%,18);
                -- Char.SetData(Mypart_index,%对象_Y%,1);
                -- Char.SetData(Mypart_index,%对象_地图%,777);
                -- Char.SetData(Mypart_index,%对象_方向%,4);
                -- Char.SetData(Mypart_index,%对象_名字%,"组队离队NPC");
                -- NLG.UpChar(Mypart_index);
                ----Char.SetTalkedEvent(nil, "MypartM_sg", Mypart_index);
                -- Char.SetWindowTalkedEvent(nil, "MypartM_WindowTalked", Mypart_index);
        -- end
-- end
-- function Mypart_Init()
        -- Mypart_create();
       
-- end
就是点组队后,队长会弹出是否同意组队的对话框,但是,我弄了好久没解决如何触发队长的选择,用npc的方式触发失败,至今没解决,希望知道的帮忙解决下啊。截图在我另一个帖子有发过的。

TOP

回复 阁楼 的帖子

剛想想 因該是寫的順序 跟對象錯亂  我讀到後面已經分不出哪個參數是哪個參數妖城在线论坛1 [  l& p$ p2 n' i& {4 J
本來想說可以用 全域變數驗證 可是我在上班 沒辦法測試XD妖城在线论坛# ?/ Y* ~! Q+ M1 E. F! X, K
9 \# \4 Z4 V$ I' H: A
你看這樣 可不可以
3 F2 F# X: K" E7 H) m+ G: c9 P—魔力私服,魔力宝贝私服技术,DELPHI编程,魔力寶貝, 魔力宝贝, 크로스게이트,クロスゲート
  R% V; [' O) l; H8 ]大概看一下,不能實際測試=A=
复制内容到剪贴板
代码:
---產生組隊處發    自己  對方  自己鍵值



function MyPartyEvent(CharIndex, TargetCharIndex, Type)

--如果自己傳達 +入組隊
        if(Type==0)then


--讓對方執行NPC窗口
----------------NPC窗口 (NPC本體,觸發者)
                MypartM_sg(Mypart_index,TargetCharIndex);
                return 0;
        end
        return 1;
end



--NPC窗口   抓出NPC本身.觸發者  這邊觸發者 變成 被要求組隊的那個人
function MypartM_sg(_NpcIndex,_PlayerIndex)

                local msg = "\\n\\n"..Char.GetData(CharIndex,%对象_名字%).." 申请加入您的队伍。\\n\\n是否同意其入队申请呢?\\n\\n同意入队请选择『是』,拒绝入队请选择『否』。\\n"


                NLG.ShowWindowTalked(_PlayerIndex,_NpcIndex,%窗口_信息框%,%按钮_是否%,1,msg);

end




--NPC AI行為模式  (_NpcIndex,_PlayerIndex,_SeqNo,_Select,_data)



--這裡怪怪的~~~ _me 因該為NPC本身吧,   CharIndex為最初觸發者 要求組隊的人 不知道可不可傳達到這裡

function MypartM_WindowTalked(_me,_tome,_seqno,_select,_data)

--窗口
        if(tonumber(_seqno)==1 and tonumber(_select)==%按钮_否% and _data~="")then
                --NLG.SystemMessage(_me,"队长拒绝了您的入队申请!"); <--對象好像不正確

                NLG.SystemMessage(CharIndex,"队长拒绝了您的入队申请!");--CharIndex
                return;
        end


        Char.JoinParty(CharIndex,_tome);

        return;
end
[ 本帖最后由 jeff10363 于 2016-4-28 11:00 编辑 ]

TOP

这种需要加一个临时表来存储妖城在线论坛, |5 v- \. L+ ]6 x4 {& _

# {5 m- N# H# M& tbbs.mocwww.com否则Char.JoinParty(CharIndex,_tome);函数会反复触发组队事件。
妖城欢迎您!

TOP

复制内容到剪贴板
代码:
--组队事件
--_player:主动组队的玩家
--_toplayer:被组队的玩家
--_type:0:加入组队,1:离开组队

tbl_party_check = {};

function RPartyEvent(_player,_toplayer,_type)
        if (tbl_party_check[Char.GetData(_player,%对象_账号%)] ~= nil) then
                if (tbl_party_check[Char.GetData(_player,%对象_账号%)] == _toplayer) then
                        tbl_party_check[Char.GetData(_player,%对象_账号%)] = nil;
                        return 1;
                end
        end
        if (_type==0) then
                local msg = "\\n\\n"..Char.GetData(_player,%对象_名字%).." 申请加入您的队伍。\\n\\n是否同意其入队申请呢?\\n\\n同意入队请选择『是』,拒绝入队请选择『否』。\\n";
                tbl_party_check[Char.GetData(_toplayer,%对象_账号%)] = _player;
                NLG.ShowWindowTalked(_toplayer,tbl_npc["id69"],%窗口_信息框%,%按钮_是否%,1,msg);
                return 0;
        end
        return 1;
end
复制内容到剪贴板
代码:
--测试——TestNpc_id69——Lua脚本
function TestNpc_id69_Talked(_npc,_player)
        return;
end

function TestNpc_id69_WTalked(_npc,_player,_seqno,_select,_data)
        local _checkplayer = tbl_party_check[Char.GetData(_player,%对象_账号%)];
        if (tonumber(_seqno)==1) then
                if (tonumber(_select) == %按钮_是%) then
                        tbl_party_check[Char.GetData(_checkplayer,%对象_账号%)] = _player;
                        Char.JoinParty(_checkplayer,_player);
                else
                        NLG.SystemMessage(_checkplayer,"队长拒绝了你的组队申请");
                end
                return;
        end
        return;
end
妖城欢迎您!

TOP

这样就可以了。新建立一个NPC,用来触发弹窗事件。
# l* Y; o9 @0 R: I' l; ?7 R: N9 [妖城在线论坛
2 w0 a2 i' \8 m- E妖城在线论坛然后加一个临时表,用来缓存对象实例
妖城欢迎您!

TOP

测试了下,组队部分弹出对话框后,队长这边没点同意的情况下,这个队长点别人组队的话,会直接组进去

TOP

我昨天在完善踢人的那個LUA="""=  跟你一樣的情況
- s' e# X& e( k/ S; u妖城在线论坛妖城在线论坛/ b( H! g2 j- {2 ]0 B. {
結果發現 你每多一個確認框  
3 P$ b0 y5 h0 O6 K* h6 g8 {4 {—魔力私服,魔力宝贝私服技术,DELPHI编程,魔力寶貝, 魔力宝贝, 크로스게이트,クロスゲート所以你就要多一個判斷 是不是 跟一開始的人相同
! s: J# r9 m/ s& A. o" l+ Y$ L4 p* u9 k1 c
不然在確認界面 "還沒按下 按鈕前" 會有一堆變數 一堆可能性 會產生BUGbbs.mocwww.com6 b& I) H3 K+ K- U
魔力私服,最新魔力宝贝私服技术交流, R" g9 Q  g  C3 y6 E; t
越多視窗 越多判斷-..-

TOP

随便写的,没怎么测试。。bbs.mocwww.com( B% u* q) V5 r% z

6 U( |3 g* x) a, R6 A魔力私服,最新魔力宝贝私服技术交流试试看吧,架构还是你之前的,我只是做出来效果而已。
# Y; x1 q3 o% \" W8 a, R! T妖城在线论坛bbs.mocwww.com& o/ B1 F- j; G4 d! O: |
另外,我不建议在人物身上挂任何的callback..(如loop,会跟宠邮的loop产生冲突)
复制内容到剪贴板
代码:
NL.RegPartyEvent(nil,"OnPlayerJoinParty");
Delegate.RegInit("PartyManager_Init");

function OnPlayerJoinParty( _index, _target, _type)
    if _type == 0 then
                local ConfirmMessage = "\\n\\n"..Char.GetData(_index, 2000).." 申请加入您的队伍。\\n\\n是否同意其入队申请呢?\\n\\n同意入队请选择『是』,拒绝入队请选择『否』。\\n"
                if NLG.ShowWindowTalked( _target, m_PartyManager, 0, 12, _index, ConfirmMessage) < 0 then
                        return 1;        --异常处理机制(如果没法给队长发送消息..)
                end
                return 0;
    end
    return 1;
end

function OnPartyManagerWindowTalked( _me, _tome, _seqno, _select, _data)
        if not _seqno then        --索引异常(一般不会出现)
                return;
        end

        local PartyMode = Char.GetData( _tome, 386); --%对象_组队模式%
        if PartyMode > 1 then        --组队状态异常( 0 is none, 1 is leader)
                return;
        end
               
        if( _select == 8) then
                NLG.SystemMessage( _seqno,"队长拒绝了您的入队申请!");
        else
                Char.JoinParty( _seqno, _tome);
        end
       
        return;
end

function PartyManager_Init()
    if (m_PartyManager == nil) then
                m_PartyManager = NormalCreate( 0, 99, 33, 777, 4, "PartManager");
                if( VaildChar(m_PartyManager) == true) then
                        Char.SetWindowTalkedEvent(nil, "OnPartyManagerWindowTalked", m_PartyManager);
                end
        end
end
酱油师师范..

有事找请联系QQ:296050842,注明来意.

TOP

数据要一层一层的传递,如通过 _seqno 来判断。。
! X; `+ ]% J( P3 f妖城在线论坛
/ M; s+ o. y3 |# Z& J0 U. s—魔力私服,魔力宝贝私服技术,DELPHI编程,魔力寶貝, 魔力宝贝, 크로스게이트,クロスゲート很多种方式的,完全看你怎么来做。
8 m1 Y! ~( g- k0 t魔力私服,最新魔力私服,魔力宝贝私服,魔力宝贝私服技术,魔力宝贝私服,私服架设技术,妖城,FLASH,电影,黑客,网络,网吧,破解,入侵,注册表
0 C) M) M* E0 r框架多并不代表一定会出现BUG,还是看实现思路。
9 }9 N( ^% H) ~5 o  x" i4 c魔力私服,最新魔力宝贝私服技术交流4 N* ?3 t( R- A
引用:
原帖由 jeff10363 于 2016-4-29 13:16 发表 —魔力私服,魔力宝贝私服技术,DELPHI编程,魔力寶貝, 魔力宝贝, 크로스게이트,クロスゲート( e5 X( c4 o+ w. E
我昨天在完善踢人的那個LUA="""=  跟你一樣的情況
" M3 R8 D/ C$ J. K% |) w魔力私服,最新魔力宝贝私服技术交流魔力私服,最新魔力宝贝私服技术交流; ?7 O, w6 F& _# W) B+ @3 D( U
結果發現 你每多一個確認框  
" [6 \& n$ u9 Z4 H% xbbs.mocwww.com所以你就要多一個判斷 是不是 跟一開始的人相同—魔力私服,魔力宝贝私服技术,DELPHI编程,魔力寶貝, 魔力宝贝, 크로스게이트,クロスゲート: d: }+ p4 G3 |% d! T! I' D! j6 ]8 F

% q* T( n; }6 k, \$ B" t2 j7 D3 ~妖城在线论坛不然在確認界面 "還沒按下 按鈕前" 會有一堆變數 一堆可能性 會產生BUG妖城在线论坛- E! L; d( q" ]$ p$ F2 n
bbs.mocwww.com$ H% q% I. @6 r9 m9 c  e/ W
越多 ...
酱油师师范..

有事找请联系QQ:296050842,注明来意.

TOP

利用 WindowBuffer, 在tagChar_player_work里
% y# N2 B* r1 l% N妖城在线论坛
* U2 B9 s) g$ h% W魔力默认也是采用的WindowBuffer来缓存临时数据。
5 m* q0 N9 m# D5 ybbs.mocwww.com
. \' V/ Y8 s; t5 Sbbs.mocwww.com
引用:
原帖由 易凡 于 2016-4-28 13:44 发表 bbs.mocwww.com9 D) |$ r: @# {6 u. K# |
这样就可以了。新建立一个NPC,用来触发弹窗事件。: K( `2 x; F- j& j$ h
bbs.mocwww.com5 g1 `) _  k; r/ X, S6 E
然后加一个临时表,用来缓存对象实例
酱油师师范..

有事找请联系QQ:296050842,注明来意.

TOP

引用:
原帖由 ﹎▓ヾ僤莼べ 于 2016-4-29 22:43 发表
$ U# {, Q6 o8 d0 G% `' S/ \! W魔力私服,最新魔力宝贝私服技术交流利用 WindowBuffer, 在tagChar_player_work里
( O& a8 \. q3 V% A/ w* O6 Z% ?+ Z) P& V" r; T
魔力默认也是采用的WindowBuffer来缓存临时数据。
( n4 ~5 E7 e& A/ H( N6 C—魔力私服,魔力宝贝私服技术,DELPHI编程,魔力寶貝, 魔力宝贝, 크로스게이트,クロスゲート
  i7 K, G* @1 h0 r妖城在线论坛
魔力私服,最新魔力私服,魔力宝贝私服,魔力宝贝私服技术,魔力宝贝私服,私服架设技术,妖城,FLASH,电影,黑客,网络,网吧,破解,入侵,注册表! R* M: V5 E( l1 A9 n: h
魔力默认也是采用的WindowBuffer来缓存临时数据?你真逗,缓冲寄存器就缓冲寄存器嘛
1 Z" V- x- g' R1 m# P0 l9 ^; {9 v魔力私服,最新魔力私服,魔力宝贝私服,魔力宝贝私服技术,魔力宝贝私服,私服架设技术,妖城,FLASH,电影,黑客,网络,网吧,破解,入侵,注册表
2 A& Q7 e7 T; b* E* |/ _bbs.mocwww.com[ 本帖最后由 HookSend 于 2016-4-30 11:51 编辑 ]

TOP

魔力本身确实用WindowBuffer缓存的
8 z8 ?" m& r/ L3 K: y
$ }! ]' }# g6 v2 o- t, w我台服引擎那边,lua的所有选择宠物和道具的位置缓存也都用这个。妖城在线论坛9 E1 U+ O# D/ D/ a4 h6 R8 K* _& i

( p2 U2 _) p, P  L. {! @魔力私服,最新魔力私服,魔力宝贝私服,魔力宝贝私服技术,魔力宝贝私服,私服架设技术,妖城,FLASH,电影,黑客,网络,网吧,破解,入侵,注册表星夜说的并无错。。。。。。—魔力私服,魔力宝贝私服技术,DELPHI编程,魔力寶貝, 魔力宝贝, 크로스게이트,クロスゲート! x+ ?% x& s* ~

+ T2 ?, Y& X: I$ n4 \! [4 o& a好好沟通交流。。。。不要太暴躁。。。
妖城欢迎您!

TOP

发新话题