I need help please, don't really know how to solve this :(
Here is the error message =
Syntax error: bad argument #1 to `strsub' (string expected, got nil)
stack traceback:
1: function `strsub' [C]
2: function `DataArrival' at line 139 [file `C:\ptokax\scripts\Welcome-AI3.lua']
3: function `NewUserConnected' at line 96 [file `C:\ptokax\scripts\Welcome-AI3.lua']
Here is the code for my script =
--######## HERE STARTS THE CONFIGURATION ########--
Bot="?Welcome-AI?"
hubowner="blackwings"
--~~~~~~~~~~~~~~~~~~~~
--????????????????????????????????????????????
------------------------------------------
-- Random welcome message for the hubowner
------------------------------------------
HOWelcome = {
"has entered the hub. ==-",
"second HubOwner welcome message",
"third HubOwner welcome message",
}
--------------------------------------------------
-- Random message for when the hubowner disconnect
--------------------------------------------------
HOByeBye = {
"has left the hub",
"second HubOwner Good Bye message",
"third HubOwner Good Bye message",
}
--????????????????????????????????????????????
--++++++++++
--????????????????????????????????????????????
--------------------------------------------------------------
-- Random welcome message for the Operators and the Moderators
--------------------------------------------------------------
OPWelcome = {
"has just connected to this hub",
"second OP & Mod welcome message",
"third OP & Mod welcome message",
}
----------------------------------------------------------------------
-- Random message for when the Operators and the Moderators disconnect
----------------------------------------------------------------------
OPByeBye = {
"has left the hub",
"second OP & Mod Good Bye message",
"third OP & Mod Good Bye message",
}
--????????????????????????????????????????????
--++++++++++
--????????????????????????????????????????????
----------------------------------------
-- Random welcome message for the VIP's
----------------------------------------
VIPWelcome = {
"has just connected to this hub",
"second VIP welcome message",
"third VIP welcome message",
}
--------------------------------------------------
-- Random message for when the VIP's disconnect
--------------------------------------------------
VIPByeBye = {
"has left the hub",
"second VIP Good Bye message",
"third VIP Good Bye message",
}
--????????????????????????????????????????????
--++++++++++
--????????????????????????????????????????????
--------------------------------------------------
-- Random welcome message for the registered users
--------------------------------------------------
REGWelcome = {
"has just connected",
"second REG welcome message",
"third REG welcome message",
}
--------------------------------------------------
-- Random message for when a registered user disconnect
--------------------------------------------------
REGByeBye = {
"has left the hub",
"second REG Good Bye message",
"third REG Good Bye message",
}
--????????????????????????????????????????????
--######## HERE ENDS THE CONFIGURATION ########--
Mode=""
Client=""
function Main()
frmHub:RegBot(Bot)
end
function OpConnected(User)
local version=DataArrival(User , data)
if User.iProfile == 3 then
SendToAll(Bot,"The registered user "..User.sName.." "..REGWelcome[random(1, getn(REGWelcome))]..".")
User:SendData(Bot,"Your IP is <"..User.sIP.."> - You are using <"..Client.."|"..version.."> in "..Mode..".")
elseif User.iProfile == 2 then
SendToAll(Bot,"The VIP "..User.sName.." "..VIPWelcome[random(1, getn(VIPWelcome))]..".")
User:SendData(Bot,"Your IP is <"..User.sIP.."> - You are using <"..Client.."> in "..Mode..".")
elseif User.iProfile == 1 then
SendToAll(Bot,"Operator "..User.sName.." "..OPWelcome[random(1, getn(OPWelcome))]..".")
User:SendData(Bot,"Your IP is <"..User.sIP.."> - You are using <"..Client.."> in "..Mode..".")
elseif User.iProfile == 0 and User.sName == hubowner then
SendToAll(Bot,"The hubowner "..User.sName.." "..HOWelcome[random(1, getn(HOWelcome))]..".")
User:SendData(Bot,"Your IP is <"..User.sIP.."> - You are using <"..Client.."> in "..Mode..".")
elseif User.iProfile == 0 then
SendToAll(Bot,"Master "..User.sName.." "..OPWelcome[random(1, getn(OPWelcome))]..".")
User:SendData(Bot,"Your IP is <"..User.sIP.."> - You are using <"..Client.."> in "..Mode..".")
elseif User.iProfile == 5 then
SendToAll(Bot,"Moderator "..User.sName.." "..OPWelcome[random(1, getn(OPWelcome))]..".")
User:SendData(Bot,"Your IP is <"..User.sIP.."> - You are using <"..Client.."> in "..Mode..".")
end
end
function OpDisconnected(User)
if User.iProfile == 3 then
SendToAll(Bot,"The registered "..User.sName.." "..REGByeBye[random(1, getn(REGByeBye))]..".")
elseif User.iProfile == 2 then
SendToAll(Bot,"The VIP "..User.sName.." "..VIPByeBye[random(1, getn(VIPByeBye))]..".")
elseif User.iProfile == 1 then
SendToAll(Bot,"Operator "..User.sName.." "..OPByeBye[random(1, getn(OPByeBye))]..".")
elseif User.iProfile == 0 and User.sName == hubowner then
SendToAll(Bot,"The hubowner "..User.sName.." "..HOByeBye[random(1, getn(HOByeBye))]..".")
elseif User.iProfile == 0 then
SendToAll(Bot,"Master "..User.sName.." "..OPByeBye[random(1, getn(OPByeBye))]..".")
elseif User.iProfile == 5 then
SendToAll(Bot,"Moderator "..User.sName.." "..OPByeBye[random(1, getn(OPByeBye))]..".")
end
end
NewUserConnected=OpConnected
UserDisconnected=OpDisconnected
function DataArrival(User , data)
if strsub(data, 1, 7) == "$data" then
if strfind(data, ":P") then
Mode=""
elseif strfind(data, ":A") then
Mode=""
elseif strfind(data, ":[S5]") then
Mode=""
end
if strsub(data, 1, 7) == "$MyINFO" then
if strfind(data, "<++") and not strfind(data, "<.P>") and not strfind(data, " Client="Original DC"
local _,_,version=strfind(User.sdataString,"V:(0.%d+)")
return version
elseif strfind(data, " Client="oDC"
local _,_,version=strfind(User.sdataString,"V:(%d+.%d+)")
return version
elseif strfind(data, " Client="oDC"
local _,_,version=strfind(User.sdataString," return version
elseif strfind(data, " Client="NMDC"
local _,_, version = "ver?"
elseif strfind(data, " Client="DCGUI"
local _,_, version = strfind(User.sdataString,"V:0.(%d+.%d+)")
return version
elseif strfind(data, "zDC++") then
Client="zDC++"
local _,_,version=strfind(User.sdataString,"V:(0.%d+)")
if strfind(data, "<.P>") then
Client="PhantomDC"
local _,_,version=strfind(User.sdataString,"V:(0.%d+)")
return version
elseif strfind(data, " Client="DCDM++"
local _,_,version=strfind(User.sdataString," return version
elseif strfind(data, "[BL]:") then
Client="BCDC++"
local _,_,version=strfind(User.sdataString,"V:(0.%d+)")
return version
elseif strfind(data, "v%[") then
Client="nDC++"
local _,_,version=strfind(User.sdataString,"V:(0.%d+)")
return version
elseif strfind(data, " Client="iDC++"
local _,_,version=strfind(User.sdataString,"V:(0.%d+)")
return version
elseif strfind(data, " Client="DC++k CDM"
local _,_,version=strfind(User.sdataString," return version
elseif strfind(data, " Client="StrongDC++"
local _,_,version=strfind(User.sdataString,"V:(1.%d+%s%w+),")
return version
elseif strfind(data, "V:0.%d+%a") then
Client="CZDC++"
local _,_,version=strfind(User.sdataString,"V:(0.%d+)")
return version
elseif strfind(data, " Client="DC:PRO"
local _,_,version=strfind(User.sdataString,"V:([^,]+).")
return version
elseif strfind(data, " Client="MS++V"
local _,_,version=strfind(User.sdataString,"V:(0.%d+)")
return version
elseif strfind(data, " Client="DC@fe++"
local _,_,version=strfind(User.sdataString,"V:(0.%d+)")
return version
elseif strfind(data, " Client="rmDC++"
local _,_,version=strfind(User.sdataString,"V:(0.%d+)")
return version
elseif strfind(data, "reverseconnect.sf.net" ) or strfind(data,"www.RevConnect.com") then
Client="ReverseConnect"
local _,_,version=strfind(User.sdataString,"V:(0.%d+)")
return version
else
Client="Unknown Client"
end
end
end
end
end
all i get is this...
Syntax Error: bad argument #1 to `strsub' (string expected, got nil)
well...
if you make a function that you name
function shit (ass, toilet)
return ass+toilet
end
if ya use this in somewhere
function TP()
ass=random(1,7)
toilet=random(1,9)
if shit(ass,toilet)>6 then
a="blabla"
else
b="shimmy-yo"
end
you see that function returns the sum of those 2 values
so this is just a way 2 make a script better ordered, and between brackets, there are the variables you wanna work with
the return value makes a function useable in another function, as you make a condition depending on the value seen here. so make subfunctions for your dataarrival, and return the results of the functions, ok?
gonna put a lua manual in my sig
ehh, umm, I don't understand what you mean >_<
Could you explain in differently?