魔力宝贝

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

[GP] RightClick.lua--右键点击角色触发效果(GM封号,给道具,佣兵换...

[复制链接]
发表于 前天 02:48 | 显示全部楼层 |阅读模式
local RightClickNpc = {100500,"右键",4,777,51,54} --右键npc
local DisAbleKillCdkey = "/disbadcdkey" --解封 /disbadcdkey xxx
local killuser = "/killuser"--踢下指定CDK账号(可踢离线摆摊) /killuser xxx(对象账号,记得有个空格)
local MAXGLOD=10000000--按CF中写的魔币上限设定该数值,目前是一千万魔币

-------------------------------------------------------------
Global_Reg.CharRightclick("RightClickMain")
Global_Reg.RegTalkEvent("RightClickTalk")
Global_Reg.RegInit("RightClick_Init");

local RightClickTargetList = RightClickTargetList or {}

function RightClick_Init()
        RightClickNPC_Init();
        return 0;
end

function RightClickNPC_Init(npc)
        if npc == nil or npc < 0 then
        npc = NL.CreateNpc(nil,"RightClickNPC_Index")
        end
        Char.SetData(npc,%对象_形象%,RightClickNpc[1])
        Char.SetData(npc,%对象_原形%,RightClickNpc[1])
        Char.SetData(npc,%对象_地图%,RightClickNpc[4])
        Char.SetData(npc,%对象_X%,RightClickNpc[5])
        Char.SetData(npc,%对象_Y%,RightClickNpc[6])
        Char.SetData(npc,%对象_方向%,RightClickNpc[3])
        Char.SetData(npc,%对象_原名%,RightClickNpc[2])
        LuaNpcIndex["RightClick_index"]=npc;
        InstallNpc("RightClick_index",npc);
        --Char.SetTalkedEvent(nil, "RightClickValue23",npc)
        Char.SetWindowTalkedEvent(nil,"RightClickWindowCallBack",npc)
        --Char.SetLoopEvent(nil,"RightClickValue19",npc,1000)
        NLG.UpChar(npc)
        return true
end

function RightClickNPC_Index(index)
        return true;
end

function RightClickTalk(player,msg,color,range,size)
        local cdkey = Char.GetData(player,%对象_帐号%)
        local isgm = NLG.Get_Char_Date(player,145)
        if isgm > 0 then
                if string.sub(msg,3,(string.len(DisAbleKillCdkey)+2)) == DisAbleKillCdkey then
                        local wantcdkey = string.sub(msg,string.len(DisAbleKillCdkey)+3,-1)
                        local sqlstr = "update tbl_user set enableflg = '1' where cdkey = '" ..wantcdkey.. "'"
                        if SQL.Run(sqlstr) == 0 then
                                NLG.SystemMessage(player,"解封帐号:"..wantcdkey)
                        else
                                NLG.SystemMessage(player,"解封帐号:"..wantcdkey.." 失败。")
                        end
                elseif string.sub(msg,3,(string.len(killuser)+2)) == killuser then
                        local wantcdkey = string.sub(msg,string.len(killuser)+3,-1)
                        local index = NLG.GetCharindexformuser(wantcdkey);
                        if index>=0 then
                                local TableLen = Stall.Check(index);--对象>0就处于摆摊状态
                               
                                local fd = Protocol.GetFdByChar(index)
                                local Retime = Off.OffGetTime(fd)
                                if Retime>=0 and TableLen~=0 then--处于离线摆摊状态
                                        local ret = Off.DeleteOff(fd);
                                        NLG.SystemMessage(player,"使帐号:"..wantcdkey.." 停止离线摆摊")
                                else
                                        NLG.Close_Socket(index)
                                        NLG.SystemMessage(player,"使帐号:"..wantcdkey.." 下线")
                                end
                        else
                                NLG.SystemMessage(player,"帐号:"..wantcdkey.." 不在线或没有离线摆摊")
                        end
                end
        end
        return 0;
end

function RightClickMain(player,target)
        --NLG.SystemMessage(player,"player="..player)
        local isgm = NLG.Get_Char_Date(player,145)--145代表是否是GM,是就返回1,否就返回0
        local TableLen = Stall.Check(target);--对象>0就处于摆摊状态
        local msg = "2\n你点击了玩家:"..(Char.GetData(target,%对象_原名%)).."\n"
        if (isgm > 0) and TableLen==0 then
                msg = msg.."帐号"..(Char.GetData(target,%对象_帐号%)).."\n1.对话\n2.查看详情\n3.给予道具\n4.给予宠物\n5.给予金钱\n6.给予NowEvent\n7.给予EndEvent"
                RightClickTargetList[player] = target
                NLG.ShowWindowTalked(player,2,2,1,msg,LuaNpcIndex.RightClick_index)
        elseif (isgm > 0) and TableLen~=0 then
                NLG.SystemMessage(player,"摆摊对象账号:"..Char.GetData(target,%对象_帐号%))
        end
end

function RightClickWindowCallBack(npc,player,Seqno,Select,Data)
        if Select ~= 2 then
                local target = RightClickTargetList[player]
                if target ~= nil and target >= 0 then
                        local cdkey1 = Char.GetData(player,%对象_帐号%)
                        local cdkey2 = Char.GetData(target,%对象_帐号%)
                        if Seqno == 1 then
                                local isgm = NLG.Get_Char_Date(player,145)
                                if isgm > 0 then
                                        if tonumber(Data) == 1 then
                                                local msg = "\n请输入你要对"..(Char.GetData(target,%对象_原名%)).."说的话后点击确定:"
                                                NLG.ShowWindowTalked(player,1,3,11,msg,npc)
                                        elseif tonumber(Data) == 2 then
                                                local msg = "\n" .. (Char.GetData(target,%对象_原名%)) .. " Index=" .. target .. " Cdkey=" .. cdkey2
                                                --local macindex = LoginMac(target,mac)--Base库函数LoginMac
                                                local user=Char.GetData(target,2002);
                                                msg = msg.."\nip="..(Char.GetData(target,%对象_IP%)).." mac="..Mac[user]
                                                msg = msg.."\n点击【确定】令此帐号掉线 点击【是】封号"
                                                NLG.ShowWindowTalked(player,0,7,21,msg,npc)
                                                --local msg = "\n请输入你要给与"..(Char.GetData(target,%对象_原名%)).."的道具后点击确定:\n\n输入格式:佣兵id"
                                                --NLG.ShowWindowTalked(player,1,3,21,msg,npc)
                                        elseif tonumber(Data) == 3 then
                                                local msg = "\n请输入你要给予"..(Char.GetData(target,%对象_原名%)).."的道具后点击确定:\n\n输入格式:道具id,给予数量"
                                                NLG.ShowWindowTalked(player,1,3,31,msg,npc)
                                        elseif tonumber(Data) == 4 then
                                                local msg = "\n请输入你要给予"..(Char.GetData(target,%对象_原名%)).."的宠物后点击确定:\n\n输入格式1:宠物id,是否满档\n1为满档 0为随机\n\n输入格式2:宠物id,体力掉档,攻击掉档,防御掉档,敏捷掉档,魔法掉档 填写0~4,必须每个档位都填"
                                                NLG.ShowWindowTalked(player,1,3,41,msg,npc)
                                        elseif tonumber(Data) == 5 then
                                                local msg = "\n请输入你要给予"..(Char.GetData(target,%对象_原名%)).."的金钱后点击确定:\n\n输入格式:金币数量"
                                                NLG.ShowWindowTalked(player,1,3,51,msg,npc)
                                        elseif tonumber(Data) == 6 then
                                                local msg = "\n请输入你要给予"..(Char.GetData(target,%对象_原名%)).."的【NowEvent】后点击确定:\n\n输入格式:flag旗标 \n点击【是】为给予旗标\n点击【否】为撤销旗标"
                                                NLG.ShowWindowTalked(player,1,14,61,msg,npc)
                                        elseif tonumber(Data) == 7 then
                                                local msg = "\n请输入你要给予"..(Char.GetData(target,%对象_原名%)).."的【EndEvent】后点击确定:\n\n输入格式:flag旗标 \n点击【是】为给予旗标\n点击【否】为撤销旗标"
                                                NLG.ShowWindowTalked(player,1,14,71,msg,npc)
                                        end
                                end
                        elseif Seqno == 11 then
                                if Select == 1 then
                                        --NLG.TalkToCli(target,player,Data,FontColor)
                                        NLG.SystemMessage(target,Char.GetData(player,%对象_原名%)..":"..Data)
                                        RightClickTargetList[player] = nil
                                end
                        elseif Seqno == 21 then
                                if Select == 1 then
                                        NLG.DropPlayer(target)
                                        RightClickTargetList[player] = nil
                                        NLG.SystemMessage(player,"掉线成功。")
                                elseif Select == 4 then
                                        NLG.DropPlayer(target)
                                        local cdkey = Char.GetData(target,%对象_帐号%)
                                        if isrealstr(cdkey) then
                                                local sqlstr = "update tbl_user set enableflg = '0' where cdkey = '" ..cdkey.. "'"
                                                if SQL.Run(sqlstr) == 0 then
                                                        msgreturn = "封停帐号:"..cdkey.." 角色:"..(Char.GetData(target,%对象_原名%))
                                                else
                                                        msgreturn = "封停帐号:"..cdkey.." 失败。"
                                                end
                                        else
                                                msgreturn = "无法封停帐号:"..cdkey
                                        end
                                        RightClickTargetList[player] = nil
                                        NLG.SystemMessage(player,msgreturn)
                                end
                        elseif Seqno == 31 then
                                if Select == 1 then
                                        local isgm = NLG.Get_Char_Date(player,145)
                                        if isgm > 0 then
                                                local giveitemtemp = splitplus(Data,",")
                                                local Num = Char.FindEmptyItemBox(target);
                                                if Num>0 then
                                                        Char.GiveItem(target,tonumber(giveitemtemp[1]),tonumber(giveitemtemp[2]))
                                                        NLG.SystemMessage(player,"给予道具"..tonumber(giveitemtemp[1]).."*"..tonumber(giveitemtemp[2]))
                                                else
                                                        NLG.SystemMessage(player,"对象道具栏空位不足")
                                                end
                                                RightClickTargetList[player] = nil
                                        end
                                end
                        elseif Seqno == 41 then
                                if Select == 1 then
                                        local isgm = NLG.Get_Char_Date(player,145)
                                        if isgm > 0 then
                                                local giveitemtemp = splitplus(Data,",")
                                                local count = 0
                                                for i=0,4 do
                                                        local PetIndex = Char.GetPetIndex(target,i);
                                                        if PetIndex>=0 then
                                                                count = count + 1
                                                        end
                                                end
                                                if count<5 then
                                                       
                                                        if giveitemtemp[3]==nil then
                                                                NLG.GivePet(target,tonumber(giveitemtemp[1]),tonumber(giveitemtemp[2]))
                                                                NLG.SystemMessage(player,"给予宠物"..tonumber(giveitemtemp[1]).." 档位模式(1为满档,0为随机):"..tonumber(giveitemtemp[2]))
                                                        else
                                                                Pet.GivePetArtRank(target,tonumber(giveitemtemp[1]),tonumber(giveitemtemp[2]),tonumber(giveitemtemp[3]),tonumber(giveitemtemp[4]),tonumber(giveitemtemp[5]),tonumber(giveitemtemp[6]));
                                                                NLG.SystemMessage(player,"给予宠物"..tonumber(giveitemtemp[1]).." 档位:"..tonumber(giveitemtemp[2])..","..tonumber(giveitemtemp[3])..","..tonumber(giveitemtemp[4])..","..tonumber(giveitemtemp[5])..","..tonumber(giveitemtemp[6]))
                                                        end
                                                       
                                                else
                                                        NLG.SystemMessage(player,"对象宠物栏空位不足")
                                                end
                                                RightClickTargetList[player] = nil
                                        end
                                end
                        elseif Seqno == 51 then
                                if Select == 1 then
                                        local isgm = NLG.Get_Char_Date(player,145)
                                        if isgm > 0 then
                                                if Char.GetData(target,53)+tonumber(Data) >= MAXGLOD then
                                                        Char.SetData(target,53,MAXGLOD)
                                                elseif Char.GetData(target,53)+tonumber(Data) < 0 then
                                                        Char.SetData(target,53,0)
                                                else
                                                        Char.SetData(target,53,Char.GetData(target,53)+tonumber(Data))
                                                end
                                                NLG.UpChar(target,53)
                                                NLG.SystemMessage(player,"给予魔币"..tonumber(Data))
                                                RightClickTargetList[player] = nil
                                        end
                                end
                        elseif Seqno == 61 then
                                local isgm = NLG.Get_Char_Date(player,145)
                                if isgm > 0 then
                                        if Select == 4 then
                                                Char.NowEvent(target,tonumber(Data),1)
                                                NLG.SystemMessage(player,"给予NowEvent "..tonumber(Data))
                                        elseif Select == 8 then
                                                Char.NowEvent(target,tonumber(Data),0)
                                                NLG.SystemMessage(player,"删除NowEvent "..tonumber(Data))
                                        end
                                        RightClickTargetList[player] = nil
                                end
                        elseif Seqno == 71 then
                                local isgm = NLG.Get_Char_Date(player,145)
                                if isgm > 0 then
                                        if Select == 4 then
                                                Char.EndEvent(target,tonumber(Data),1)
                                                NLG.SystemMessage(player,"给予EndEvent "..tonumber(Data))
                                        elseif Select == 8 then
                                                Char.EndEvent(target,tonumber(Data),0)
                                                NLG.SystemMessage(player,"删除EndEvent "..tonumber(Data))
                                        end
                                        RightClickTargetList[player] = nil
                                end
                        end
                end
        end
end


回复

使用道具 举报

Archiver|魔力研究社

GMT+8, 2025-5-12 18:44 , Processed in 0.093863 second(s), 21 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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