PtokaX forum

Lua 5.3/5.2/5.1 Scripts (for PtokaX 0.4.0.0 and newer) => Help with scripts => Topic started by: satya on 26 October, 2009, 09:02:10

Title: Little help required with user commands
Post by: satya on 26 October, 2009, 09:02:10
Hey guys!!

i need some help w.r.t to user commands and some string manipulation!!

First the user command:

When i was learning how to send user command i got to know that we can send commands at 3 places ie hub tab, user list or search result. Is there any way that i can set a command in the file list. ie wen user browse some1 files list he can get those commands. I am asking this is because i have seen in ApexDc and StrongDC that we can add some commands in the file list too.

Next thing is with string:

i m developing a script where wen a user shares something he can use the command and the command will send all the hub users a notification that user abc has shared blah with path and size

for that this is how to user-command will look
Code: [Select]
$UserCommand 1 4 Trial Commands\\Add Share$<%[mynick]> +share %[file] %[filesizeshort] %[filesize] %[nick]&#124;
So the output of this will be the complete path of the file along with the file name, short size of the file, long form of file size and users nick.

something like this.

Code: [Select]
+share Movies\Promos\AVATAR HD.avi 35.83 MiB 7158103 ABC
how can i use a string function so that i can dismantle the data in following format

Code: [Select]
Path:Movies\Promos\
File Name: AVATAR HD.avi
File Size: 35.83 MiB
User: ABC

I had been trying from a long time by cant get it right :(

And one last thing

Can ne1 explain me the concept of ConnectToMeArrival() function. I know that when a users tries to get file list of other user this function is triggered. But what i want to know is how can we use the data that is passed when it is triggred, can we get wich user is that user is tryin to connect the file name the size etc etc.

Any help will be appreciated
thanks
Title: Re: Little help required with user commands
Post by: the-master on 26 October, 2009, 09:46:33
The Usercommands can be send anywhere, the codes are in the 1 1 part.
Try 1 15 and you will see them in all the places.
Its all depending on the second number u use, 1 1 is a place, 1 2 another, 1 3 are the places 1 1 and 1 2 together, 1 4 is again another place, 1 5 is 1 4 and 1 1 together, 1 6 is 1 4 and 1 2 together etc..
Title: Re: Little help required with user commands
Post by: satya on 26 October, 2009, 17:10:31
The Usercommands can be send anywhere, the codes are in the 1 1 part.
Try 1 15 and you will see them in all the places.
Its all depending on the second number u use, 1 1 is a place, 1 2 another, 1 3 are the places 1 1 and 1 2 together, 1 4 is again another place, 1 5 is 1 4 and 1 1 together, 1 6 is 1 4 and 1 2 together etc..
ya i know that buddy bt how do you set them to show only in file list.
Title: Re: Little help required with user commands
Post by: the-master on 26 October, 2009, 19:41:48
If you really knew what i was trying to tell you, you would know that "$UserCommand 1 8" shows in filelistmenu
Title: Re: Little help required with user commands
Post by: satya on 27 October, 2009, 08:04:27
If you really knew what i was trying to tell you, you would know that "$UserCommand 1 8" shows in filelistmenu
hehe thanx bt i figurd dat out bit late
See this thread on CG's Nighthawk Forum (http://nighthawk-forum.europe-united.net/index.php?topic=52.0)
It explains the parameters for UserCommands in greater detail
thanks buddy that was some good ref. I was lookin for your reply hey muter can you help me with the string and the connecttomearrival query. Thanks :)
Title: Re: Little help required with user commands
Post by: Madman on 27 October, 2009, 15:13:50
This is also on CG's forum....  CTM (http://nighthawk-forum.europe-united.net/index.php?topic=178.0)
Title: Re: Little help required with user commands
Post by: satya on 27 October, 2009, 15:50:13
This is also on CG's forum....  CTM (http://nighthawk-forum.europe-united.net/index.php?topic=178.0)

Thanks buddy!! now with the String manipulation can u help me with that pleasee :D

thanks
Title: Re: Little help required with user commands
Post by: Madman on 28 October, 2009, 16:15:08
Code: [Select]
+share %[file] %[filesizeshort] %[filesize] %[nick]&#124;
local _,_,f,fss,fs,n = "share%s(.+)%s(%d+%a+)%s(%d+)%s(" ..user.sNick ")"

I don't know the client variabels, but i asume filesizeshort is 50MB and filesize is 500000...
so that's what i worked on. just use the pattern above in a string.find
Title: Re: Little help required with user commands
Post by: satya on 28 October, 2009, 16:22:35
Code: [Select]
+share %[file] %[filesizeshort] %[filesize] %[nick]|
local _,_,f,fss,fs,n = "share%s(.+)%s(%d+%a+)%s(%d+)%s(" ..user.sNick ")"

I don't know the client variabels, but i asume filesizeshort is 50MB and filesize is 500000...
so that's what i worked on. just use the pattern above in a string.find

Thanks buddy will try that out and will let u know!! :)

thanks for the help buddy i was really needed this!!
Title: Re: Little help required with user commands
Post by: satya on 29 October, 2009, 08:03:17
Fantastic American Idiot that really works!!

but there is a problem!!
the user-command that i m sending from the script to the users is something like this

Code: [Select]
$UserCommand 1 4 Trial Commands\\Add Share$<%[mynick]> +share %[file] %[filesizeshort] %[filesize] %[nick]&#124;
Now when users clicks on any file name and triggers this command the path along with the file name doesnt contain '\\' i contains only single slash!!

this is wat i mean

Code: [Select]
+share Movies\Promos\AVATAR HD.avi 35.83 MiB 7158103 ABC
This is how the data will be received by the hub. there wont bt \\ in the path name i hope u get what i m trying to say

but ur sample code was really very good thanks a lot for it can u pls help me out with that pls.

Title: Re: Little help required with user commands
Post by: satya on 29 October, 2009, 09:20:24
Hey American Idiot thanks
using some of my logic and some help from your sample script i figured out the whole script!!

Thanks a TON man u are a great help..

Just one query,
This is also on CG's forum....  CTM (http://nighthawk-forum.europe-united.net/index.php?topic=178.0)

Here while reading i found that we can get to know that which user is trying to connect which.
But we i tried to display the data ie the data wich is passed as a arg to CTM it doesnt displays nething :(

can u tell me how to show the data of CTM in hub!!?? i mean do we hv to use string.format??

Title: Re: Little help required with user commands
Post by: Madman on 29 October, 2009, 14:34:28
Core.SendToAll("CTM: "..data)

if you just send data, it will "execute" the data as a CTM....
so adding anythign before data i.e "CTM: " or "!" will send it to main.
Title: Re: Little help required with user commands
Post by: satya on 29 October, 2009, 15:22:12
Core.SendToAll("CTM: "..data)

if you just send data, it will "execute" the data as a CTM....
so adding anythign before data i.e "CTM: " or "!" will send it to main.

ohh ki lemme try that!! thanks madman!! :)