hello friends,
im learning to script and i have a question of diffrent
data arrivals [DA], i know what [DA] means, but why so many diffrent variations and is there a set way of
having a [DA] function.
here are some that i found
they all look the same but diffrent
how do i know what each means
function DataArrival(user, data)
if(strsub(data, 1, 4) == "$To:") then
data=strsub(data,1,strlen(data)-1)
s,e,whoTo = strfind(data,"$To:%s+(%S+)")
function DataArrival(user, data)
if( strsub(data, 1, 1) == "<" ) then
data=strsub(data,1,strlen(data)-1)
s,e,cmd,arg = strfind( data, "%b<>%s+(%S+)%s+(.*)" )
if (arg==nil) then
s,e,cmd = strfind( data, "%b<>%s+(%S+)%s*" )
function DataArrival(curUser, data)
if strsub(data, 1, 1) ~= "<" then return end
local s, e, cmd, args = strfind(data, "^%b<> %!(%a+)%s*(.*)%|$")
function DataArrival(user,data)
if strsub(data, 1, 1) == "<" then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
function DataArrival(curUser, data)
if (strsub(data, 1, 1) == "$" and curUser.iProfile==-1 and strfind(data, "ConnectToMe")) then
function DataArrival(user, data)
if (strsub(data,1,1) == "<") then
data = strsub(data,1,strlen(data)-1)
local s,e,cmd = nil
s,e,cmd = strfind( data, "%b<>%s+(%S+)" )
weird script
i don't see use for more dataarrivals
and the missing all a
end
QuoteOriginally posted by [NL]Pur
weird script
i don't see use for more dataarrivals
and the missing all a
end
LOL no pur
those are diffrent [DA] that i found in some scripts,
and i wanted to know how do i know what the diffrence
is and what each one does,....how do you read a [DA]?
Short explaination from me, becouse have just learn a few more
things about this.
for start
Always only one DataArrival
"<" = Catching what going on in mainchat
"$To" = Catch what going between users or Bot
"$MyInfo" = catching myInfo
the numbers stand for the letters/symbols
ex:
"$To: "
This will be:
if(strsub(data, 1, 5) == "$To: ") then
then it can be like this to
"$To:"
if(strsub(data, 1, 4) == "$To:") then
and
"$To"
if(strsub(data, 1, 3) == "$To") then
this is what I have learn in this so far for this.
hope it helps some.
function DataArrival(user, data)
^^ --> Pretty Obvious ;)
if(strsub(data, 1, 4) == "$To:") then
"$To:" <---- There are 4 Characters inside those double Quotes, That's why the number 4 is there! :)
Which means if it finds any data in "$To:" then
data=strsub(data,1,strlen(data)-1)
^^ -- Remove end pipe if im not wrong?
s,e,whoTo = strfind(data,"$To:%s+(%S+)")
^^ <---- Here you set "WhoTo" to (%S+)
It will search for something like this:
$To:
function DataArrival(user, data)
if( strsub(data, 1, 1) == "<" ) then
^^ <--- 1,1 is main, Keep that in memory
data=strsub(data,1,strlen(data)-1)
^^ <---- Remove end pipe
s,e,cmd,arg = strfind( data, "%b<>%s+(%S+)%s+(.*)" )
^^ <----- %s+ = SPACE while %S+ is everything without a space
think of it like this, the cmd is the first thing you find in Inside parantheses, While the arg = (.*)
Which means anything actually
if (arg==nil) then
^^ if arg is equal to nil then
s,e,cmd = strfind( data, "%b<>%s+(%S+)%s*" )
function DataArrival(curUser, data)
if strsub(data, 1, 1) ~= "<" then return end
^^ This one however, You probably know that == means Equality, This ~= is the other way around.
So, If it finds anything else that IS NOT in main then
local s, e, cmd, args = strfind(data, "^%b<> %!(%a+)%s*(.*)%|$")
function DataArrival(user,data)
if strsub(data, 1, 1) == "<" then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
function DataArrival(curUser, data)
if (strsub(data, 1, 1) == "$" and curUser.iProfile==-1 and strfind(data, "ConnectToMe")) then
"$" <-- ONE character, that's why again we have 1,1
and if user is a "Normal" user and if it finds $ConnectToMe from that user then
return 1
end?
function DataArrival(user, data)
if (strsub(data,1,1) == "<") then
data = strsub(data,1,strlen(data)-1)
local s,e,cmd = nil
s,e,cmd = strfind( data, "%b<>%s+(%S+)" )
^^ I have no idea :S
oh ok, lol
if(strsub(data, 1, 4) == "$To:") then
data=strsub(data,1,strlen(data)-1)
s,e,whoTo = strfind(data,"$To:%s+(%S+)")
this one is for if you want that commands only can be
used by sending them in a pm too a bot
function DataArrival(user, data)
if( strsub(data, 1, 1) == "<" ) then
data=strsub(data,1,strlen(data)-1)
s,e,cmd,arg = strfind( data, "%b<>%s+(%S+)%s+(.*)" )
if (arg==nil) then
s,e,cmd = strfind( data, "%b<>%s+(%S+)%s*" )
this one has commands with and without 1 argument
function DataArrival(curUser, data)
if strsub(data, 1, 1) ~= "<" then return end
local s, e, cmd, args = strfind(data, "^%b<> %!(%a+)%s*(.*)%|$")
this one hs commands with 1 argument
function DataArrival(user,data)
if strsub(data, 1, 1) == "<" then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
just for command without arguments
function DataArrival(curUser, data)
if (strsub(data, 1, 1) == "$" and curUser.iProfile==-1 and strfind(data, "ConnectToMe")) then
This is apply's too normal users -1 , when they connect
too a other client
function DataArrival(user, data)
if (strsub(data,1,1) == "<") then
data = strsub(data,1,strlen(data)-1)
local s,e,cmd = nil
s,e,cmd = strfind( data, "%b<>%s+(%S+)" )?>
same as earlier only sets the varibles first too nil
and is for command without arguments
WOW :D
pur
kepp
Nightlitch
thanks alot guys,
very good explanations,
very much appreciated.
i will read this over and over again.
P.S. what does
"remove end pipe" mean?
curUser:SendData(Bot, "Hello|")
Notice "|"
Which means you will remove that one.
I suppose it is like the example above...?
No problem, :)
the pipe isn't needed but if you want too send a hello
you must add a $ before it
Ok, so no matter what,
You still need to add any of those two characters? "|", "$" unless you don't put that line of code in DataArrival function()?
QuoteOriginally posted by kepp
Ok, so no matter what,
You still need to add any of those two characters? "|", "$" unless you don't put that line of code in DataArrival function()?
uh, no | is to break line, so basically if you do user:SendData(Bot,"whateer")
or
user:SendData(Bot,"whaver|")
wont make any differ except because ptokax will already do this after it sends the data so no need, as for $ its for commands, used as a key
user:SendData("$Hello ".."name")
this will make a name appear in the userlist
but i dont now what ur getting at
Me Neither, lol
ok a few things i will add, mainly about the way i usually use "
function DataArrival(user,data)
if strsub(data, 1, 1) == "<" then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
ok strsub is finding the main keys such as $To etc, so i wont go over that unless u need help with it, removing the endpip is explained also Brrrr, and as for strfind < my fav :p
so this is about local and global
word = "whatevr" << global < usually outside the functions
local word = "whatever"
s,e,cmd = strfind(data,"%b<>%s+(%S+)") --global
local s,e,cmd = strfind(data,"%b<>%s+(%S+)") --local
x (where x is not one of the magic characters ^$()%.[]*+-?) --- represents the character x itself.
. --- (a dot) represents all characters.
%a --- represents all letters.
%c --- represents all control characters.
%d --- represents all digits.
%l --- represents all lowercase letters.
%p --- represents all punctuation characters.
%s --- represents all space characters.
%u --- represents all uppercase letters. %x --- represents all hexadecimal digits.
%z --- represents the character with representation 0.
%x (where x is any non-alphanumeric character) ---
%w --- represents all alphanumeric characters.
represents the character x. This is the standard way to escape the magic characters. Any punctuation character (even the non magic) can be preceded by a `%? when used to represent itself in a pattern.
pHaTz,,