PtokaX forum

Lua 5.3/5.2/5.1 Scripts (for PtokaX 0.4.0.0 and newer) => Finished Scripts => Topic started by: speedX on 03 January, 2008, 09:47:21

Title: Move Script Up or Down in PtokaX
Post by: speedX on 03 January, 2008, 09:47:21
Hi, posting my first basic script in this forum. Please post your comments as well as problems/bugs regarding this script.


-- Move Script Up or Down in PtokaX [NEW API] [Strict] by speedX (04/01/08)
-- Version 1.0

-- Note:
-- Please Dont add .lua extension (the script automatically adds the extension)

tSettings = {
 -- Bot Name
sBot = SetMan.GetString(21),

-- Hub Name
sHubName = SetMan.GetString(0),

-- Rightclick: Enable = true, Disable = false
bRC = true,

-- Commands
sMoveDown = "movedown",
sMoveUp = "moveup",

-- 1 = Allow ; 0 = Don't Allow
Levels = {
       [-1] = 0,       -- Unregistered User
       [0] = 1,        -- Master
       [1] = 0,        -- Operator
       [2] = 0,        -- Vip
       [3] = 0,        -- Registered User
       }
           
}

function OnStartup()
       Core.RegBot(tSettings.sBot,"","",true)
end

ChatArrival = function(User,Data)
if tSettings.Levels[User.iProfile] == 1 then
local _,_,cmd,file = string.find(Data, "%b<>%s%p([^ ]+)%s*([^|]*)")
 file = string.lower(file)
 f = ""..file..".lua"
if cmd and (cmd == tSettings.sMoveUp) then
   ScriptMan.MoveUp(f)
Core.SendToNick(User.sNick,"<"..tSettings.sBot.."> "..f.." has been successfully Moved Up.")
return true
elseif cmd and (cmd == tSettings.sMoveDown) then
   ScriptMan.MoveDown(f)
Core.SendToNick(User.sNick,"<"..tSettings.sBot.."> "..f.." has been successfully Moved Down.")
return true
end
else
  Core.SendToNick(User.sNick,"<"..tSettings.sBot.."> You are not allowed to use this command.")
  return true
end
end

UserConnected = function(User)
if tSettings.Levels[User.iProfile] == 1 then
if tSettings.bRC then
Core.SendToNick(User.sNick,"$UserCommand 1 3 "..tSettings.sHubName.."\\Move Up Script$<%[mynick]> !moveup %[line:Script Name]&#124;")
   Core.SendToNick(User.sNick,"$UserCommand 1 3 "..tSettings.sHubName.."\\Move Down Script$<%[mynick]> !movedown %[line:Script Name]&#124;")
end
end
end
OpConnected = UserConnected
RegConnected = UserConnected
Title: Re: Move Script Up or Down in PtokaX
Post by: Yahoo on 03 January, 2008, 12:20:43
great work  :D
Title: Re: Move Script Up or Down in PtokaX
Post by: Madman on 03 January, 2008, 12:58:46
NewUserConnected should be UserConnected other than that, it looks okey =)
Title: Re: Move Script Up or Down in PtokaX
Post by: CrazyGuy on 03 January, 2008, 14:06:54
Core.GetUserAllData(User)

You use this line in both UserConnected and in ChatArrival.
I'm not sure what you want with it, i guess you copied this from a script converted by Hungarista's converter ?  :P
Either way, it is useless in both functions.
Its purpose is to fill the User object table with all values, but the only value you use is iProfile which is always available in the table, therefor the call does nothing but increase script memory usage.

Otherwise looks pretty good  :)
Title: Re: Move Script Up or Down in PtokaX
Post by: speedX on 03 January, 2008, 16:20:08
Quote from: CrazyGuy on 03 January, 2008, 14:06:54
You use this line in both UserConnected and in ChatArrival.
I'm not sure what you want with it, i guess you copied this from a script converted by Hungarista's converter ?  :P
Either way, it is useless in both functions.
Its purpose is to fill the User object table with all values, but the only value you use is iProfile which is always available in the table, therefor the call does nothing but increase script memory usage.

Otherwise looks pretty good  :)

Done, actually I had seen tht in one of the scripts converted by Hungarista's Converter, so thought tht it might be necessary. Anyways I have edited the script.

Thank you Madman and CrazyGuy for your replies...
Title: Re: Move Script Up or Down in PtokaX
Post by: rediff on 03 January, 2008, 16:20:46
nice script speedx
congrats
Title: Re: Move Script Up or Down in PtokaX
Post by: ?StIfFLEr?? on 30 October, 2008, 04:01:00
its a great script but i would love to have an option where in i can place the two command where ever i want on the rigght click
like
<hubname>\\<ur scriptname>\\<and the 2 option>
Title: Re: Move Script Up or Down in PtokaX
Post by: speedX on 30 October, 2008, 06:42:05
Quote from: ?StIfFLEr?? on 30 October, 2008, 04:01:00
its a great script but i would love to have an option where in i can place the two command where ever i want on the rigght click
like
<hubname>\\<ur scriptname>\\<and the 2 option>

It is already given in the script.


UserConnected = function(User)
if tSettings.Levels[User.iProfile] == 1 then
if tSettings.bRC then
Core.SendToNick(User.sNick,"$UserCommand 1 3 "..tSettings.sHubName.."\\Move Up Script$<%[mynick]> !moveup %[line:Script Name]&#124;")
   Core.SendToNick(User.sNick,"$UserCommand 1 3 "..tSettings.sHubName.."\\Move Down Script$<%[mynick]> !movedown %[line:Script Name]&#124;")
end
end
end
OpConnected = UserConnected
RegConnected = UserConnected
Title: Re: Move Script Up or Down in PtokaX
Post by: ?StIfFLEr?? on 30 October, 2008, 10:27:16
sorry i noticed it when i was reading the script....
forgot to update the forum
sorry for the trouble
its indeed a nice script atleast i wont have to use ptokax now again and again