Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AllowSummonFromNames = {};
- AcceptSummonFromAll = false;
- DeclineUnAllowedPlayersSummons = true;
- function CheckIfInsideList(Smsg,Rmsglist)
- if (Rmsglist ~= nil) then
- for x=1,#Rmsglist do
- if (Rmsglist[x] == Smsg) then
- return true;
- end;
- end;
- end;
- return false;
- end;
- function OnCreate()
- -- from summoner plugin
- Event_PacketUnBlock(0xF3,0xFF,1); --0x0732 0x732
- this:RegisterCommand("chatbot", CommandChatType.CHAT_ALLY, CommandAccessLevel.ACCESS_ME);
- ENABLED = false;
- DEFAULT_BUFFING_MAX_RANGE = 300;
- admins = {
- "Zanfas",
- "xwlx",
- "xbpx",
- "Bezbel",
- "Mekinjar",
- "xbdx",
- "xswsx",
- "xppx",
- "Isus",
- "Yeeeea",
- "HurtMe",
- "Farbeyonddriven",
- "Onomad",
- "Decartes",
- "Newton",
- "Pascal",
- "Leibniz",
- "Ramanujan",
- "Gauss"
- }
- commands = {};
- commands['follow'] = {}
- commands['follow']['type'] = "misc"
- commands['leave'] = {}
- commands['leave']['type'] = "leave"
- commands['invite'] = {}
- commands['invite']['type'] = "invite"
- commands['buff'] = {}
- commands['buff']['type'] = "buff"
- commands['command'] = {}
- commands['command']['type'] = "command"
- commands['-c'] = {}
- commands['-c']['type'] = "ccommand"
- commands['-s'] = {}
- commands['-s']['type'] = "say"
- commands['sstart'] = {}
- commands['sstart']['type'] = "scriptstart"
- commands['sstop'] = {}
- commands['sstop']['type'] = "scriptstop"
- commands['stop'] = {}
- commands['stop']['type'] = "stop"
- skills = {};
- skills[1] = {};
- skills[1]['id'] = 1393
- skills[1]['name'] = 'Unholy Resistance';
- skills[1]['alias'] = 'ur';
- skills[1]['requireParty'] = false;
- skills[1]['requireTarget'] = true;
- skills[2] = {};
- skills[2]['id'] = 1191
- skills[2]['name'] = 'Resist Fire';
- skills[2]['alias'] = 'rf';
- skills[2]['requireParty'] = false;
- skills[2]['requireTarget'] = true;
- skills[3] = {};
- skills[3]['id'] = 1189
- skills[3]['name'] = 'Resist Wind';
- skills[3]['alias'] = 'rw';
- skills[3]['requireParty'] = false;
- skills[3]['requireTarget'] = true;
- skills[4] = {};
- skills[4]['id'] = 1182
- skills[4]['name'] = 'Resist Aqua';
- skills[4]['alias'] = 'ra';
- skills[4]['requireParty'] = false;
- skills[4]['requireTarget'] = true;
- skills[5] = {};
- skills[5]['id'] = 1352
- skills[5]['name'] = 'Elemental Protection';
- skills[5]['alias'] = 'ep';
- skills[5]['requireParty'] = false;
- skills[5]['requireTarget'] = true;
- skills[6] = {};
- skills[6]['id'] = 307
- skills[6]['name'] = 'Dance of Aqua Guard';
- skills[6]['alias'] = 'doa';
- skills[6]['requireParty'] = true;
- skills[6]['requireTarget'] = false;
- skills[7] = {};
- skills[7]['id'] = 306
- skills[7]['name'] = 'Song of Flame Guard';
- skills[7]['alias'] = 'sof';
- skills[7]['requireParty'] = true;
- skills[7]['requireTarget'] = false;
- skills[8] = {};
- skills[8]['id'] = 308
- skills[8]['name'] = 'Song of Storm Guard';
- skills[8]['alias'] = 'sos';
- skills[8]['requireParty'] = true;
- skills[8]['requireTarget'] = false;
- skills[9] = {};
- skills[9]['id'] = 1397
- skills[9]['name'] = 'Clarity';
- skills[9]['alias'] = 'cl';
- skills[9]['requireParty'] = false;
- skills[9]['requireTarget'] = true;
- skills[10] = {};
- skills[10]['id'] = 1353
- skills[10]['name'] = 'Divine Protection';
- skills[10]['alias'] = 'dp';
- skills[10]['requireParty'] = false;
- skills[10]['requireTarget'] = true;
- skills[11] = {};
- skills[11]['id'] = 1354
- skills[11]['name'] = 'Arcane Protection';
- skills[11]['alias'] = 'ap';
- skills[11]['requireParty'] = false;
- skills[11]['requireTarget'] = true;
- skills[12] = {};
- skills[12]['id'] = 270
- skills[12]['name'] = 'Song of Invocation';
- skills[12]['alias'] = 'soi';
- skills[12]['requireParty'] = true;
- skills[12]['requireTarget'] = false;
- skills[13] = {};
- skills[13]['id'] = 1303
- skills[13]['name'] = 'Wild Magic';
- skills[13]['alias'] = 'wm';
- skills[13]['requireParty'] = false;
- skills[13]['requireTarget'] = true;
- skills[14] = {};
- skills[14]['id'] = 1388
- skills[14]['name'] = 'Greater Might';
- skills[14]['alias'] = 'gm';
- skills[14]['requireParty'] = true;
- skills[14]['requireTarget'] = true;
- skills[15] = {};
- skills[15]['id'] = 1389
- skills[15]['name'] = 'Greater Shield';
- skills[15]['alias'] = 'gs';
- skills[15]['requireParty'] = true;
- skills[15]['requireTarget'] = true;
- function getSkillId(sknm)
- local Skills = GetSkills();
- for Skill in Skills.list do
- if (Skill.name == sknm) then
- return Skill.skillId;
- end;
- end;
- return nil
- end;
- function useSkill(skillId, requireTarget, requireParty, requestSender, targetName, maxRange, cType)
- ready = isSkillReady(skillId);
- if ready ~= nil then
- if ready then
- ok = true
- target = nil
- if isTargetInRange(targetName, maxRange) then
- if requireTarget then
- target = getTarget(targetName)
- end
- if (requireParty) then
- if GetUserByName(targetName):IsMyPartyMember() == false then
- if(requestSender ~= targetName) then
- SendPM(requestSender, targetName.." is not member of my party!")
- else
- SendPM(requestSender, "You are not member of my party!")
- end
- ok = false;
- end
- end
- else
- if(requestSender ~= targetName) then
- SendPM(requestSender, targetName.." is too far!")
- else
- SendPM(requestSender, "You are too far!")
- end
- ok = false;
- end
- if ok then
- UseSkillRaw(skillId, false, false)
- else
- ShowToClient("error", "error")
- end
- else
- SendPM(requestSender, "That skill is on reuse.")
- end
- else
- if cType == 2 then
- SendPM(requestSender, "I don't have such skill.")
- end
- end
- end
- function getTarget(targetName)
- Command("/target "..targetName);
- return GetTarget();
- end
- function isTargetInRange(targetName, maxRange)
- return GetMe():GetRangeTo(GetUserByName(targetName)) <= maxRange
- end
- function isSkillReady(skillId)
- local skills = GetSkills();
- for skill in skills.list do
- if (skill.skillId == skillId) then
- return skill:CanBeUsed();
- end;
- end;
- return nil
- end;
- function trimr(s)
- return s:find'^%s*$' and '' or s:match'^(.*%S)'
- end
- function buff(playerName, buffName, cType)
- skillIndex = 0;
- for i = 1, table.getn(skills) do
- if skills[i]['alias'] == buffName or skills[i]['name'] == buffName then
- skillIndex = i;
- break;
- end
- end
- if skillIndex == 0 then
- if cType == 2 then
- SendPM(playerName, "That buff is unknown to me.")
- end
- else
- useSkill(skills[skillIndex]['id'], skills[skillIndex]['requireTarget'], skills[skillIndex]['requireParty'], playerName, playerName, 300, cType)
- end
- end
- end;
- function stop()
- loc = GetMe():GetLocation();
- x = loc.X - 1;
- y = loc.Y;
- z = loc.Z;
- MoveToNoWait(x, y, z)
- ClearTargets();
- CancelTarget(false);
- CancelTarget(false);
- CancelTarget(false);
- end
- -- function OnCommand_chatbot(vCommandChatType, vNick, vCommandParam)
- -- if (ENABLED) then
- -- ENABLED = false;
- -- ShowToClient("ChatBot","DISABLED");
- -- else
- -- ENABLED = true;
- -- ShowToClient("ChatBot","ENABLED");
- -- end;
- -- end;
- function OnChatUserMessage(chatType, nick, msg)
- pcall(protectedOnChatUserMessage, chatType, nick, msg);
- end;
- function protectedOnChatUserMessage(cType, cNm, cMsg)
- -- ShowToClient(tostring(cType), "asd");
- -- ShowToClient("chatbot", tostring(ENABLED))
- -- if ENABLED then
- -- ShowToClient("chatbot", "chating is enabled")
- if cNm ~= GetMe():GetName() then
- if cType ==2 or cType == 3 then
- for i, admin in ipairs(admins) do
- if admin == cNm then
- words = {}
- local command = ""
- i = 0
- params = {}
- params[1] = ""
- paramsString = ""
- for w in cMsg:gmatch("%S+") do
- if i > 0 then
- params[i] = w
- paramsString = paramsString..w.." "
- else
- command = w
- end
- i = i + 1
- end
- if command ~= "" then
- if commands[command] ~= nil then
- if commands[command]['type'] == "command" then
- if paramsString ~= "" then
- Command(paramsString)
- else
- SendPM(admin, "I need atleast one parameter!")
- end
- elseif commands[command]['type'] == "invite" then
- Command("/invite "..cNm)
- elseif commands[command]['type'] == "leave" then
- Command("/leave")
- elseif commands[command]['type'] == "stop" then
- stop();
- elseif commands[command]['type'] == "scriptstart" then
- Command(".scriptstart "..trimr(paramsString)..".lua")
- elseif commands[command]['type'] == "scriptstop" then
- Command(".scriptstop "..trimr(paramsString)..".lua")
- elseif commands[command]['type'] == "ccommand" then
- Command("/"..paramsString)
- elseif commands[command]['type'] == "say" then
- Command(paramsString)
- elseif command == "buff" then
- buff(cNm, trimr(paramsString), cType)
- stop();
- end
- end
- end
- end
- end
- end
- end
- end;
- function OnIncomingPacket(packet)
- ShowToClient("asd", "asd")
- --F3 (packet id) confirm dlg
- --32 07 00 00 -- (type) in this case its summoning accept/decline window
- --02 00 00 00 -- how many data will be provided for this window
- --0C 00 00 00 -- type of data of first (in this case 0C is string)
- --4A 00 55 00 3E 00 70 00 71 00 6C 00 65 00 00 00 -- (the data as name of user summoning(string))
- --07 00 00 00 -- type of data of second (in this case 7 is coordinates(3 int variables x,y,z))
- --83 3F 01 00 -- X
- --17 47 02 00 -- Y
- --78 F2 FF FF -- Z
- --30 75 00 00 -- Time in mille seconds until the window automaticaly closes with a decline answer if no response
- --8D 99 70 4A -- Message Id which is needed to be added in the DLG answer to indicate the answer for this message.
- packet:SetOffset(0)
- if (packet:GetID() == 0xF3 and packet:ReadInt(4) == 1842) then
- packet:SetOffset(12)
- local SummonerName = packet:ReadString();
- --ShowToClient("Summoner Name",tostring(SummonerName))
- packet:Move(20);
- local MsgId = packet:ReadInt(4);
- --ShowToClient("Message Id",tostring(MsgId))
- if AcceptSummonFromAll or CheckIfInsideList(SummonerName,AllowSummonFromNames) then
- packet:BlockMe();
- AnswerDlg(1842,true,MsgId);
- ShowToClient("Summon Plugin","Summon from " .. SummonerName .. " has been Accepted.");
- elseif DeclineUnAllowedPlayersSummons then
- packet:BlockMe();
- AnswerDlg(1842,false,MsgId);
- ShowToClient("Summon Plugin","Summon from " .. SummonerName .. " has been Rejected.");
- end;
- end;
- end;
- function AnswerDlg(dlgtype,answer,messageid)
- -- C6 (DlgAnswer packetId)
- -- (MessageID):Int
- -- (Answer):Int
- -- (Messgae Id):Int
- pb = PacketBuilder();
- pb:AppendInt(0xC6,1);
- pb:AppendInt(dlgtype,4);
- if answer then
- pb:AppendInt(1,4);
- else
- pb:AppendInt(0,4);
- end;
- pb:AppendInt(messageid,4);
- SendPacket(pb);
- end;
- -- function OnMagicSkillUse(user, target, skillId)
- -- if user:IsPlayer() and target:IsMe() then
- -- ShowToClient("SKILL ID",tostring(skillId));
- -- end
- -- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement