Author Topic: ALPHABETICAL ORDER IN RIGHT CLICK COMMAND  (Read 5114 times)

0 Members and 1 Guest are viewing this topic.

Offline -Slash-

  • Member
  • ***
  • Posts: 37
  • Karma: +0/-0
ALPHABETICAL ORDER IN RIGHT CLICK COMMAND
« on: 22 May, 2005, 15:13:50 »
how to arrange alphabetically the rc commands?
i give them an order in the script but the commands don't appear tidy in the hub...i want to arrange them alphabetically!!!!

PtokaX forum

ALPHABETICAL ORDER IN RIGHT CLICK COMMAND
« on: 22 May, 2005, 15:13:50 »

Offline Tw?sT?d-d?v

  • Lord
  • ***
  • Posts: 436
  • Karma: +79/-2
    • EURO-OP
(No subject)
« Reply #1 on: 22 May, 2005, 15:27:15 »
Quote
Originally posted by -Slash-
how to arrange alphabetically the rc commands?
i give them an order in the script but the commands don't appear tidy in the hub...i want to arrange them alphabetically!!!!

Post here what you have already tried.

Offline Dessamator

  • Scripter
  • Emperor
  • ******
  • Posts: 1 262
  • Karma: +13/-9
(No subject)
« Reply #2 on: 22 May, 2005, 15:47:09 »
Quote
Originally posted by -Slash-
how to arrange alphabetically the rc commands?
i give them an order in the script but the commands don't appear tidy in the hub...i want to arrange them alphabetically!!!!

Cant be done, with zrightclicker because its stored in tables and the table sort command isnt stable, and it sorts by size , maybe changing the script, then u can sort it ,manually !!
Ignorance is Bliss.

Offline plop

  • Forum God
  • ****
  • Posts: 2 464
  • Karma: +37/-0
(No subject)
« Reply #3 on: 30 May, 2005, 13:55:56 »
Quote
Originally posted by Dessamator
Quote
Originally posted by -Slash-
how to arrange alphabetically the rc commands?
i give them an order in the script but the commands don't appear tidy in the hub...i want to arrange them alphabetically!!!!

Cant be done, with zrightclicker because its stored in tables and the table sort command isnt stable, and it sorts by size , maybe changing the script, then u can sort it ,manually !!
it can actualy be done, but it isn't a really nice way.
you would need a table and an array.
the table holds the user commands indexed by the command.
and the array only the commands.
now you can sort the array and loop that, using that 2 call the commands from the table.
all this should be done on function Main() 2 reduce the load.
this can also be done if you make your own sort function 2 sort the table (even more complex).

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Offline Dessamator

  • Scripter
  • Emperor
  • ******
  • Posts: 1 262
  • Karma: +13/-9
(No subject)
« Reply #4 on: 30 May, 2005, 14:55:56 »
hmmm indeed, ur right but as i said it cant be done with the current zrightlicker, u have to change its layout and functions, to accomodate it, :)
Ignorance is Bliss.

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 725
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
(No subject)
« Reply #5 on: 30 May, 2005, 15:31:27 »
Quote
Originally posted by Dessamator
hmmm indeed, ur right but as i said it cant be done with the current zrightlicker, u have to change its layout and functions, to accomodate it, :)

Loop through command table, insert the ready-to-send commands into an array, withoput $UC and context.  Do a table.sort and send the sorted array's elements to the connecting user. Wohoo! :P

(Easier way: submenus. :P)
« Last Edit: 30 May, 2005, 15:32:27 by bastya_elvtars »
Everything could have been anything else and it would have just as much meaning.

Offline Dessamator

  • Scripter
  • Emperor
  • ******
  • Posts: 1 262
  • Karma: +13/-9
(No subject)
« Reply #6 on: 30 May, 2005, 15:51:51 »
Quote
Originally posted by bastya_elvtars
Quote
Originally posted by Dessamator
hmmm indeed, ur right but as i said it cant be done with the current zrightlicker, u have to change its layout and functions, to accomodate it, :)

Loop through command table, insert the ready-to-send commands into an array, withoput $UC and context.  Do a table.sort and send the sorted array's elements to the connecting user. Wohoo! :P

(Easier way: submenus. :P)
RC, already has submenus, and furthermore, what u just said is theory, show us the practical use of it, with a simple example,
mr
Quote
Emperor bastya_elvtars
,
because i too have my theories about it, hehe, havent used them either , :)
Ignorance is Bliss.

Offline Tw?sT?d-d?v

  • Lord
  • ***
  • Posts: 436
  • Karma: +79/-2
    • EURO-OP
(No subject)
« Reply #7 on: 30 May, 2005, 17:18:36 »
so would something like this work bastya_elvtars ..

Code: [Select]
aMenu = "RULES"
bMenu = "HELP"

function NewUserConnected(curUser)
if curUser.bUserCommand then
curUser:SendData("$UserCommand 1 3 "..aMenu.."\\Rules$<%[mynick]> !rules|")
curUser:SendData("$UserCommand 1 3 "..bMenu.."\\Help$<%[mynick]> !help|")
« Last Edit: 30 May, 2005, 17:21:10 by (uk)jay »

Offline Dessamator

  • Scripter
  • Emperor
  • ******
  • Posts: 1 262
  • Karma: +13/-9
(No subject)
« Reply #8 on: 30 May, 2005, 18:53:01 »
Code: [Select]
-- RightClicker for RoboCopv10.01d
-- Added  ALPHABETICAL ORDER by Dessamator (request/idea by (uk)jay) --hints by plop and or bastya
-- Some small fixes by jiten
-- Made by Optimus & TiMeTrAVelleR
-- Optimized and fixed some stuff
-- Best is not to use it for normal users takes to much bandwidth

sMenu = "RC"

SendTo = { --> 1=on/0=off
[0] = 1,   -- Masters
[1] = 1,   -- Operators
[2] = 1,   -- Vips
[3] = 0,   -- Regs
[4] = 1,   -- Moderator
[5] = 1,   -- NetFounder
[-1] = 0,  -- Users
}

dofile("tbl/scriptlevel.tbl")
dofile("tbl/inbuildlevel.tbl")

-- End Editable Settings --

[COLOR=red]
-- Sorting the table in function main, hint idea by plop
function Main()
a = {}
for n,z in InbuildCmds do table.insert(a, z) end
for n,z in ScriptCmds do table.insert(a, z) end
table.sort(a)

end


GetRightClick = function(user)
for cmd,level in InbuildLevel do
for cmd1,level1 in ScriptLevel do
if InbuildLevel[cmd][user.iProfile] == 1 or ScriptLevel[cmd1][user.iProfile] == 1 then
if InbuildCmds[cmd] or ScriptCmds[cmd1] then
HasRightClick = true
end
end
end
end
if HasRightClick then
for i=1,table.getn(a) do user:SendData(a[i]") end
--user:SendData(table2[cmd]")
HasRightClick = false
end
end

NewUserConnected = function(user)
if SendTo[user.iProfile] == 1 then
if user.bUserCommand then
user:SendData("$UserCommand 0 3 |")
GetRightClick(user, ScriptLevel, ScriptCmds)  customCMDs(user)  --GetRightClick(user, InbuildLevel, InbuildCmds)
user:SendData(" Enhanced Right Click Support for [RoboCop] is available!")
end
end
end
[/COLOR]

OpConnected=NewUserConnected

ScriptCmds = {
["kick"]="$UserCommand 1 3 "..sMenu.."\\KICK/BAN\\Kick user$<%[mynick]> !kick %[nick] %[line:Reason]",
["ban"]="$UserCommand 1 3 "..sMenu.."\\KICK/BAN\\Ban user$<%[mynick]> !ban %[nick] %[line:Reason]",
}
InbuildCmds = {
["banip"]="$UserCommand 1 3 "..sMenu.."\\INBUILD\\Banip user$<%[mynick]> !banip %[line:Ipnumber]",
["unban"]="$UserCommand 1 3 "..sMenu.."\\INBUILD\\Unban user$<%[mynick]> !unban %[nick] %[line:nick/ip]",
}
customCMDs = function(user) --// You can put your custome commands here
--user:SendData("$UserCommand 1 3 zCUSTOM\\Test$<%[mynick]> !test||") -- Example line
end

Done !
btw, this is just an example the only thing i changed was the function in red.
« Last Edit: 31 May, 2005, 22:37:07 by Dessamator »
Ignorance is Bliss.

Offline Star

  • Double Ace
  • *
  • Posts: 100
  • Karma: +0/-0
(No subject)
« Reply #9 on: 31 May, 2005, 12:14:31 »
If i change the script as Dessamator instructed. All users get all commands. What's wrong?

Thanks //StarChild

Offline Dessamator

  • Scripter
  • Emperor
  • ******
  • Posts: 1 262
  • Karma: +13/-9
(No subject)
« Reply #10 on: 31 May, 2005, 19:06:52 »
all users ????, only if u defined it in this table :
Code: [Select]
SendTo = { --> 1=on/0=off
[0] = 1,   -- Masters
[1] = 1,   -- Operators
[2] = 1,   -- Vips
[3] = 0,   -- Regs
[4] = 1,   -- Moderator
[5] = 1,   -- NetFounder
[-1] = 0,  -- Users
}


but ill check the code and debug it (if it needs debugging)
Ignorance is Bliss.

Offline plop

  • Forum God
  • ****
  • Posts: 2 464
  • Karma: +37/-0
(No subject)
« Reply #11 on: 31 May, 2005, 19:28:03 »
Quote
Originally posted by Star
If i change the script as Dessamator instructed. All users get all commands. What's wrong?
he forgot 2 check the userlevels for the command before sending them.

beside that there is a nasty bug in this script.
using 2 end pipes can trigger bcdc based clients 2 start a kind of flood.
it keeps sending 1 of the user commands over and over.
unlike the old ptokax, ppk changed SendData so it adds the end pipe itself.
sending 2 from the script means that ptokax adds 1 more which make 3.

plop
« Last Edit: 31 May, 2005, 19:28:54 by plop »
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Offline Dessamator

  • Scripter
  • Emperor
  • ******
  • Posts: 1 262
  • Karma: +13/-9
(No subject)
« Reply #12 on: 31 May, 2005, 22:38:51 »
Quote
Originally posted by plop
Quote
Originally posted by Star
If i change the script as Dessamator instructed. All users get all commands. What's wrong?
he forgot 2 check the userlevels for the command before sending them.

beside that there is a nasty bug in this script.
using 2 end pipes can trigger bcdc based clients 2 start a kind of flood.
it keeps sending 1 of the user commands over and over.
unlike the old ptokax, ppk changed SendData so it adds the end pipe itself.
sending 2 from the script means that ptokax adds 1 more which make 3.

plop
indeed, ur right (once again) second error corrected, first error, hmm still have to think about it
Ignorance is Bliss.

Offline Star

  • Double Ace
  • *
  • Posts: 100
  • Karma: +0/-0
(No subject)
« Reply #13 on: 31 May, 2005, 23:01:37 »
Hi Dessamator,
Well. If I say it like this then. If I login as reg in my hub, I get all robos commands in the rightclick. Even them i don't have access to. Du u understand what I mean now?

Thanks //StarChild

Offline Dessamator

  • Scripter
  • Emperor
  • ******
  • Posts: 1 262
  • Karma: +13/-9
(No subject)
« Reply #14 on: 31 May, 2005, 23:31:53 »
yap i understood it, and ive fixed it, just have to fix a memory related bug, and ill post it
Ignorance is Bliss.

Offline Dessamator

  • Scripter
  • Emperor
  • ******
  • Posts: 1 262
  • Karma: +13/-9
(No subject)
« Reply #15 on: 31 May, 2005, 23:50:48 »
Code: [Select]
-- RightClicker for RoboCopv10.01d
-- Added  ALPHABETICAL ORDER by Dessamator (request/idea by (uk)jay) --hints by plop and or bastya
-- Some small fixes by jiten
-- Made by Optimus & TiMeTrAVelleR
-- Optimized and fixed some stuff
-- Best is not to use it for normal users takes to much bandwidth

sMenu = "RC"

SendTo = { --> 1=on/0=off
[0] = 1,   -- Masters
[1] = 1,   -- Operators
[2] = 1,   -- Vips
[3] = 0,   -- Regs
[4] = 1,   -- Moderator
[5] = 1,   -- NetFounder
[-1] = 0,  -- Users
}

dofile("tbl/scriptlevel.tbl")
dofile("tbl/inbuildlevel.tbl")

-- End Editable Settings --

[COLOR=red]
GetRightClick = function(user, table1, table2)

for cmd,level in table1 do
if table1[cmd][user.iProfile] == 1 then
if table2[cmd] then
table.insert(a,table2[cmd])
end
end
end
end

NewUserConnected = function(user)
if SendTo[user.iProfile] == 1 then
if user.bUserCommand then

a={}
user:SendData("$UserCommand 0 3 |")
GetRightClick(user, ScriptLevel, ScriptCmds) GetRightClick(user, InbuildLevel, InbuildCmds) customCMDs(user)
table.sort(a)
for i=1,table.getn(a) do user:SendData(a[i].."|")end
user:SendData(" Enhanced Right Click Support for [RoboCop] is available!")
a=nil
collectgarbage();io.flush();
end
end
end
[/COLOR]

OpConnected=NewUserConnected

ScriptCmds = {
["kick"]="$UserCommand 1 3 "..sMenu.."\\KICK/BAN\\Kick user$<%[mynick]> !kick %[nick] %[line:Reason]",
["ban"]="$UserCommand 1 3 "..sMenu.."\\KICK/BAN\\Ban user$<%[mynick]> !ban %[nick] %[line:Reason]",
}
InbuildCmds = {
["banip"]="$UserCommand 1 3 "..sMenu.."\\INBUILD\\Banip user$<%[mynick]> !banip %[line:Ipnumber]",
["unban"]="$UserCommand 1 3 "..sMenu.."\\INBUILD\\Unban user$<%[mynick]> !unban %[nick] %[line:nick/ip]",
}
customCMDs = function(user) --// You can put your custome commands here
--user:SendData("$UserCommand 1 3 zCUSTOM\\Test$<%[mynick]> !test||") -- Example line
end

Done !, P.S.: The Custom Cmds, arent in a table, if u add them they will appear "out of order"
« Last Edit: 31 May, 2005, 23:53:57 by Dessamator »
Ignorance is Bliss.

Offline plop

  • Forum God
  • ****
  • Posts: 2 464
  • Karma: +37/-0
(No subject)
« Reply #16 on: 01 June, 2005, 00:11:06 »
hint:
Code: [Select]
ScriptCmds = {
["kick"] = {
sCom = "$UserCommand 1 3 "..sMenu.."\\KICK/BAN\\Kick user$<%[mynick]> !kick %[nick] %[line:Reason]",
tLevels = {
[0]=1,
[1]=1,
}
},
["ban"] = {
  sCom = "$UserCommand 1 3 "..sMenu.."\\KICK/BAN\\Ban user$<%[mynick]> !ban %[nick] %[line:Reason]",
  tLevels = {
[0]=1,
[1]=1,
}
},
---etc...
}

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Offline Star

  • Double Ace
  • *
  • Posts: 100
  • Karma: +0/-0
(No subject)
« Reply #17 on: 01 June, 2005, 00:41:29 »
Nice job Dessamator! Works perfect now.

Thanks
/Star

Offline Dessamator

  • Scripter
  • Emperor
  • ******
  • Posts: 1 262
  • Karma: +13/-9
(No subject)
« Reply #18 on: 01 June, 2005, 13:00:46 »
ur welcome start

and plop, still im working on it, ( trying )
Ignorance is Bliss.

PtokaX forum

(No subject)
« Reply #18 on: 01 June, 2005, 13:00:46 »