error message with my DataArrival and NewUserConnected
 

error message with my DataArrival and NewUserConnected

Started by blackwings, 05 October, 2004, 21:23:08

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

blackwings

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, "") then
				Client="PhantomDC"
				local  _,_,version=strfind(User.sdataString,"V:(0.%d+)")
				return version
			elseif strfind(data, "



Psycho_Chihuahua

all i get is this...

Syntax Error: bad argument #1 to `strsub' (string expected, got nil)
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

bastya_elvtars

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

blackwings

#3
ehh, umm, I don't understand what you mean >_<

Could you explain in differently?


SMF spam blocked by CleanTalk