Ptokax 0.3.3.0 syntax erros...
 

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

Ptokax 0.3.3.0 syntax erros...

Started by nErBoS, 27 February, 2004, 14:44:18

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

nErBoS

Hi all,

Geting this error on many of my scripts which works without errors in the TD4

for eg...

Syntax error: bad argument #1 to `strfind' (string expected, got nil)
stack traceback:
   1:  function `strfind' [C]
   2:  function `DataArrival' at line 113 [file `C:\teste\Ptokax 3.30\scripts\teste.lua']

at line 113 i have this...

if strfind(curUser.sMyInfoString, "
Did something changed in the new version ???

Best regards, nErBoS
--## nErBoS Spot ##--

NightLitch

I have the same erros sometimes when someother script is loaded before my NXS-3. if NXS-3 loads first I don't have those errors.

try. load that bot first then the others.
//NL

nErBoS

#2
In this case is only one bot that i am using...

Here is it...

------------------------------------------------------- 
---------------- Datalog - Lua Edition ---------------- 
--------------------- Version 1.1 --------------------- 
------------------- by DirtyFinger -------------------- 
---------------- [EMAIL]DirtyFinger@gmx.net[/EMAIL] ------------------ 
------------------ ICQ : 145873101 -------------------- 
------- [URL]http://mitglied.lycos.de/dirtyfinger01/[/URL] ------- 
------------------------------------------------------- 
------------------------------------------------------- 
-- This script logs incoming data , connects, disconnects 
-- and saves them in three seperate files. 
-- I'm pretty sure that absolutely NO ONE needs this script 
-- to run a functioning hub. 
-- It's rather something to watch at long, cold evenings. 

-- Due to the known problems with PtokaX 0.323X the files 
-- may not be generated. 
-- In that case AND if you use PtokaX 0.324 or higher, 
-- use the second set of file locations (directly below). 
-- Make sure the Directory Datalog exists !! 
Connectlogfile = "Datalog/connectlog.txt" 
Datalogfile = "Datalog/datalog.txt" 
Statisticsfile = "Datalog/stats.txt" 
SecondDatafile = "Datalog/data2log.txt"
-- Connectlogfile = "Datalog/connectlog.txt" 
-- Datalogfile = "Datalog/datalog.txt" 
-- Statisticsfile = "Datalog/stats.txt" 

sBotName = "Datalog" 

timerIntervall = 10*1000 -- This sets the intervalls in which the files get saved 

sDatalog = "" 
sConnectlog = "" 
sSDatalog = ""


Statistics = { 
ConnectToMe = 0, 
GetNickList = 0, 
GetINFO = 0, 
Kick = 0, 
MainChat = 0, 
MultiConnectToMe = 0, 
MultiSearch = 0, 
MyINFO = 0, 
MyPass = 0, 
OpForceMove = 0, 
Other = 0, 
Quit = 0, 
RevConnectToMe = 0, 
Search = 0, 
SearchResult = 0, 
To = 0, 
ValidateNick = 0, 
Version = 0, 
ZTotal = 0, 
} 


--// This function is fired at the serving start 
function Main() 
SendToAll(sBotName.." "..date(" launched at %B %d %Y %X ")) 
SetTimer(timerIntervall) 
StartTimer() 
loadStatistics (Statisticsfile) 

end 

--// This function is fired when a new data arrives 
function DataArrival(curUser, sData) 
sDatalog = sDatalog .. "\n" .. "<|"..date("%c|") .. curUser.sName .. "|" .. curUser.sIP .. "|> " .. sData 
local s = splitstring(sData) 
if s == "$ConnectToMe" then 
Statistics.ConnectToMe = Statistics.ConnectToMe + 1 
elseif s == "$GetNickList|" then 
Statistics.GetNickList = Statistics.GetNickList + 1 
elseif s == "$GetINFO" then 
Statistics.GetINFO = Statistics.GetINFO + 1 
elseif s == "$Kick" then 
Statistics.Kick = Statistics.Kick + 1 
elseif s == "<"..curUser.sName..">" then 
Statistics.MainChat = Statistics.MainChat + 1 
elseif s == "$MultiConnectToMe" then 
Statistics.MultiConnectToMe = Statistics.MultiConnectToMe + 1 
elseif s == "$MultiSearch" then 
Statistics.MultiSearch = Statistics.MultiSearch + 1 
elseif s == "$MyINFO" then 
Statistics.MyINFO = Statistics.MyINFO + 1 
elseif s == "$MyPass" then 
Statistics.MyPass = Statistics.MyPass + 1 
elseif s == "$OpForceMove" then 
Statistics.OpForceMove = Statistics.OpForceMove + 1 
elseif s == "$Quit" then 
Statistics.Quit = Statistics.Quit + 1 
elseif s == "$RevConnectToMe" then 
Statistics.RevConnectToMe = Statistics.RevConnectToMe + 1 
elseif s == "$Search" then 
Statistics.Search = Statistics.Search + 1 
elseif s == "$SR" then 
Statistics.SearchResult = Statistics.SearchResult + 1 
elseif s == "$To:" then 
Statistics.To = Statistics.To + 1 
elseif s == "$ValidateNick" then 
Statistics.ValidateNick = Statistics.ValidateNick + 1 
elseif s == "$Version" then 
Statistics.Version = Statistics.Version + 1 
else 
Statistics.Other = Statistics.Other + 1 
end 
Statistics.ZTotal = Statistics.ZTotal + 1 

if strfind(curUser.sMyInfoString, " " .. client .. "|" .. version

end 


--// This function is fired when a new user finishes the login 
function NewUserConnected(curUser) 
sConnectlog = sConnectlog .. "\n" .. "<"..date("%c|") .. curUser.sName .. "|" .. curUser.sIP .. "> " .. "User Connected" 
end 

function tokenize (inString,token) 
_WORDS = {} 
local matcher = "([^"..token.."]+)" 
gsub(inString, matcher, function (w) tinsert(_WORDS,w) end) 
return _WORDS 
end 

--// This function is fired when an operator enters the hub 
function OpConnected(curUser) 
sConnectlog = sConnectlog .. "\n" .. "<"..date("%c|") .. curUser.sName .. "|" .. curUser.sIP .. "> " .. "Operator Connected" 
end 

--// This function is fired when an user disconnects 
function UserDisconnected(curUser) 
sConnectlog = sConnectlog .. "\n" .. "<"..date("%c|") .. curUser.sName .. "|" .. curUser.sIP .. "> " .. "User Disconnected" 
end 

--// This function is fired when an operator disconnects 
function OpDisconnected(curUser) 
sConnectlog = sConnectlog .. "\n" .. "<"..date .. "|" .. curUser.sName .. "|" .. curUser.sIP .. "> " .. "Operator Disconnected" 
end 

function OnTimer() 
-- DirtyUsers:saveToFile(HubSettings.HubDataFile,FileIPList) 
if sDatalog ~= "" then 
local f = appendto(Datalogfile) 
write(sDatalog) 
sDatalog = "" 
closefile(f) 

end 
if sConnectlog ~= "" then 
local f = appendto(Connectlogfile) 
write(sConnectlog) 
sConnectlog = "" 
closefile(f) 

end
if sSDatalog ~= "" then 
local f = appendto(SecondDatafile) 
write(sSDatalog) 
sSDatalog = "" 
closefile(f) 

end  
saveStatistics (Statisticsfile) 

end 


function print (...) 
local s ="" 
for i=1,arg.n do 
s = s..tostring(arg[i]).."\t" 
end 
SendToAll ("",s) 
end 

function splitstring (string,token) 
token = token or " " 
local n = strfind(string,token) 
if n then 
return strsub(string,1,n-1) , strsub(string,n+1) 
else 
return string , "" 
end 
end 

function loadStatistics (file) 
assert(readfrom(file),"stats.txt not found.Generating new stats.txt. All is fine. Don't panic.") 
dostring(read("*all")) 
readfrom() 
end 

function saveStatistics (file) 
writeto(file) 
local l = {} 
for k,v in Statistics do 
tinsert(l,k) 
end 
sort(l) 

local s = "Statistics = { \n" 
for i=1,getn(l) do 
s = s .. "\t" .. l[i] .. " = " .. tostring(Statistics[l[i]]) .. ", \n" 
end 
local s = s.."}" 
write(s) 
writeto() 
end

Have to create a DataLog folder in the script folder.

I?m using ptokax 0.3.3.0 debug 15.18, is there any more recently coud be that.

Best regards, nErBoS
--## nErBoS Spot ##--

tezlo

#3
the user object cant have a sMyInfoString property until the client actually sends the first $MyINFO

NightLitch

ptokax 0.3.3.0 debug 15.18 have a tendes to lose MyInfo quite often.

that version is not stable.

ptokax 0.3.3.0 debug 15.25 is the best so far in my eyes.

/NL
//NL

tezlo

MyINFOs dont get "lost".. user.sMyInfoString is always nil on $ValidateNick (for instance) because it comes before $MyINFO

nErBoS

Hi,

If i understod tezlo the script isn't catching user.sMyInfoString because is nil, why ??? is this a bug ?? please examplain me..

Best regards, nErBoS
--## nErBoS Spot ##--

tezlo

#7
i just did.. its not a bug its obvious
everytime DataArrival() triggers the script tries to strfind something in user.sMyInfoString
in the login sequence.. $Key and $ValidateNick come before $MyINFO so there is no user.sMyInfoString at that point

Guibs

Hi there,

tezlo is right, yep, & it's not a bug,,

When a user log, there is an order,,
In first, the datas come from:
> function DataArrival(curUser, sData) < all incoming datas are going thrue this function, and datas on login received are in first:
"$ValidateNick" key < nick is coming, & not yet the user :)
"$MyINFO" < user has send Client infos,, & is now connected
Then, function NewUserConnected(curUser) is called, like a confirmation,...

So, the lines like:
----
if strfind(curUser.sMyInfoString, "----
is right only if user has send the "$MyINFO" key,

So, after the line > elseif s == "$MyINFO" then  < you could try:
----
elseif s == "$MyINFO" then 
	Statistics.MyINFO = Statistics.MyINFO + 1 
	if strfind(curUser.sMyInfoString, " " .. client .. "|" .. version
----
It should maybe work better,,

good luck,, ;)
-- Please,... don\'t ask help in Pm,...Forums are made for that, to help everyone & my Inbox pm will be safe,... Thks,,  :))  --
CB forum     /     CB Home page

NightLitch

QuoteOriginally posted by tezlo    
MyINFOs dont get "lost".. user.sMyInfoString is always nil on $ValidateNick (for instance) because it comes before $MyINFO

Well they do, many of us here have had those problems in the scripts. I don't know now if your just talking about this script above. But Optimus had the same problem a while ago when 15.18 was the latest. Plop had it.

We by passed it with:
if curUser.sMyInfoString==nil then

or

if (strsub(data,1,7) == "$MyINFO") then
   local _,_,MyInfo = strfind(data, "(.*)")
   if MyInfo==nil then

this took care of my problem and I got the solve from Optimus script.

/NL
//NL

NightLitch

Am I alone remembering this "bug".

Plop, Optimus.... others...

I Am so sure of this.
//NL

tezlo

its not what causes the error anyway..
are you sure you werent trying to get sMyInfoString on $ValidateNick too?

nErBoS

#12
Hi,

Thanks to all complete understood on this metter, solved all my bugs :)

Best regards, nErBoS
--## nErBoS Spot ##--

NightLitch

QuoteOriginally posted by tezlo    
its not what causes the error anyway..
are you sure you werent trying to get sMyInfoString on $ValidateNick too?

 
Yes Am sure, Try doing this, install my bot NXS-3 and anther script that uses strfind in NewUserConnected for ex:

NXS-3 2.9 and a ip-bot that strfind in NewUserConnected or a ISPChecker etc.

And that NXS-3 loads last. then you have a strfind error.

Same error occurr in Glory if something before main script, why ???

/NL
//NL

kepp

It's nothing else than a bug indeed..
Guarding    

SMF spam blocked by CleanTalk