PtokaX forum

Archive => HOW-TO's => Archived 5.1 boards => Old HOW-TO's => Topic started by: Dessamator on 16 May, 2005, 21:53:33

Title: How To Create Right clicks
Post by: Dessamator on 16 May, 2005, 21:53:33
-->>right clicks for users <<--
first of all create a function for normal users::eg.reg, unreg, vip, etc :

function NewUserConnected(User)    

end  
 

and for ops :

function Opconnected(User)

end


after add code like this example :
$UserCommand
|
User:SendData("$UserCommand 1 3 help$<%[mynick]> !help|")  

now for the explanation :

User:SendData -- Sends info to the users client
$UserCommand 1 3 -- the right click command is sent
1 -- the type :

Quote is a positive integer describing the kind of command, where:
0 = separator
1 = raw
2 = raw-nick-limited (same as raw with the exception that it should only be used once per %[nick])
255 = erase all sent commands (MAY BE REMOVED, CONFUSES PEOPLE)stands for context menu
3 --stands for the context where it will appear:

tells in which context the command should be shown, where:
1 = Hub command (View hub rules for example, change own password)
this command should contain no 'somenick' arguments (i.e. not %[nick] but it may contain %[mynick] or %[line:blah])
2 = User command (Show someones stats for example, ban someone)
this command may take nick-specific arguments
4 = User file command (Report bad file found for example)
this command may take nick- and file-specific arguments
8 = Filelist command (Report a bad file found then browsing a filelist for example)
this command may take nick- and file-specific arguments
This context is new in DC++ 0.669


now for the details :

help -- thats the name of the command,
if u want to add a menu, just put \\
e.g : right click\\help

$<%[mynick]> -- simply sends the info that ur nick is sending the command to main chat

!help -- thats the command
| -- the escape

to add a dialog box for a command just add something like : %[line:description]
and to add a nick when using the search menu, or user list use %[nick]
eg:
User:SendData("$UserCommand 1 3 op commands\\Kick user$<%[mynick]> !kick %[nick] %[line:Reason]|")  

other stuff:

QuoteSeparator
$UserCommand 0 |
Will add a menu separator (vertical bar) to the specified contexts ().
 

QuoteErase
$UserCommand 255 |
 
Will erase all commands that the hub has sent previously. This is for hubs/scripts that allow for updates while running.

for more info on those that refer to
this (http://dcplusplus.sourceforge.net/wiki/index.php/UserCommand%20command)
Title:
Post by: jiten on 16 May, 2005, 22:04:11
Nice one Dessamator!
Surely this one will help lots of users... :D

Cheers m8
Title:
Post by: TTB on 16 May, 2005, 22:05:47
nice one!

Title:
Post by: Dessamator on 16 May, 2005, 22:07:43
QuoteOriginally posted by jiten
Nice one Dessamator!
Surely this one will help lots of users... :D

Cheers m8

and scripters too, hehe less work for us(that was my plan from the beginning)
:)

thnx TTB

Any suggestions or corrections are welcome !
Title:
Post by: bastya_elvtars on 25 May, 2005, 01:10:12
Make

OpConnected=NewUserConnected
and a table

rc_prof=
[-1]="...",
[0]="...",
-- etc.
}

Where you have tables as values, tables contain many string values starting with $UserCommand

Thus you can make profile-based rightclick menus.

Also, you can do this:
function NewUserConnected(user)
 if usr.bUserCommand then
   SendRiteclickToThatGuyNow(user)
 end
end

thus not sending rightclick who have it disabled, or their client does not support it, and you save resources.
Title:
Post by: Dessamator on 25 May, 2005, 10:08:51
hmm indeed, well done bastya :))
Title: Small example
Post by: XPMAN on 25 May, 2005, 16:49:37
Appreciate the tutorial. This is exactly what i have been trying to do. One thing though. I have tried and tried and get errors. I have looked thru the tutorial and read it several times, guess I am slower then i thought when it comes to the learning process :) . Would it be possible to give a short script example such as making a in a right click say called  TEXT  which expands out to let you choose text files? I plan on using the text script built in PtokaX to call on the text files in the text folder.  Dont need a custom script, if i did i would just post in the request section :) I wanna try to do this on my own, just wanted to see the layout , I can take it from there...i hope anyways :). Just maybe show all together what it would look like. I realize its probably something easy for most, but........well, not for me :) I just cant seem to get everything in the right order or something.  Thanx guys.
Title: WooHooooo
Post by: XPMAN on 25 May, 2005, 17:40:38
Finally got it ....lol , Now for the profile specific.  More info and "How-to's) would be great :)
Title:
Post by: bastya_elvtars on 25 May, 2005, 17:51:45
First read this (http://dcplusplus.sourceforge.net/wiki/index.php/UserCommand%20command).

You say example script? Hmm, ok.

-- This script was written by bastya_elvtars
-- Helps you to learn writing scripted usercomands
-- Originally requested by XPMAN, but many can benefit from it
-- Don't forget to see the description of the protocol:

-- [URL]http://dcplusplus.sourceforge.net/wiki/index.php/UserCommand%20command[/URL]


-- Assume unreg can see help, reg can change pass, vip can add reg, op can add vip, master can add op.
-- Of course lower profile commands are available for higher profile too.
-- Using standard profiles for convenience.

rc_by_profiles={
[-1]={"1 3 Help$<%[mynick]> !help|"}, -- normal users
[0]={"1 3 Add an op$<%[mynick]> !regop %[line:Nick:] %[line:Password:]|"}, -- Master
[1]={"1 3 Add a VIP$<%[mynick]> !regvip %[line:Nick:] %[line:Password:]|"}, -- OP
[2]={"1 3 Add a reg$<%[mynick]> !regreg %[line:Nick:] %[line:Password:]|"}, -- VIP
[3]={"1 3 Change password$<%[mynick]> !chpass %[line:New Password:]|"}
}

-- User levels. The more rights a user has, the higher the value for the profile key is.

userlevels={
[-1] = 1,
[0] = 5,
[1] = 4,
[2] = 3,
[3] = 2 }



function NewUserConnected(user)
if user.bUserCommand then -- if his client accepts usercommands
user:SendData("$UserCommand 0 3") -- separator
for a,b in rc_by_profiles do -- thorough checking this table :)
-- if his rights are equal or higher than needed for taht command
if userlevels[user.iProfile] >= userlevels[a] then
for k=1,table.getn(b) do -- parse array containing commands
-- and send its elements according to NMDC protocol
user:SendData("$UserCommand "..b[k])
end
end
end
end
end

OpConnected=NewUserConnected
Title:
Post by: Dessamator on 25 May, 2005, 22:52:01
hmm, nice example bastya, lets just hope some ppl can learn from it , :)
Title:
Post by: bastya_elvtars on 25 May, 2005, 23:53:47
QuoteOriginally posted by Dessamator
hmm, nice example bastya, lets just hope some ppl can learn from it , :)

I think they can, however this is a customisable still weird version, I am not used to this either, but for profile-based commands this is a neat way.
Title: Thank u
Post by: XPMAN on 26 May, 2005, 05:53:47
Learning as we speak ;)  Thanx for the example buddy. That gives me a solid foothold.
Title: help
Post by: XPMAN on 29 May, 2005, 16:23:52
Ok, I am having a problem with the tables......how would one make profile specific right click commands without tables? I know tables are better, but trying to take it one step at a time :)

For example, how would one use something like these commands, but it only show up in Op or Master profile right click:

user:SendData("$UserCommand 1 3 TESTHUB\\Profile management\\View Profile Numbers $<%[mynick]> !profiles||")

user:SendData("$UserCommand 1 3 TESTHUB\\Profile management\\Enable Profile $<%[mynick]> !enableprofile %[line:What profile do you wish to Re-Enable?] ||")

user:SendData("$UserCommand 1 3 TESTHUB\\Profile management\\Disable Profile $<%[mynick]> !disableprofile %[line:What profile number do you wish to Disable?] ||")

Just trying to understand all this :)  Any help would be great!!
Title:
Post by: jiten on 29 May, 2005, 17:24:06
QuoteOriginally posted by XPMAN
Ok, I am having a problem with the tables......how would one make profile specific right click commands without tables? I know tables are better, but trying to take it one step at a time :)

For example, how would one use something like these commands, but it only show up in Op or Master profile right click
Well, for example, this one will send the rightclick to every non-operator:
function NewUserConnected(user)
user:SendData("$UserCommand 1 3 TESTHUB\\Profile management\\View Profile Numbers $<%[mynick]> !profiles||")
end

And this one to operators:
function OpConnected(user)
user:SendData("$UserCommand 1 3 TESTHUB\\Profile management\\View Profile Numbers $<%[mynick]> !profiles||")
end

Then, if you want to send it to a certain profile, then you would need to add a if statement under the right function. Something like this:
function NewUserConnected(user)
if user.iProfile == 2 then
user:SendData("$UserCommand 1 3 TESTHUB\\Profile management\\View Profile Numbers $<%[mynick]> !profiles||")
end
end
Title: Thank u
Post by: XPMAN on 29 May, 2005, 18:34:15
Thank u for taking the time to clear it for me  :))

I know alot of this stuff is "common knowledge" for alot of you guys, but thanks for helping out a newbie such as myself. Thank God I finally understand this part.....now to move on to the next step  :))
Title:
Post by: jiten on 29 May, 2005, 20:58:06
You're welcome :]
Title: please help
Post by: tortilla on 04 October, 2005, 18:21:25
[2]={"1 3 Add a reg$<%[mynick]> !regreg %[line:Nick:] %[line:Password:]|"}, -- VIP

i.m lookig to insert in the register this symbol  []ML[].


the user enter with your nick, example  zocotrocolo

 i send command to rightclick into de zrightclicker for robocop and need insert automatically de symbol []ML[].

for register finally is []ML[].zocotrocolo


thanks
Title:
Post by: tortilla on 05 October, 2005, 02:33:54
THANKKS MUTORRR
Title:
Post by: Jo4kim on 09 October, 2005, 18:08:40
QuoteOriginally posted by bastya_elvtars
First read this (http://dcplusplus.sourceforge.net/wiki/index.php/UserCommand%20command).

You say example script? Hmm, ok.

-- This script was written by bastya_elvtars
-- Helps you to learn writing scripted usercomands
-- Originally requested by XPMAN, but many can benefit from it
-- Don't forget to see the description of the protocol:

-- [URL]http://dcplusplus.sourceforge.net/wiki/index.php/UserCommand%20command[/URL]


-- Assume unreg can see help, reg can change pass, vip can add reg, op can add vip, master can add op.
-- Of course lower profile commands are available for higher profile too.
-- Using standard profiles for convenience.

rc_by_profiles={
[-1]={"1 3 Help$<%[mynick]> !help|"}, -- normal users
[0]={"1 3 Add an op$<%[mynick]> !regop %[line:Nick:] %[line:Password:]|"}, -- Master
[1]={"1 3 Add a VIP$<%[mynick]> !regvip %[line:Nick:] %[line:Password:]|"}, -- OP
[2]={"1 3 Add a reg$<%[mynick]> !regreg %[line:Nick:] %[line:Password:]|"}, -- VIP
[3]={"1 3 Change password$<%[mynick]> !chpass %[line:New Password:]|"}
}

-- User levels. The more rights a user has, the higher the value for the profile key is.

userlevels={
[-1] = 1,
[0] = 5,
[1] = 4,
[2] = 3,
[3] = 2 }



function NewUserConnected(user)
if user.bUserCommand then -- if his client accepts usercommands
user:SendData("$UserCommand 0 3") -- separator
for a,b in rc_by_profiles do -- thorough checking this table :)
-- if his rights are equal or higher than needed for taht command
if userlevels[user.iProfile] >= userlevels[a] then
for k=1,table.getn(b) do -- parse array containing commands
-- and send its elements according to NMDC protocol
user:SendData("$UserCommand "..b[k])
end
end
end
end
end

OpConnected=NewUserConnected

I tried to use this example as a pinpointer, when I tried to create a rightclick-menu my self. It all starts, but when I rightclick, and check the menu, only one of my now two alternatives shows up. And I can't understand why.

The thing that I changed from above, is this

Quoterc_by_profiles={

   [-1]={"1 2 Check new releases at\\NFORCE\\PC-Games$<%[mynick]> !nfpcg-iso|"},
   
   [-1]={"1 2 Check new releases at\\NFORCE\\Xbox-Games$<%[mynick]> !nfxbox|"},
}

Thanks, in advance, Joakim.
Title: Thank you very much Mutor.
Post by: Jo4kim on 09 October, 2005, 20:02:31
QuoteOriginally posted by Mutor
you can only set the profile, in this case [-1] once. The second statement overwrites the first.

You'll need an array. Something like this should do.

rc_by_profiles={

[-1]={"1 2 Check new releases at\\NFORCE\\PC-Games$<%[mynick]> !nfpcg-iso|","1 2 Check new releases at\\NFORCE\\Xbox-Games$<%[mynick]> !nfxbox|"},
}


bastya_elvtars only used one command per profile in his example, thats all.

Thanks Mutor, it worked out fine now. And thanks to bastya for submitting the "guide" before, it now seems clear to me now =)

Just started using Ptokax again, used it in the begining of my hub-owner career, but switched to ynhub, but I can see that the ptokax got the potential do more and be more fun.

So thanks guys for a wonderful help. =)
Title:
Post by: bastya_elvtars on 09 October, 2005, 20:22:40
To be honest, I don't use this method myself. I use like this:

commands={
["Help$ !help|"]=4
-- etc.
}

so the key is the command itself, value is the userlevel, according to

userlevels={
[-1] = 1,
[0] = 5,
[1] = 4,
[2] = 3,
[3] = 2 }
Title:
Post by: Jo4kim on 12 October, 2005, 00:33:50
QuoteOriginally posted by bastya_elvtars
To be honest, I don't use this method myself. I use like this:

commands={
["Help$ !help|"]=4
-- etc.
}

so the key is the command itself, value is the userlevel, according to

userlevels={
[-1] = 1,
[0] = 5,
[1] = 4,
[2] = 3,
[3] = 2 }


Well, I'm back again.. Think I screwed up real good, or just tired, I don't know.. I just can't get it right this time either.

I now used bastya_elvtars first script example to XP-man, but tried to change to his later way of making rightclick-commands.. And it now doesn't work at all, it says the following in ptokax: [00:28] Syntax ...nts and Settings\Joakim\Mina dokument\Ptokax HUb\scripts\rightclick2.lua:27: `}' expected (to close `{' at line 25) near `['

And I use notepad, and found out that line that isn't working, is one of this

commands={
["Check new releases at\\NFORCE\\Games - PC$<%[mynick]> !nfpcg-iso|"]=1
["Check new releases at\\NFORCE\\Games - PS2$<%[mynick]> !nfps2|"]=1
["Check new releases at\\NFORCE\\Games - Xbox$<%[mynick]> !nfxbox|"]=1
["Check new releases at\\NFORCE\\Movies - XviD$<%[mynick]> !nfxvid|"]=1
["Check new releases at\\NFORCE\\Movies - DVDR$<%[mynick]> !nfdvdr|"]=1

And it's all I've changed from bastya_elvtars earlier piece of code.

Thanks in advance, Joakim.
Title:
Post by: bastya_elvtars on 12 October, 2005, 01:09:15
Put a } after the last line posted. :)

And use Notepad++ or SciTe.

See this wiki page (http://ptxwiki.psycho-chihuahua.net/doku.php/misc/editors) on editors.
Title: I really suck at this =)
Post by: Jo4kim on 12 October, 2005, 10:32:16
QuoteOriginally posted by bastya_elvtars
Put a } after the last line posted. :)

And use Notepad++ or SciTe.

See this wiki page (http://ptxwiki.psycho-chihuahua.net/doku.php/misc/editors) on editors.


I've downloaded Notepad++, thanks for the tip =)

But, I can't get the script working properly..

So can you make a working, complete example to me, when you both have commands for all, and commands accessable to OPs, because I'm stuck with this shit, can't get it working. =)

And using your method: ["Help$ !help|"]=4
Title:
Post by: Markitos on 15 October, 2005, 11:50:45
Im making a right click and to my work become more easier i want to add a function thats adds the escape thing (||) in all commands without repeating over and over again...i saw this code in rc rightclick
GetRightClick = function(user, table1, table2)
for cmd,level in table1 do
if table1[cmd][user.iProfile] == 1 then
if table2[cmd] then
user:SendData(table2[cmd].."||")
end
end
end
end
But the problem is that im not using tables...my right click looks like this
function OpConnected(user)
if (user.iProfile) == -1 then
-- the commands
end
end

Could some one help me?
Title:
Post by: Markitos on 15 October, 2005, 13:57:04
QuoteOriginally posted by Markitos
Im making a right click and to my work become more easier i want to add a function thats adds the escape thing (||) in all commands without repeating over and over again...i saw this code in rc rightclick
GetRightClick = function(user, table1, table2)
for cmd,level in table1 do
if table1[cmd][user.iProfile] == 1 then
if table2[cmd] then
user:SendData(table2[cmd].."||")
end
end
end
end
But the problem is that im not using tables...my right click looks like this
function OpConnected(user)
if (user.iProfile) == -1 then
-- the commands
end
end

Could some one help me?
Nbdy???
Title: Lol
Post by: Markitos on 15 October, 2005, 16:14:38
QuoteOriginally posted by Mutor
for one reason we can loop a table and perform a function on all or some table elements.

Your help comes as this, make a table  :P
Thats what i had in mind...anyways thnks!