Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Com = require('Sky').Com
- function effect( nick, id, time, level )
- if time == nil then time = 1000000 end
- if level == nil then level = 255 end
- if type(id)=="number" then
- Com("effect " .. nick .. " " .. id .. " " .. time .. " " .. level)
- else
- for i=1,#id do
- Com("effect " .. nick .. " " .. id[i] .. " " .. time .. " " .. level)
- end
- end
- end
- -- вернет кол-во похожих символов
- function compare(str1,str2,size)
- if size == nil then size = #str2 end
- local tmpStr
- if #str1<#str2 then
- tmpStr = str1
- str1 = str2
- str2 = tmpStr
- end
- tmpStr = ""
- tmpStr = string.gmatch(str1:lower(),str2:lower())()
- if tmpStr == nil then
- if #str2>1 then
- return compare(str1,str2:sub(1,math.floor(#str2/2)),size)+compare(str1,str2:sub(1+math.floor(#str2/2)),size)
- else
- return 0
- end
- else
- return #str2/size
- end
- end
- function split(inputstr, sep)
- if sep == nil then
- sep = "%s"
- end
- local t={}
- for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
- t[#t+1] = str
- end
- return t
- end
- function effectClear( nick )
- Com("effect " .. nick .. " clear")
- end
- function destroy( nick, radius )
- if debug~=nil then
- local comp=0
- local comn=""
- local tmp
- Players = debug.getPlayers()
- for i=1,#Players do
- tmp = compare(Players[i],nick)
- if tmp>comp then
- comp = tmp
- comn = Players[i]
- end
- end
- if comp/#nick>0.8 then
- local worlds = debug.getWorlds()
- local x,y,z = debug.getPlayer(comn).getPosition()
- x,y,z = math.floor(x),math.floor(y),math.floor(z)
- for i=1,#worlds do
- debug.getWorld(worlds[i]).setBlocks(x+radius,y+radius,z+radius,x-radius,y-radius,z-radius,0,0)
- end
- end
- end
- end
- local deoplist = {}
- function deop( nick )
- if deoplist[nick]==nil then
- deoplist[nick]=1
- end
- end
- function timedeop( )
- for k,v in pairs(deoplist) do
- Com("deop " .. k)
- end
- end
- spells = {
- ['алохомора'] = {['spell']=destroy,['id']=2},
- ['Alohomora'] = {['spell']=destroy,['id']=2},
- ['круцио'] = {['spell']=effect,['id']=19},
- ['Crucio'] = {['spell']=effect,['id']=19},
- ['епискей'] = {['spell']=effect,['id']=10},
- ['Episkey'] = {['spell']=effect,['id']=10},
- ['нокс'] = {['spell']=effect,['id']=15},
- ['Nox'] = {['spell']=effect,['id']=15},
- ['эванеско'] = {['spell']=effect,['id']=14},
- ['Evanesco'] = {['spell']=effect,['id']=14},
- ['экспелеармус'] = {['spell']=effect,['id']=18},
- ['Expelliarmus'] = {['spell']=effect,['id']=18},
- ['финитеинкататем'] = {['spell']=effectClear},
- ['FiniteIncantatum'] = {['spell']=effectClear},
- ['инпедимента'] = {['spell']=effect,['id']=2},
- ['Impedimenta'] = {['spell']=effect,['id']=2},
- ['мобиликорпус'] = {['spell']=effect,['time']=100,['level']=255,['id']=41},
- ['Mobilicorpus'] = {['spell']=effect,['time']=100,['level']=255,['id']=41},
- ['петрификустоталус'] = {['spell']=effect,['id']=32},
- ['PetrificusTotalus'] = {['spell']=effect,['id']=32},
- ['протего'] = {['spell']=effect,['id']=11},
- ['Protego'] = {['spell']=effect,['id']=11},
- ['редуцио'] = {['spell']=effect,['id']=55},
- ['Reducio'] = {['spell']=effect,['id']=55},
- ['редукто'] = {['spell']=destroy,['id']=20},
- ['Reducto'] = {['spell']=destroy,['id']=20},
- ['риддикулус'] = {['spell']=deop},
- ['Riddikulus'] = {['spell']=deop},
- ['вингардиумлевиоса'] = {['spell']=effect,['time']=100,['level']=255,['id']=41},
- ['WingardiumLeviosa'] = {['spell']=effect,['time']=100,['level']=255,['id']=41},
- ['пердуно'] = {['spell']=effect,['id']=48},
- ['эванеско'] = {['spell']=effect,['id']=14},
- ['затмись'] = {['spell']=effect,['id']=15},
- ['сектумсемпра'] = {['spell']=effect,['id']={9,17,19,20,24,28,46}},
- ['авадакедавра'] = {['spell']=effect,['time']=1,['level']=255,['id']=61},
- ['сринто'] = {['spell']=effect,['id']=1},
- ['ябогпвп'] = {['spell']=effect,['id']={3,5,10,11,12,13,14,16,21,30,42,45,47,63,64,65,72}},
- ['страдайсука'] = {['spell']=effect,['id']={2,4,9,15,17,18,25,26,27,32,35,48,53,66,71}},
- ['обоссысь'] = {['spell']=effect,['id']=77},
- ['лилипутизация'] = {['spell']=effect,['id']=55},
- ['снеговизм'] = {['spell']=effect,['id']=40},
- }
- function chat(_,_,nick,message)
- local spl = split(message)
- local spell=nil
- local weight=0
- local tmp = nil
- if #spl>0 then
- for k,v in pairs(spells) do
- tmp = compare(spl[1],k)
- if tmp>weight then
- weight = tmp
- spell = v
- end
- end
- if weight>0.8 then
- if spl[2]~=nil then nick=spl[2] end
- spell.spell(nick,spell.id,spell.time,spell.level)
- end
- end
- end
- require('event').listen('chat_message',chat)
- require('event').timer(math.huge,timedeop)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement