PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: Exile on 09 January, 2005, 13:53:45

Title: Help with script (not working)
Post by: Exile on 09 January, 2005, 13:53:45
I have started a Hub Bot and am having some problems...
I have no errors in the syntax, but when I try and do the !version command I don't get anything back in the hub...
Also when I enter as unregistered it is meant to show me a Download and Search disabled message, which it doesnt... :S:S:S

No errors, yet I dont see anything :S

-- Evil-Eye v1.00a by Exile?.
-- GUI built by Exile? (Current GUI Version is: Unreleased Beta Edition).
-- Email [EMAIL]btadiar@yahoo.co.uk[/EMAIL] to receive newest GUI version.

-- Script Variables (Soon to be Read From Settings.ini)
BotName = "Evil-Eye"
CurrentVersion = "Evil-Eye v1.00a"
NoUpload = "0"
NoDownload = "1"
NoSearch = "1"


--Register BotName
function Main()
frmHub:RegBot(BotName)
end

-- CurrentVersion Command (Displays Current Script Version in the Hub)
function DataArrvial (user, data)
if (strsub(data,1,1)=="<") or (strsub(data,1,5+strlen(BotName))=="$To: "..BotName) then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
if cmd=="!version" then
user:SendData(BotName, "This Hub is Running "..CurrentVersion.." by Exile?") -- Send User the Script Version
return 1
end


-- Block Unregistered User Uploads
if (strsub(data, 1, 12) == "$ConnectToMe") and user.iProfile== "-1" and NoUpload == "1" then
user:SendData("\r\n*** Search & Download/Upload Disabled!!! You are not Registered. Search & Download/Upload are Disabled.\r\n")
return 1
end

-- Block Unregistered User Downloads
if( strsub(data, 1, 12) == "$RevConnectToMe") and user.iProfile== "-1" and NoDownload == "1" then
user:SendData("\r\n***  Search & Download/Upload Disabled!!! You are not Registered. Search & Download/Upload are Disabled.\r\n")
return 1
end

-- Block Unregistered User Searches
if( strsub(data, 1, 12) == "$Search") and user.iProfile== "-1" and NoSearch == "1" then
user:SendData("\r\n***  Search & Download/Upload Disabled!!! You are not Registered. Search & Download/Upload are Disabled.\r\n")
return 1
end

end
end

Please help me :)

Truly,

Exile
Title: Says theres an end expected...i cant find it!
Post by: Exile on 09 January, 2005, 17:00:12
Script Editor saying theres an end expected to close the function at line 19 in the one you wrote optimus....icant find where to out it though...must just be me. Could you take anuva look please ?

Truly,

Exile
Title:
Post by: Optimus on 09 January, 2005, 17:11:02
-- Evil-Eye v1.00a by Exile?.
-- GUI built by Exile? (Current GUI Version is: Unreleased Beta Edition).
-- Email [EMAIL]btadiar@yahoo.co.uk[/EMAIL] to receive newest GUI version.

-- Script Variables (Soon to be Read From Settings.ini)

BotName = "Evil-Eye"
CurrentVersion = "Evil-Eye v1.00a"
NoUpload = 1
NoDownload = 1
NoSearch = 1

--Register BotName
function Main()
frmHub:RegBot(BotName)
frmHub:EnableFullData(1)
end

function DataArrival(user, data)
if (strsub(data, 1, 1) == "<" ) or (strsub(data,1,5+strlen(BotName))=="$To: "..BotName) then
data=strsub(data,1,strlen(data)-1)
s,e,cmd=strfind(data, "%b<>%s+(%S+)")
if (cmd=="!version") then
-- Send User the Script Version
user:SendData(BotName, "This Hub is Running "..CurrentVersion.." by Exile?")
return 1
end
-- Block Unregistered User Uploads
elseif (strsub(data, 1, 12) == "$ConnectToMe") then
if user.iProfile == -1 and NoUpload == 1 then
user:SendData(BotName, "*** Search & Download/Upload Disabled!!! You are not Registered. Search & Download/Upload are Disabled.\r\n")
return 1
end
-- Block Unregistered User Downloads
elseif (strsub(data, 1, 15) == "$RevConnectToMe") then
if user.iProfile == -1 and NoDownload == 1 then
user:SendData(BotName, "***  Search & Download/Upload Disabled!!! You are not Registered. Search & Download/Upload are Disabled.\r\n")
return 1
end
-- Block Unregistered User Search
elseif (strsub(data, 1, 7) == "$Search") then
if user.iProfile == -1 and NoSearch == 1 then
user:SendData(BotName, "***  Search & Download/Upload Disabled!!! You are not Registered. Search & Download/Upload are Disabled.\r\n")
return 1
end
end
end

Here ya go ;)
Title: Cheers Opti...
Post by: Exile on 09 January, 2005, 22:27:28
Right this is really annoyin me! The command !version works fine, but no unregistered users receive messages when they connect, which in theory they should, anyone help?

Using my script, modidfied by Opti, post before mine, can someone please take a look :)

Truly,

Exile
Title:
Post by: Optimus on 09 January, 2005, 22:33:23
DataArrival is for checking protocols and other stuff. That part has nothing todo with a message on connect, you need 1 extra function.

--// On-Connect
function NewUserConnected(user)
if user.iProfile == -1 then
user:SendData(BotName, "***  Search & Download/Upload Disabled!!! You are not Registered. Search & Download/Upload are Disabled.\r\n")
end
end
Btw there are enough samples on the forum to learn these basic things. It isn't that hard

Greetingz Optimus
Title:
Post by: Optimus on 09 January, 2005, 22:38:34
Below is a common script skeleton, you can/may use as a good starting point.

--// PtokaX script skeleton START ----------------------------------------------------
-- if you need any global variable, define them outside any function
-- for example here, onthe top of the script


--// below are predefined functions which are called by the hub on a specific action


--// This function is fired at the serving start
function Main()
  -- TODO your code here
end


--// This function is fired when a new data arrives
function DataArrival(user, sData)
  -- TODO your code here
end


--// This function is fired when a new user finishes the login
function NewUserConnected(user)
  -- TODO your code here
end


--// This function is fired when an operator enters the hub
function OpConnected(user)
  -- TODO your code here
end

--// This function is fired when an user disconnects
function UserDisconnected(user)
  -- TODO your code here
end

--// This function is fired when an operator disconnects
function OpDisconnected(user)
  -- TODO your code here
end


--// PtokaX script skeleton END ----------------------------------------------------
This is how it basicly work
Title:
Post by: ??????Hawk?????? on 09 January, 2005, 22:39:01
hi m8  ..

Add this Function to the script..

function NewUserConnected(curUser)
--   curUser:SendPM(BotName,"***  Search & Download/Upload Disabled!!! You are not Registered. Search & Download/Upload are Disabled.\r\n")   --// Send Pm To user on connect
curUser:SendData(BotName,"***  Search & Download/Upload Disabled!!! You are not Registered. Search & Download/Upload are Disabled.\r\n")   --// Send main chat message To user on connect
end


remove  and add the  --   to the line you Dont want to use.

Or  just remve the unwanted line

* * * EDIT  Removed a double quote from the code * * *

also noticed i must have had the Reply window open far too long  ..  Opti got there first   ;)


??????Hawk??????
Title:
Post by: Optimus on 09 January, 2005, 22:44:23
Quotefunction NewUserConnected(curUser)
--     curUser:SendPM(BotName,"***  Search & Download/Upload Disabled!!! You are not Registered. Search & Download/Upload are Disabled.\r\n")      --// Send Pm To user on connect
   curUser:SendData(BotName,"***  Search & Download/Upload Disabled!!! You are not Registered. Search & Download/Upload are Disabled.\r\n")      --// Send main chat message To user on connect
end
Shouldn't that be
function NewUserConnected(user)
--   user:SendPM(BotName,"***  Search & Download/Upload Disabled!!! You are not Registered. Search & Download/Upload are Disabled.\r\n")   --// Send Pm To user on connect
user:SendData(BotName,"***  Search & Download/Upload Disabled!!! You are not Registered. Search & Download/Upload are Disabled.\r\n")   --// Send main chat message To user on connect
end
Title:
Post by: ??????Hawk?????? on 09 January, 2005, 22:49:07
hi  opti ..

am  i missing something  or is it because were  posting at the same time    lolol