魔力宝贝

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz

[GA] laba.lua--喇叭

[复制链接]
发表于 前天 02:13 | 显示全部楼层 |阅读模式
--  ***************************************************************************************************** --
--  code by http://www.Cgdev.me
--  喇叭模块
--                   #更新日志#
--  TYPE ***** TIME ***** Editor ***** Text
--  CREATE  2013/01/16     blue

--                   #基本设置#
local limit_time = 10; --两次发喇叭间隔时间,单位秒
local laba_itemid = 622848; --小喇叭的道具编号
local turn_on_key = "/开启喇叭"; --玩家开启喇叭开关的命令
local turn_off_key = "/关闭喇叭"; --玩家关闭喇叭开关的命令
--  ***************************************************************************************************** --

tbl_labaPlayer = {};
Delegate.RegDelLoginEvent("labaLoginEvent");
Delegate.RegDelAllOutEvent("labaOutEvent");
Delegate.RegDelTalkEvent("labaTalkEvent");
function new_labaplayerobject(player)
        local labaplayer =
        {
                index = player;
                isopen = true;
                limit_time = 0;
        };
        return labaplayer;
end

function labaLoginEvent(player)
        tbl_labaPlayer[Playerkey(player)] = new_labaplayerobject(player);
end

function labaOutEvent(player)
        tbl_labaPlayer[Playerkey(player)] = nil;
end


function labaTalkEvent(player,msg,color,range,size)
       

        if(msg==turn_on_key) then
                tbl_labaPlayer[Playerkey(player)].isopen = false;
                NLG.SystemMessage(player,"小喇叭已经开启。");
        end
       
        if(msg==turn_off_key) then
                tbl_labaPlayer[Playerkey(player)].isopen = true;
                NLG.SystemMessage(player,"小喇叭已经关闭。");
        end       
       
       
        if( check_msg(msg,">") ) then       
       
                local litime = tbl_labaPlayer[Playerkey(player)].limit_time;       
                if (os.time() - litime < limit_time )then
                        NLG.SystemMessage(player,limit_time.."秒内禁止重复发喇叭。");
                        return;
                end
       
                if(Char.ItemNum(player,laba_itemid) > 0)then
                       
                        for _,v in pairs (tbl_labaPlayer) do
                                if(v.isopen == true)then
                                        NLG.SystemMessage(v.index,"[小喇叭]"..Char.GetData(player,%对象_名字%)..": "..string.sub(msg,2));
                                end
                        end               
                        Char.DelItem(player,laba_itemid,1);
                        tbl_labaPlayer[Playerkey(player)].limit_time = os.time();
                else
                        NLG.SystemMessage(player,"对不起您的小喇叭不足!");       
                end
        end
               
end


回复

使用道具 举报

Archiver|魔力研究社

GMT+8, 2025-5-12 18:14 , Processed in 0.121089 second(s), 24 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表