need help to my DataArrival - Page 3
 

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

need help to my DataArrival

Started by Themaster, 24 September, 2004, 01:25:15

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Themaster

that i mean is when i do this ? in main is get a nil in ptokax how can i fix it
peace out...and love to your all scripter..that do the hard work  :D And all thx to your all there are here 2 help!!! :]

blade.lir.dk

Themaster

now i got what is made that error and i need help to get it write

  if (strsub(data, 1, 1) == "<" ) then
   local data = strsub(data,1,strlen(data)-1)
   local _,_,prefix,cmd=strfind(data, "%b<>%s+(%S)(%S+)")
      if Tprefix[prefix] and cmd then
         prefixcmd = Tprefix[prefix]..cmd
         local Commands = Commands(user, data, cmd)
         return Commands
peace out...and love to your all scripter..that do the hard work  :D And all thx to your all there are here 2 help!!! :]

blade.lir.dk

bastya_elvtars

Try this!

  if (strsub(data, 1, 1) == "<" ) then

   local data = strsub(data,1,strlen(data)-1)

   local _,_,prefix,cmd=strfind(data, "%b<>%s+(.)(%S+)")

      if Tprefix[prefix] and cmd then

         prefixcmd = Tprefix[prefix]..cmd

         local Commands = Commands(user, data, cmd)

         return Commands
Everything could have been anything else and it would have just as much meaning.

Themaster

i still got the same error :s
peace out...and love to your all scripter..that do the hard work  :D And all thx to your all there are here 2 help!!! :]

blade.lir.dk

bastya_elvtars

post me the tprefix table

but already told u not 2 make a table 4 this
Everything could have been anything else and it would have just as much meaning.

Themaster

i have try to get it short but it still made the error

in DataArrival

  if (strsub(data, 1, 1) == "<" ) then
   local data = strsub(data,1,strlen(data)-1)
   local _,_,prefix,cmd=strfind(data, "%b<>%s+(.)(%S+)")
      if Tprefix[prefix] and cmd then
         prefixcmd = Tprefix[prefix]..cmd
         local Commands = Commands(user, data, cmd)
         return Commands

in Setup
--// Prefix
Tprefix = {
["!"] = 1,
["+"] = 1,
["-"] = 1,
["/"] = 1,
}
peace out...and love to your all scripter..that do the hard work  :D And all thx to your all there are here 2 help!!! :]

blade.lir.dk

VidFamne

If prefix is a control charackter you could use %c in reg.exp

Themaster

peace out...and love to your all scripter..that do the hard work  :D And all thx to your all there are here 2 help!!! :]

blade.lir.dk

bastya_elvtars

  if (strsub(data, 1, 1) == "<" ) then

   local data = strsub(data,1,strlen(data)-1)

   local _,_,cmd=strfind(data, "%b<>%s+(%S+)")

      if cmd and Tprefix[strsub(cmd,1,1)] then -- gets the 1st char of the cmd string and sees if its in the table

         prefixcmd = cmd

         local Commands = Commands(user, data, strsub(cmd,2,strlen(cmd))) -- stripping the prefix

         return Commands

Now some notes:

/ as prefix is bad, not all clients send it 2 hub

Dont use a table when u can use:

local _,_,cmd=strfind(data,"%b<>%s+[%!%+%-%/](%S+)) -- checks if the 1st word in main is starting with ! or - or / or +
Everything could have been anything else and it would have just as much meaning.

Themaster

k...now i got it..but why can't i made so there are a table to change it else ??
peace out...and love to your all scripter..that do the hard work  :D And all thx to your all there are here 2 help!!! :]

blade.lir.dk

bastya_elvtars

whats the use of having it all in a table? or whats the harm, if  u dont prevent users using +help instead of !help?
Everything could have been anything else and it would have just as much meaning.

Themaster

Hmm....now my commands is dead !!!!
peace out...and love to your all scripter..that do the hard work  :D And all thx to your all there are here 2 help!!! :]

blade.lir.dk

bastya_elvtars

i dont understand what u r up to so please post the entire script
Everything could have been anything else and it would have just as much meaning.

Themaster

you have post this

local _,_,cmd=strfind(data,"%b<>%s+[%!%+%-%/](%S+)) -- checks if the 1st word in main is starting with ! or - or / or +

it just need a "
local _,_,cmd=strfind(data,"%b<>%s+[%!%+%-%/](%S+)") -- checks if the 1st word in main is starting with ! or - or / or +

that why it was dead
peace out...and love to your all scripter..that do the hard work  :D And all thx to your all there are here 2 help!!! :]

blade.lir.dk

bastya_elvtars

ah sry just bought my new HDD and im moving about 100G data, so i am attending to 6 things - sry
Everything could have been anything else and it would have just as much meaning.

Themaster

ok...hmm...damn now when i do +help there is nothing going on :s
peace out...and love to your all scripter..that do the hard work  :D And all thx to your all there are here 2 help!!! :]

blade.lir.dk

Themaster

#66
hm i can't Not get it work write now... here is my script

sec = 1000
min = 60*sec
hour = 60*min
day = 24*hour

Version ="Blade? 1.0"
Build ="?1.7?"
Creators ="Themaster?"


HubName = frmHub:GetHubName()
HubDesc = frmHub:GetHubDescr()
Redirect = frmHub:GetRedirectAddress()
MaxUsers = frmHub:GetMaxUsers()
MinShare = frmHub:GetMinShare(3)

pmArray={}
awayArray={}
MainArray={}
Symbol = { "%c", "?", "|" }
maxkicks = 3
kicks = {}
warn = {}

ScriptRestart = {}
Kennylizednicks = {}
savekicks = "blade/logs/count.kicks.txt"
WriteKickBan = "blade/logs/writekickban.txt"
rules = "blade/txt/rules.txt"
network = "blade/txt/network.txt"
Guard_File = "blade/PeerGuardian/Guarding.P2P"

function Main()
   loadfile(savekicks)
   frmHub:UnregBot(BotName)
	frmHub:RegBot(BotName)
   frmHub:RegBot(OpChat)
   TimeSpanInMinutes = 60
   SendToAll(BotName,"?~~~~? Script ReStart at: "..date("  %X -- %d/%m-%Y").." ? Version ? "..Version.." ? Build ? "..Build.." ? Creators ? "..Creators.." ?~~~~?")
	BotNameInfo = "$MyINFO $ALL "..BotName.." <++V:1.0 Blade? 1.0,C:Themaster? $ $LAN(T3)"..strchar( 1 ).."$$"
   OpChatInfo = "$MyINFO $ALL "..OpChat.." <++V:1.0 Blade? 1.0,C:Themaster? $ $LAN(T3)"..strchar( 1 ).."$$"
   SendToAll(ScriptRestart)
   SendToAll(BotNameInfo) 
   SendToAll(OpChatInfo)
	SetTimer(TimeSpanInMinutes*60000)
	StartTimer()
end

function OnTimer()
	SendAdMessage()
end

function SendAdMessage()
	upline = "~~~~~~~~~~~~H~U~B~~S~T~A~T~S~~~~~~~~~~"
	underline = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	hubstats = "\r\n\r\n"..upline.."\r\n"..
		 "      ?Script Version:    		 "..Version.."\r\n"..
       "      ?Build:    		 	"..Build.."\r\n"..
		 "      ?Script Creator:	  	  	 "..Creators.."\r\n"..
		 "      ?Hub Name: 		    	 "..HubName.."\r\n"..
		 "      ?Hub Description:   		 "..HubDesc.."\r\n"..
		 "      ?Hub Adress:		   	 "..HubAdress.."\r\n"..
       "      ?Web Adress:		   	 "..WebAdress.."\r\n"..
		 "      ?Owner:		 	 "..HubOwner.."\r\n"..
		   "      ?Online Users:			 "..frmHub:GetUsersCount().."\r\n"..
		 "      ?Redirect Adress:   		 "..Redirect.."\r\n"..
		 "      ?Maximum Users:  	 	 "..MaxUsers.."\r\n"..
		 "      ?Hub Network:	 		 !network".."\r\n"..
		 "      ?Hub Rules:    			 !rules".."\r\n"..underline.."\r\n".." "

		SendToAll(BotName, hubstats)
end

function DataArrival(user,data)
   if (strsub(data,1,7) == "$MyINFO") then
      Tag,Speed,Share = Parse(data)
      TagCheck(Tag,Speed,Share,user)
   end
   
   if (strsub(data, 1, 1) == "<" ) then
   local data = strsub(data,1,strlen(data)-1)
   local _,_,prefix,cmd=strfind(data, "%b<>%s+(.)(%S+)")
      if Tprefix[prefix] and cmd then
         prefixcmd = Tprefix[prefix]..cmd
         local Commands = Commands(user, data, cmd)
         return Commands

      	elseif Kennylizednicks[user.sName] == 1 then
            text=kennytext[random(1, getn(kennytext))]
				SendToAll(user.sName, text)
				return 1
         end
      end
   
   replaced = nil
	local newmsg = gsub(data,"(%w+)",
   function (word)
         if tWords[strlower( word )] then
				replaced = 1
				return tWords[strlower( word )]
			else
            return word
			end
		end)
	if replaced then
		SendToAll(""..newmsg.."|")
		return 1
	end

   if strsub(data, 1, 5) == "$To: " then
      local s,e,to,from,text = strfind(data, "%$To:%s(%S+)%sFrom:%s(%S+)%s$(.*)$")
         if to == OpChat then
            if user.bOperator then
               local s,e,msg = strfind(text,"^%b<>%s+(.+)")
               OpChatRoom(user,msg)
            end
         end
      end
   end

function NewUserConnected(user,data)
   user:SendData(" Use !help in main for your Command! ")
	Connected(user)     
end
OpConnected = NewUserConnected

function OpChatRoom(user,msg)
      local allprofiles = GetProfiles()
      local index, profile, index2, nick
      for index, profile in allprofiles do
         local users = GetUsersByProfile(profile)
         for index2, nick in users do
            local usr = GetItemByName(nick)
            if usr ~= nil then
               if user.sName == usr.sName then
               else
                  if usr.iProfile == 0 or usr.iProfile == 1 or usr.iProfile == 4 then
                     usr:SendData("$To: "..usr.sName.." From: "..OpChat.." $<"..user.sName.."> "..msg)
                  end
               end
            end
         end
      end
end

function BlockGuard(ip)
   local _,_,a,b,c,d = strfind(ip "(%d*).(%d*).(%d*).(%d*)")
   if ( tonumber(a) and tonumber(b) and tonumber (c) and tonumber (d) ) then
      local uip = Computer(ip)
      if uip then
         for ranger,comp in Guard do
            local _,_,r1,r2 = strfind(ranger, "(.*)-(.*)")
            r1 = ComputeIP(r1)
            r2 = ComputeIP(r2)
            if uip>=r1 and uip <=r2 then
               return 1,comp
            end
         end
      end
   end
end

function Computer(curIP)
   local _,_,a,b,c,d = strfind (curIP, "(%d+).(%d+).(%d+).(%d+)")
   return a*16777216 + b*65536 + c+256 + d
end

function DeComputeIP(cIP)
	local temp1 = mod(cIP,16777216)
	local temp2 = mod(temp1,65536)
	return (floor(cIP/16777216).."."..floor(temp1/65536).."."..floor(temp2/256).."."..floor(mod(temp2,256)))
end

function LoadGuard(table,file)
	local handle = openfile(file, "r")
	if (handle) then
    local line = read(handle)
    while line do
			s,e,ind,val = strfind( line, "(.*):(.*)")
			if ind and val then
				table[val]=ind
			end
			line = read(handle)
    end
  	closefile(handle)
	end
end

function Readtextfile(user, file)
   	local filecontents = ""
	local handle = openfile(file, "r")
	if (handle ~= nil) then
		local line = read(handle)
		while line do
        	filecontents = filecontents..line.."\r\n"
		line = read(handle)
		end
		closefile(handle)
      	user:SendPM(Bot, filecontents)
	end
end

function Readtextfile(user,file)
   local filecontents = ""
   local line
   ret,err = readfrom("blade/txt/"..file)
   if ret then
      while 1 do
      line = read()
         if line == nil then
         break
         end
      filecontents = filecontents..line.."\r\n"
      end
      user:SendPM(BotName, filecontents)
      readfrom()
   else
      user:SendData(BotName, "Error: "..file.." not found")
   end
end

function WriteKickBan(what)
	appendto("blade/logs/banned.txt") 
		write(what.."\n")
	writeto() 
end

function WriteKicked(what)
	appendto("blade/logs/kicked.txt") 
		write(what.."\n")
	writeto() 
end

function ReadKicked(user, data)
	readfrom("blade/logs/kicked.txt")
	local message = ""
	while 1 do
	local line = read()
	if line == nil then break
	else
	message = message..line.."\r\n"
	end
end
	user:SendPM(BotName, "\r\n"..message)
end

function WriteKickBan(what)
	appendto("blade/logs/banned.txt") 
		write(what.."\n")
	writeto() 
end

function ReadKickBan(user, data)
	readfrom("blade/logs/banned.txt")
	local message = ""
	while 1 do
	local line = read()
	if line == nil then break
	else
	message = message..line.."\r\n"
	end
end
	user:SendPM(BotName, "\r\n"..message)
end

plz test it and tell me where bug is
it still a problem with ?
peace out...and love to your all scripter..that do the hard work  :D And all thx to your all there are here 2 help!!! :]

blade.lir.dk

bastya_elvtars

its only me that cant see Commands function?
Everything could have been anything else and it would have just as much meaning.

Herodes

And also i suggest you take more care in your tabbing ...

example :
function LoadGuard(table,file)
	local handle = openfile(file, "r")
	if (handle) then
    local line = read(handle)
    while line do
			s,e,ind,val = strfind( line, "(.*):(.*)")
			if ind and val then
				table[val]=ind
			end
			line = read(handle)
    end
  	closefile(handle)
	end
end
would read very very bad comparing to this :
function LoadGuard(table,file)
	local handle = openfile(file, "r")
	if (handle) then
		local line = read(handle)
		while line do
			s,e,ind,val = strfind( line, "(.*):(.*)")
			if ind and val then
				table[val]=ind
			end
			line = read(handle)
		end
	  	closefile(handle)
	end
end


Also look out for globals ... try and keep their count to as low as possible ...example

somevariable = 1 --- this is a global

local somevariable = 1 --- this is a local


this has an impact on the memory the script consumes ...

Themaster

have a lillte problem again.
it is my word replaced i have this bot if i writ some stoff in PM then they send the replaced word to all users

replaced = nil
	local newmsg = gsub(data,"(%w+)",
      function (word)
			if tWords[strlower( word )] then
				replaced = 1
				return tWords[strlower( word )]
			else
            return word
			end
		end)
	if replaced then
		SendToAll(""..newmsg.."|")
		return 1
	end
peace out...and love to your all scripter..that do the hard work  :D And all thx to your all there are here 2 help!!! :]

blade.lir.dk

bastya_elvtars

this fuction probably isnt notified if the conversation goes in PM - and the SendToAll isnt a lucky choice :P
Everything could have been anything else and it would have just as much meaning.

Themaster

if i do m8 in PM then they come a other PM with Mate
Sry i don't post that
peace out...and love to your all scripter..that do the hard work  :D And all thx to your all there are here 2 help!!! :]

blade.lir.dk

Themaster

i have that code

   replaced = nil
	local newmsg = gsub(data,"(%w+)",
      function (word)
			if tWords[strlower( word )] then
				replaced = 1
				return tWords[strlower( word )]
			else
            return word
			end
		end)
	if replaced then
		SendToAll(""..newmsg.."|")
		return 1
	end
   

if i do 1 off the thing in word replace in PM then it show it to all...and that i have a problem i just only want 2 have in main
peace out...and love to your all scripter..that do the hard work  :D And all thx to your all there are here 2 help!!! :]

blade.lir.dk

SMF spam blocked by CleanTalk