PtokaX forum

Lua 5.3/5.2/5.1 Scripts (for PtokaX 0.4.0.0 and newer) => Finished Scripts => Topic started by: Tw?sT?d-d?v on 04 November, 2007, 18:20:35

Title: Wave [New API]
Post by: Tw?sT?d-d?v on 04 November, 2007, 18:20:35

-- lua5(by Dessamator)
-- Wave by DirtyFingers
-- on/off and more.. by Hawk
--// Converted to NEW API by Tw?sT?d-d?v?l (28/10/07)
--// Added Rightclicker too   1=on/0=off

Wave = {
        [0] = 1, -- Master
        [1] = 1, -- Operator
}

wavepart = "??..??''???``''??..??_"
--          1234567890123456789012
pos = 1
wholewave = string.rep(wavepart,4)
active = 0
function OnStartup()

end


function OnTimer(tmr)
if pos > 1 then
pos = pos-1
else
pos = 22
end
local c = string.sub(wavepart,pos,pos)
wholewave = c..string.sub(wholewave,1,string.len(wholewave)-1)
--SendToAll("",c.."\t"..string.sub(wholewave,string.len(wholewave)-1,string.len(wholewave)-1))
Core.SendToAll("<".."*".."> "..wholewave.." <*>")
end


function ChatArrival(curUser,sData)
Core.GetUserAllData(curUser)
command=string.sub(sData,1,string.len(sData)-1)
s,e,cmd = string.find(command,"%b<>%s+(%S+)")
if curUser.bOperator then
if cmd=="!waveon" then
tmr = TmrMan.AddTimer(200)
active = 1
elseif cmd=="!waveoff" then
  TmrMan.RemoveTimer(tmr)
active = 0
end
end
if active ~= 0 then
local s,i
_,i = (string.find(sData,"<"..curUser.sNick.."> "))
if i ~= nil then
s = string.sub(sData,i+1,string.len(sData)-1)
if ( string.sub(sData, 1, 4) == "$To:" ) then
s,e,g,h,j = string.find(sData,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(.*)")
j = string.sub(j,1,string.len(j)-1)
Core.SendPmToNick(g,h,j)
else
if string.len(s) < string.len(wholewave) then
wholewave = s .. string.sub(wholewave,string.len(s))
else
wholewave = string.sub(s,string.len(wholewave))
end
end
end
return true
end
end

OpConnected = function(user)
Core.GetUserAllData(user)
             if (Wave[user.iProfile] == 1) then
Core.SendToNick(user.sNick,"$UserCommand 1 3 Wave\\Start Wave$<%[mynick]> !waveon&#124;")
                Core.SendToNick(user.sNick,"$UserCommand 1 3 Wave\\Stop Wave$<%[mynick]> !waveoff&#124;")
end
end