AuthorMessage
InfErnuS
n00b
Posts: 28

Ok i haven't written a script in god knows how long, but after seeing the PM blocker i was inspired to write a script blocking search and downloads for unregistered users. After writing the script I have tried to use it in my hub and it yielded no result This is what i wrote:
Code:
-- Disable Search and Download for Unregs
-- 0.01 by Centurion
-- Meka][Meka Lua Plugin Required.
function DataArrival(user, data)
   if string.find(data, $Search) ~= nil and user.iProfile == Default then
            SendChatTo(user.iUserID, Hub.BotName(), 'Searching is disabled for unregistered users. Please register by typing +report Can I be Registered?');
            return 1;
   end;
   if string.find(data, $ConnectToMe) ~= nil and user.iProfile == Default then
            SendChatTo(user.iUserID, Hub.BotName(), 'Downloading from others is disabled for unregistered users. Please register by typing +report Can I be Registered?');
            return 1;
   end;
end;

Yes i know it's sloppy, and i'm a mediocre scripter, but I can't see what is wrong with the script. Maybe someone with more experience in lua can point out a problem with my syntax or something that's missing.
CrazyGuy
n00b
Posts: 32

user.iProfile returns an integer.
so user.iProfile == Default will always result in a nil / false
use GetProfileName(user.iProfile) == "Default" instead
also, you have to double qoute your other strings
"~= nil" equivalation is not needed as "if" will return a boolean, with false for nil and true for all other values.
you do block CTM, but not RevCTM ( i removed the $ in that search as the rest of the string does count for both)
Code:

-- Disable Search and Download for Unregs
-- 0.01 by Centurion
-- slightly touched by CrazyGuy
-- Meka][Meka Lua Plugin Required.
function DataArrival(user, data)
   if string.find(data, "$Search") and GetProfileName(user.iProfile) == "Default" then
            SendChatTo(user.iUserID, Hub.BotName(), 'Searching is disabled for unregistered users. Please register by typing +report Can I be Registered?');
            return 1;
   end;
   if string.find(data, "ConnectToMe")  and GetProfileName(user.iProfile) == "Default" then
            SendChatTo(user.iUserID, Hub.BotName(), 'Downloading from others is disabled for unregistered users. Please register by typing +report Can I be Registered?');
            return 1;
   end;
end;

besides that I'd like to point out that not just the Default profile is for unregistered users. You might want to use a table with profile names instead
InfErnuS
n00b
Posts: 28

i came in my hub as an unregistered user and the script is still not yielding an effect   i think it has something to do with the plugin version? i am using the last release and i noticed that the scripting style might differ from older versions of the plugin. i say "might" because i'm not too sure if that's correct.
Lord_Zero
Ametuar
Posts: 122

Using a script like this is not a solution. If a user will lose some of his rights the hub will automatically move him to the profile which matches his new rights and the script will no longer stop him from downloading.
You can remove the right connect4 (can connect to users) from the default profile and users need to register (or to be moved to another profile which has that right) to be able to download or search.
InfErnuS
n00b
Posts: 28

that works well lol.. ty for the reply
Chucky
n00b
Posts: 22

If we remove the right connect4 (can connect to users) , the user wont be able to download or search but wont be able to share also...   is there a way to go around this ?
So that non registed users may not download or search, but can share his files ?
By what i can see there's a new luaplugin...   So this scripts "-- Meka][Meka Lua Plugin Required" wont work on it ?  need new scripts, right ?
<<--- kind a nOOb on Hexhub....working on it   8)
Lord_Zero
Ametuar
Posts: 122

Quoted from Chucky
If we remove the right connect4 (can connect to users) , the user wont be able to download or search but wont be able to share also...   is there a way to go around this ?

The idea behind this is "fair hideshare" - those who don't want others to download from them should not try to download from others. Also, those who want to protect their IP address from being seen by normal users can have this right removed.
If you want this setting to save hub's b/w from traffic made by unregistered users - there are not many users who would stay in a hub where only others can download from them.