Move Script Up or Down in PtokaX
 

Move Script Up or Down in PtokaX

Started by speedX, 03 January, 2008, 09:47:21

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

speedX

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
Thanking You,

speedX

Yahoo

"BoRN FIGhTEr"

Madman

NewUserConnected should be UserConnected other than that, it looks okey =)
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

CrazyGuy

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  :)

speedX

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...
Thanking You,

speedX

rediff


?StIfFLEr??

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>

speedX

#7
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
Thanking You,

speedX

?StIfFLEr??

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

SMF spam blocked by CleanTalk