Board logo

标题: [魔力私服分享] LUA腳本 簡易生蛋 道具參數LUA_usePetEgg [打印本页]

作者: jeff10363    时间: 2016-4-27 11:18     标题: LUA腳本 簡易生蛋 道具參數LUA_usePetEgg

今天分享一個寫出來 很簡單的腳本
! Z7 N5 B8 c! Y9 t2 P! O—魔力私服,魔力宝贝私服技术,DELPHI编程,魔力寶貝, 魔力宝贝, 크로스게이트,クロスゲート
$ l, M: O. s4 e  o4 u+ Z( Q8 a妖城在线论坛這個腳本 可以拿來做為 道具參數的呼應 參考文章吧?+ D0 ]  P9 q- n4 g2 B" B  n
懂得應用的話 可以弄成各種東西=""=
9 V/ a  l" ]7 ~+ R妖城在线论坛
+ A) Z7 I( y& y; X2 Abbs.mocwww.com
! r! J) }; d2 n; d- }/ M5 V. N, r$ R: T: F- }' d$ g) J8 u% v
我們通常要寫寵物蛋  妖城在线论坛7 B7 I, L) @- C( w
都會反覆的在 npc 底下 新增對應的txt 檢查道具 刪除道具 產生寵物
  s% B9 m, c; d# ]' o- O% _妖城在线论坛可是對我來說 繁瑣的去新增txt 煩煩的=""=
: b  L& p: t0 B. `; p% G妖城在线论坛
! z8 p9 _5 {+ ~% [" i—魔力私服,魔力宝贝私服技术,DELPHI编程,魔力寶貝, 魔力宝贝, 크로스게이트,クロスゲート所以就寫了 一個簡易生蛋的功能,下面附上GBK的檔案~((轉檔沒測試過 有問題在跟我講
. o* T3 T7 S( T魔力私服,最新魔力私服,魔力宝贝私服,魔力宝贝私服技术,魔力宝贝私服,私服架设技术,妖城,FLASH,电影,黑客,网络,网吧,破解,入侵,注册表
3 O+ I7 c$ _9 l0 e3 ^【示演】
# U- J* p9 W) |在道具itemset.txt新增LUA_usePetEgg類型的道具
' j& C- h  F0 F) Y; [$ z妖城在线论坛參數 則設定enemy裡頭的怪物ID 下方參數 設定 1  代表虎人編號7 @8 q% o+ x. I( n9 T; S; U
套用LUA後 以後只要新增itemset.txt 就可以了~~~魔力私服,最新魔力私服,魔力宝贝私服,魔力宝贝私服技术,魔力宝贝私服,私服架设技术,妖城,FLASH,电影,黑客,网络,网吧,破解,入侵,注册表2 {: x  W. Z6 \& p' v  a. g

9 e- @- ?; d: v  o魔力私服,最新魔力私服,魔力宝贝私服,魔力宝贝私服技术,魔力宝贝私服,私服架设技术,妖城,FLASH,电影,黑客,网络,网吧,破解,入侵,注册表
& H8 `  \  ~- k3 P4 L; J/ S: _. B) b妖城在线论坛蛋?        虎人的蛋        1                        LUA_usePetEgg                                                90001078        99451        0        43                0        1        0        93        1        1        1        1                                                0        0                                                                                                                                                                                                                                                                                                                                                                                                                                                                                0        0        1                        0                        100        0        0                        0—魔力私服,魔力宝贝私服技术,DELPHI编程,魔力寶貝, 魔力宝贝, 크로스게이트,クロスゲート# \/ Z: Q' Q8 x0 r/ H. q
魔力私服,最新魔力宝贝私服技术交流: X; ?7 u3 \  w1 P2 h  U

, S- D5 X6 p/ L# k  R' u—魔力私服,魔力宝贝私服技术,DELPHI编程,魔力寶貝, 魔力宝贝, 크로스게이트,クロスゲート【腳本內容】
复制内容到剪贴板
代码:
--2016/04/27 阿晉
--简易生蛋功能
--
--
--免新增npc底下 生蛋脚本 直接透过item参数诞生宝宝
--
--注册一个道具使用参数
NL.RegItemString(nil, "PetEgg", "LUA_usePetEgg");


function PetEgg(player,toplayer,itemSlot)
--取到道具的自定參數
local ItemIndex=Char.GetItemIndex(player,itemSlot);
--复制内值
local itemval=Item.GetData(ItemIndex,%道具_自用参数%);



if(Char.PetNum(player)==5)then
NLG.SystemMessage(player,"宠物栏已满,无法使用。");
return;
end


Item.Kill(player,ItemIndex,itemSlot);
Char.GivePet(player,itemval,0);
--Char.GivePet(player,itemval,1);--满档


end
【後記】7 C& B0 d) O: {+ w" J
—魔力私服,魔力宝贝私服技术,DELPHI编程,魔力寶貝, 魔力宝贝, 크로스게이트,クロスゲート5 m7 N4 d' z$ ~# p8 X( {9 F( Q
1.這個蛋只會檢查是否 有寵物欄空間妖城在线论坛% c" h  ]' B# L5 U& D8 P3 B
2.請勿讓他堆疊 刪除道具 是刪除那一整格 而非數量  否則可能整格蛋 刪光光
  I  J+ Y( J6 j) R( E# ~0 P; ]3.符合寵物空間 刪除道具 產生寵物bbs.mocwww.com' @1 l) ^/ I1 z
4.Char.GivePet(player,itemval,1); 更改這個可以產生 滿檔寶寶
) w8 l) w, `' K4 B8 o9 Q+ D魔力私服,最新魔力宝贝私服技术交流5.另外  這個lua產生的效果很陽春-..-沒有窗口
% ]% m5 B* t( `- `. |3 w: U1 H—魔力私服,魔力宝贝私服技术,DELPHI编程,魔力寶貝, 魔力宝贝, 크로스게이트,クロスゲート妖城在线论坛" t7 c( t$ b: V! Q# y9 O) Y. P

# b( R9 W8 w. H: Y& [; |—魔力私服,魔力宝贝私服技术,DELPHI编程,魔力寶貝, 魔力宝贝, 크로스게이트,クロスゲート【安裝方法】魔力私服,最新魔力私服,魔力宝贝私服,魔力宝贝私服技术,魔力宝贝私服,私服架设技术,妖城,FLASH,电影,黑客,网络,网吧,破解,入侵,注册表" I" u# S9 n7 |: p8 U$ y/ `6 ^! Y
1.版本確認 GA版本
- z: M5 u4 l( O  A, {! K2.把PetEgg.lua 丟到 lua\Module 下面
4 L9 k2 I) S9 C/ K' M—魔力私服,魔力宝贝私服技术,DELPHI编程,魔力寶貝, 魔力宝贝, 크로스게이트,クロスゲート3.Config內新增妖城在线论坛3 N. E% T) N7 P. `( g+ U. \9 \
useModule("PetEgg");
, U2 X# W' i2 {; P8 d+ j魔力私服,最新魔力私服,魔力宝贝私服,魔力宝贝私服技术,魔力宝贝私服,私服架设技术,妖城,FLASH,电影,黑客,网络,网吧,破解,入侵,注册表: c' r" \- m9 R9 h0 f1 X3 o1 d
[ 本帖最后由 jeff10363 于 2016-4-27 13:53 编辑 ]

附件: PetEgg.rar (2016-4-27 11:18, 500 Bytes) / 该附件被下载次数 259
http://bbs.mocwww.com/attachment.php?aid=17192
作者: 易凡    时间: 2016-4-27 13:49

感谢分享,我抛装引玉一下。。。。因为这个道具功能,我当初也做过。不过因为引擎不一样,所以我下面发的代码仅供参考~~
作者: 易凡    时间: 2016-4-27 13:57

道具使用事件代码:
复制内容到剪贴板
代码:
--_player:使用道具的角色
--_item:使用道具的索引实例
--_slot:被使用道具所在栏位
--返回值:1表示正常使用道具,0表示禁止使用道具

function RItemUseEvent(_player,_item,_slot)
        --容错
        if _slot < 0 or _slot > 27 then
                return 0;
        end
        if _item == -1 then
                return 0;
        end
       
        --判断是否已鉴定
        if Item.GetData(_item,%ITEM_LEAKLEVEL%) == 0 then
                NLG.SystemMessage(_player,"未鉴定道具不可使用");
                return 0;
        end
       
        local _itemid = Item.GetData(_item,%ITEM_ID%);
        local _itemname = Item.GetData(_item,%ITEM_TRUENAME%);
        local _itemusefunc = Item.GetData(_item,%ITEM_USEFUNC%);

        --给予宠物,参数有一个或者两个:宠物编号,是否满档
        if _itemusefunc == "LUA_useGivePet" then
                Char.SetData(_player,LuaSetup.TMP_ItemSelect,_slot);
                NLG.CallNpcTalked(tbl_npc.GivePetNpc_id16,_player);
                return 1;
        end;
       
        return 1;       
end
功能NPC的实现代码
复制内容到剪贴板
代码:
--GivePet——GivePetNpc_id16——Lua脚本
function GivePetNpc_id16_Talked(_npc,_player)
        --判断玩家身上是否有足够的宠物栏空位
        if Char.PetSpace(_player) == 0 then
                MyFun.EndWindow(_player,"\\n\\n\\n\\n@c您的宠物栏满了,请先整理!");
                return;
        end
        --验证缓存的道具
        local _item = MyFun.CheckItemBuffer(_player,"LUA_useGivePet");
        if _item == nil then
                return;
        end;
        local _itemname = Item.GetData(_item,%ITEM_TRUENAME%);
        local _arg = Item.GetData(_item,%ITEM_ARGUMENT%);
        local _argstl = MyFun.Split(_arg,",");
        local _enemyid = tonumber(_argstl[1]);
        if _enemyid == nil then
                MyFun.EndWindow(_player,"\\n\\n\\n\\n@c道具参数有误,请截图联系GM\\nError:LUA_useGivePet");
                return;
        end
        local _full = 0;
        if (#_argstl == 2) and (_argstl[2] == "1") then
                _full = 1;
        end
        local _enemyindex = Data.GetIndex(%FILE_ENEMY%,_enemyid);
        if _enemyindex == nil then
                return;
        end
        local _enemybaseid = Data.GetInt(%FILE_ENEMY%,_enemyindex,%ENEMYDATA_TEMPNO%);
        local _enemybaseindex = Data.GetIndex(%FILE_ENEMYBASE%,_enemybaseid);
        local _enemylv = Data.GetInt(%FILE_ENEMY%,_enemyindex,%ENEMYDATA_LV_MAX%);
        if _enemybaseindex == nil then
                return;
        end
        local _enemybasename = Data.GetChar(%FILE_ENEMYBASE%,_enemybaseindex,%E_T_NAME%);
        local _str = "\\n\\n    您确定要使用“".._itemname.."”吗?\\n"
                .."\\n        召唤魔族:".._enemybasename
                .."\\n        魔族等级:".._enemylv.."级";
        if _full == 1 then
                _str = _str.."\\n        魔族档次:满档";
        else
                _str = _str.."\\n        魔族档次:随机档";
        end
        NLG.ShowWindowTalked(_player,_npc,%WINDOW_MESSAGETYPE_MESSAGE%,%BUTTON_OK_CANCEL%,LuaSetup.MySeqno+1,_str);
        return;
end

function GivePetNpc_id16_WTalked(_npc,_player,_seqno,_select,_data)

        local _seqno = _seqno - LuaSetup.MySeqno;

        --验证缓存的道具
        local _item = MyFun.CheckItemBuffer(_player,"LUA_useGivePet");
        if _item == nil then
                return;
        end;
        local _itemid = Item.GetData(_item,%ITEM_ID%);
        local _arg = Item.GetData(_item,%ITEM_ARGUMENT%);
        local _argstl = MyFun.Split(_arg,",");
        local _enemyid = tonumber(_argstl[1]);
        local _full = 0;
        if (#_argstl == 2) and (_argstl[2] == "1") then
                _full = 1;
        end
       
        if (tonumber(_seqno)==1) then
                if (tonumber(_select) == %BUTTON_OK%) then
                        Char.DelItem(_player,_itemid,1);
                        local _pet = Char.GivePet(_player,_enemyid,_full);
                        if _pet ~= nil then
                                NLG.SystemMessage(_player,"获得了宠物『"..Char.GetData(_pet,%CHAR_Name%).."』");
                                NLG.UpChar(_pet);
                        end
                        return;
                else
                        return;
                end
                return;
        end
        return;
end


function GivePetNpc_id16_LoopEvent(_npc)
        return;
end
创建这个功能NPC的createnpc代码
复制内容到剪贴板
代码:
--GivePet——GivePetNpc_id16

function GivePetNpc_id16_Create()
        if (GivePetNpc_id16 == nil) then
                GivePetNpc_id16 = NL.CreateNpc("GivePet",100453,0,779,0,11,4);
                tbl_npc.GivePetNpc_id16=GivePetNpc_id16;
                Char.SetTalkedEvent("lua/Npc/GivePet_id16.lua","GivePetNpc_id16_Talked", GivePetNpc_id16);
                Char.SetWindowTalkedEvent(nil,"GivePetNpc_id16_WTalked", GivePetNpc_id16);
                --Char.SetLoopEvent(nil,"GivePetNpc_id16_LoopEvent", GivePetNpc_id16,1000);
        end
end
itemset数据范例
8 b5 O) \4 h/ k* o) _" D+ e- N) a8 j魔力私服,最新魔力宝贝私服技术交流召唤卡?        『满档黄蜂』召唤卡        314,1                        LUA_useGivePet                                                60501        27489                26                0        1        0        0        1        1        1        1        0                                        0        0                                                                                                                                                                                                                                                                                                                                                                                                                                                                                0        1        0                        0        605011        605011        100        0        0                        0魔力私服,最新魔力私服,魔力宝贝私服,魔力宝贝私服技术,魔力宝贝私服,私服架设技术,妖城,FLASH,电影,黑客,网络,网吧,破解,入侵,注册表* E  H; }5 X3 [+ r4 w+ J% }
比如参数直接写314就是随机档次了,314,1就是满档妖城在线论坛6 U$ k  r& \' b  f" Y

& @/ p/ l0 F: I- ]7 ^魔力私服,最新魔力私服,魔力宝贝私服,魔力宝贝私服技术,魔力宝贝私服,私服架设技术,妖城,FLASH,电影,黑客,网络,网吧,破解,入侵,注册表确实比较方便
' e( I9 t$ B' b1 h. h; G8 p- m—魔力私服,魔力宝贝私服技术,DELPHI编程,魔力寶貝, 魔力宝贝, 크로스게이트,クロスゲート

图片附件: 11.jpg (2016-4-27 13:57, 102.9 KB) / 该附件被下载次数 136
http://bbs.mocwww.com/attachment.php?aid=17193


作者: jeff10363    时间: 2016-4-27 14:07

感謝站長提供 語法參照
/ }$ e* c3 u& M* I5 V0 B. M0 J" e/ S/ N哈 原來拖GA接口的福 才可以寫的這麼簡短魔力私服,最新魔力私服,魔力宝贝私服,魔力宝贝私服技术,魔力宝贝私服,私服架设技术,妖城,FLASH,电影,黑客,网络,网吧,破解,入侵,注册表0 j( [6 s3 R2 U* j* d

/ P/ E) v. Q3 B; b1 ^魔力私服,最新魔力宝贝私服技术交流
5 i9 \9 k$ M& o7 |$ fbbs.mocwww.com現在還在試寫-...-魔力私服,最新魔力私服,魔力宝贝私服,魔力宝贝私服技术,魔力宝贝私服,私服架设技术,妖城,FLASH,电影,黑客,网络,网吧,破解,入侵,注册表! P- R3 A2 k* U' B3 y$ Y/ j& k
! y6 L$ k; O; {0 l
1.寵物技能捲軸(點寵 開窗 選寵學)   
+ T0 ~/ t  m( @" A( g+ ?妖城在线论坛    學習特殊技能使用.. 魔力私服,最新魔力宝贝私服技术交流" d: v: x2 b$ E' n, x  s3 K9 @/ y, Q
=>不用開 寵技npc
* W! b! s5 p$ U: T6 |—魔力私服,魔力宝贝私服技术,DELPHI编程,魔力寶貝, 魔力宝贝, 크로스게이트,クロスゲート還怕別人一次學五隻—魔力私服,魔力宝贝私服技术,DELPHI编程,魔力寶貝, 魔力宝贝, 크로스게이트,クロスゲート6 d3 w0 ^0 T. m4 {5 U$ j- r2 _: N# c
或是另外做一個獨立 隔開的地圖 來限制
5 a) ^) G" j  J" v- h6 e
" i3 i4 |7 Z6 e妖城在线论坛2.封印盒子
" K% ]) z  X$ u' ?! ^: q: e9 \) g魔力私服,最新魔力私服,魔力宝贝私服,魔力宝贝私服技术,魔力宝贝私服,私服架设技术,妖城,FLASH,电影,黑客,网络,网吧,破解,入侵,注册表  把不可交異的東西  水鏡、哥、弟戒、放大鏡bbs.mocwww.com6 W. S2 f' n3 ]  G, q
裝進去 只有本人(檢查CDK 跟 角色ID) —魔力私服,魔力宝贝私服技术,DELPHI编程,魔力寶貝, 魔力宝贝, 크로스게이트,クロスゲート. d: ?1 u. |& M2 {, C3 S
才可以打開    方便收到分身那 節省道具攔空間—魔力私服,魔力宝贝私服技术,DELPHI编程,魔力寶貝, 魔力宝贝, 크로스게이트,クロスゲート+ s; d5 E) m( y+ d* Z. P8 b
—魔力私服,魔力宝贝私服技术,DELPHI编程,魔力寶貝, 魔力宝贝, 크로스게이트,クロスゲート' g1 I; Q7 S0 V/ F, k( n
[ 本帖最后由 jeff10363 于 2016-4-27 14:09 编辑 ]
作者: 易凡    时间: 2016-4-27 15:55

复制内容到剪贴板
代码:
--宠物技能学习——Pet_AddSkillNpc_id13——Lua脚本
--道具参数格式:techid,cost
--cost可选,不填写,则表示免费,如果填写-1则表示使用tech.txt中定义的价格
function Pet_AddSkillNpc_id13_Talked(_npc,_player)
        local _str = MyFun.ShowSelectPetstr(_player,"学习技能");
        NLG.ShowWindowTalked(_player,_npc,%WINDOW_MESSAGETYPE_SELECT%,%BUTTON_CANCEL%,LuaSetup.MySeqno+1,_str);
        return;
end

function Pet_AddSkillNpc_id13_WTalked(_npc,_player,_seqno,_select,_data)
        local _seqno = _seqno - LuaSetup.MySeqno;
       
        --验证缓存的道具
        local _item = MyFun.CheckItemBuffer(_player,"LUA_usePetAddSkill");
        if _item == nil then
                return;
        end;
        local _arg = Item.GetData(_item,%ITEM_ARGUMENT%);
        local _argstl = MyFun.Split(_arg,",");
        local _techid = tonumber(_argstl[1]);
        local _needgold = 0;
        local _techindex = Data.GetIndex(%FILE_TECH%,_techid);
        if _techindex == nil then
                MyFun.EndWindow(_player,"\\n\\n\\n\\n@c技能ID错误,请截图联系GM");
                return;
        end
        local _techname = Data.GetChar(%FILE_TECH%,_techindex,%TECH_NAME%);
        if #_argstl == 2 then
                if tonumber(_argstl[2]) ~= -1 then
                        _needgold = tonumber(_argstl[2]);
                else
                        local _techcost = Data.GetInt(%FILE_TECH%,_techindex,%TECH_COST%);
                        if _techcost ~= "" then
                                _needgold = tonumber(_techcost);
                        end
                end
        end

        --选择宠物后确认
        if (tonumber(_seqno)==1 and _data~=nil) then
                if tonumber(_select) == %BUTTON_CANCEL% then
                        return;
                end
               
                --容错
                if MyFun.CheckSelectWindowData(_player,_data,5) == false then
                        return;
                end
                local _petpos = tonumber(_data) - 1;
                local _pet = Char.GetPet(_player,_petpos);
                if _pet == nil then
                        MyFun.EndWindow(_player,"\\n\\n\\n\\n@c您选择的位置没有宠物,请重新选择!");
                        return;
                end
                --这里加一个验证,禁止部分宠物学习指定技能
                if (Char.GetData(_pet,%PET_PetId%) >= 20921) and (Char.GetData(_pet,%PET_PetId%) <= 20924) and (_techid == 8900) then
                        MyFun.EndWindow(_player,"\\n\\n\\n\\n@c很抱歉,出生系列牛头怪禁止学习宠物邮件");
                        return;
                end
                               
                local _itemname = Item.GetData(_item,%ITEM_TRUENAME%);
                local _petname = Char.GetData(_pet,%CHAR_Name%);
                local _petlv = Char.GetData(_pet,%CHAR_Lv%);
                Char.SetData(_player,LuaSetup.TMP_PetSelect,_petpos);
                local _str = "\\n\\n   已选宠物:".._petname.."\\n   当前等级:".._petlv.." 级\\n\\n   您确定要让这只宠物学习新技能——\\n       “".._techname.."”吗?";
                if _needgold > 0 then
                        _str = _str.."\\n   这将需要花费".._needgold.."G";
                end
                NLG.ShowWindowTalked(_player,
                                _npc,
                                %WINDOW_MESSAGETYPE_MESSAGE%,
                                %BUTTON_YES_NO%,
                                LuaSetup.MySeqno+2,
                                _str);
                return;
        end
       
        --进行学习技能操作
        if (tonumber(_seqno)==2) then
                if tonumber(_select) == %BUTTON_NO% then
                        --将缓存释放
                        Char.SetData(_player,LuaSetup.TMP_ItemSelect,0);
                        Char.SetData(_player,LuaSetup.TMP_PetSelect,0);
                        return;
                end
               
                local _pet = MyFun.CheckPetBuffer(_player);
                if _pet == nil then
                        return;
                end
               
                local _petname = Char.GetData(_pet,%CHAR_Name%);
                local _petlv = Char.GetData(_pet,%CHAR_Lv%);

                local _itemid = Item.GetData(_item,%ITEM_ID%);
                if Char.ItemNum(_player,_itemid) > 0 then
                        --先判断金币是否充足
                        if Char.GetData(_player,%PLAYER_Gold%) < _needgold then
                                MyFun.EndWindow(_player,"\\n\\n\\n\\n@c您的魔币不足以支付该技能学习费用!");
                                return;
                        end
                        --尝试学习技能
                        local _ret = Pet.AddSkill(_pet,_techid);
                        if _ret == nil then
                                MyFun.EndWindow(_player,"\\n\\n\\n\\n@c学习失败,可能宠物的技能已满了!");
                                return;
                        end       
                        Char.DelItem(_player,_itemid,1);--删除道具
                        if _needgold > 0 then
                                Char.AddGold(_player,-_needgold);
                        end
                        NLG.UpChar(_pet);
                        NLG.SystemMessage(_player,"[系统提示] 您的宠物“".._petname.."”已成功习得新技能“".._techname.."”");       
                        --将缓存释放
                        Char.SetData(_player,LuaSetup.TMP_ItemSelect,0);
                        Char.SetData(_player,LuaSetup.TMP_PetSelect,0);
                        return;
                end
        end   
        return;
end


function Pet_AddSkillNpc_id13_LoopEvent(_npc)
        return;
end
复制内容到剪贴板
代码:
--组合宠物选择框
function MyFun.ShowSelectPetstr(_player,_keystr)
        local _keystrnew = "操作";
        if _keystr ~= nil then
                _keystrnew = _keystr;
        end
        local _str = "3|\\n\\n     请选择您要".._keystrnew.."的宠物!\\n\\n";
        local _str2 = "";
        local _str3 = "";
        for i=0,4 do
                local _pet = Char.GetPet(_player,i);
                if (_pet == nil) then
                        _str = _str .. "     *空*\\n";
                else
                        _str2 = Char.GetData(_pet,%CHAR_Name%);
                        _str2 = "     "..string.format("%-20s",_str2);
                        _str3 = "LV"..Char.GetData(_pet,%CHAR_Lv%);
                        _str2 = string.format("%20s",_str2);
                        _str = _str.._str2.._str3.."\\n";
                end
        end
        return _str;
end
复制内容到剪贴板
代码:
--验证缓存的所选择宠物
function MyFun.CheckPetBuffer(_player)
        local _slot = Char.GetData(_player,LuaSetup.TMP_PetSelect);
        if _slot < 0 or _slot > 4 then
                MyFun.EndWindow(_player,"\\n\\n\\n\\n@c宠物栏异常,请截图联系GM");
                return;
        end
        local _pet = Char.GetPet(_player,_slot)
        if _pet == nil then
                MyFun.EndWindow(_player,"\\n\\n\\n\\n@c您所选择的宠物异常,请截图联系GM");
                return;
        else
                return _pet;
        end

end
复制内容到剪贴板
代码:
--分割字符串
function MyFun.Split(szFullString, szSeparator)
        local nFindStartIndex = 1;
        local nSplitIndex = 1;
        local nSplitArray = {};
        while true do
                local nFindLastIndex = string.find(szFullString, szSeparator, nFindStartIndex);
                if not nFindLastIndex then
                        nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex, string.len(szFullString));
                        break;
                end
                nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex, nFindLastIndex - 1);
                nFindStartIndex = nFindLastIndex + string.len(szSeparator);
                nSplitIndex = nSplitIndex + 1;
        end
        return nSplitArray;

end

--结束窗口
function MyFun.EndWindow(_player,_str)
        local _fd = Char.GetData(_player,%PLAYERWORK_Fd%);
        local _objindex = Char.GetData(_player,%CHARWORK_ObjIndex%);
        Protocol.WN_Send(_fd,%WINDOW_MESSAGETYPE_MESSAGE%,%BUTTON_OK%,LuaSetup.EndWindowSeqno,_objindex,_str);
        return;
end

--判断选择窗口异常
function MyFun.CheckSelectWindowData(_player,_data,_max)
        if  (_data == "") or (_data == nil) or (tonumber(_data) == nil) then
                MyFun.EndWindow(_player,"@c\\n\\n\\n\\n异常选项处理失败,请截图联系客服!");
                return false;
        end
        if (tonumber(_data) > _max or tonumber(_data) < 1) then
                MyFun.EndWindow(_player,"@c\\n\\n\\n\\n异常选项处理失败,请截图联系客服!");
                return false;
        end
        return true;
end





欢迎光临 妖城在线论坛 (http://bbs.mocwww.com/) Powered by Discuz! 6.0.0