How To Create Right clicks
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

How To Create Right clicks

Started by Dessamator, 16 May, 2005, 21:53:33

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Dessamator

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

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

Quote
Erase
$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
Ignorance is Bliss.

jiten

Nice one Dessamator!
Surely this one will help lots of users... :D

Cheers m8

TTB

#2
nice one!

TTB

(? ?.??.-> Admin @ Surfnet hubs <-.??.???)

Dessamator

#3
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 !
Ignorance is Bliss.

bastya_elvtars

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.
Everything could have been anything else and it would have just as much meaning.

Dessamator

hmm indeed, well done bastya :))
Ignorance is Bliss.

XPMAN

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.

XPMAN

Finally got it ....lol , Now for the profile specific.  More info and "How-to's) would be great :)

bastya_elvtars

First read this.

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
Everything could have been anything else and it would have just as much meaning.

Dessamator

hmm, nice example bastya, lets just hope some ppl can learn from it , :)
Ignorance is Bliss.

bastya_elvtars

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.
Everything could have been anything else and it would have just as much meaning.

XPMAN

Learning as we speak ;)  Thanx for the example buddy. That gives me a solid foothold.

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:

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!!

jiten

#13
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

XPMAN

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

jiten

You're welcome :]

tortilla

[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

tortilla


Jo4kim

QuoteOriginally posted by bastya_elvtars
First read this.

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.

Jo4kim

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. =)

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 }
Everything could have been anything else and it would have just as much meaning.

Jo4kim

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.

bastya_elvtars

Put a } after the last line posted. :)

And use Notepad++ or SciTe.

See this wiki page on editors.
Everything could have been anything else and it would have just as much meaning.

Jo4kim

QuoteOriginally posted by bastya_elvtars
Put a } after the last line posted. :)

And use Notepad++ or SciTe.

See this wiki page 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

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?

SMF spam blocked by CleanTalk