PtokaX forum

Development Section => Your Developing Problems => Topic started by: -Slash- on 22 May, 2005, 15:13:50

Title: ALPHABETICAL ORDER IN RIGHT CLICK COMMAND
Post by: -Slash- 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!!!!
Title:
Post by: Tw?sT?d-d?v on 22 May, 2005, 15:27:15
QuoteOriginally 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.
Title:
Post by: Dessamator on 22 May, 2005, 15:47:09
QuoteOriginally 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 !!
Title:
Post by: plop on 30 May, 2005, 13:55:56
QuoteOriginally posted by Dessamator
QuoteOriginally 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
Title:
Post by: Dessamator 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, :)
Title:
Post by: bastya_elvtars on 30 May, 2005, 15:31:27
QuoteOriginally 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)
Title:
Post by: Dessamator on 30 May, 2005, 15:51:51
QuoteOriginally posted by bastya_elvtars
QuoteOriginally 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
QuoteEmperor bastya_elvtars
,
because i too have my theories about it, hehe, havent used them either , :)
Title:
Post by: Tw?sT?d-d?v on 30 May, 2005, 17:18:36
so would something like this work bastya_elvtars ..

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|")
Title:
Post by: Dessamator on 30 May, 2005, 18:53:01
-- 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.
Title:
Post by: Star 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
Title:
Post by: Dessamator on 31 May, 2005, 19:06:52
all users ????, only if u defined it in this table :
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)
Title:
Post by: plop on 31 May, 2005, 19:28:03
QuoteOriginally 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
Title:
Post by: Dessamator on 31 May, 2005, 22:38:51
QuoteOriginally posted by plop
QuoteOriginally 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
Title:
Post by: Star 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
Title:
Post by: Dessamator 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
Title:
Post by: Dessamator on 31 May, 2005, 23:50:48
-- 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"
Title:
Post by: plop on 01 June, 2005, 00:11:06
hint: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
Title:
Post by: Star on 01 June, 2005, 00:41:29
Nice job Dessamator! Works perfect now.

Thanks
/Star
Title:
Post by: Dessamator on 01 June, 2005, 13:00:46
ur welcome start

and plop, still im working on it, ( trying )