PtokaX forum

Archive => Archived 5.0 boards => Finished Scripts => Topic started by: -RICK- on 27 April, 2006, 01:32:00

Title: Simpel send hubrules in own language / or help.txt files
Post by: -RICK- on 27 April, 2006, 01:32:00
-- RICK--
-- 2006
-- Lua 5.0
-- login multilanguage on request
-- Sends PM to new connected Users and they can choose what language they want
-- Make folder Loginmessages and put in there Language.txt (put languase's u have in it englich dutch ect)
-- Put in same folder all language.txt files
-- it also can be used for all your help files (for choosen profiles)

--[[
Example
-----------------------------------------------
Language.txt
put your languase's in here
dutch
english
------------------------------------------
english.txt
put your english text in here
-------------------------------------------
dutch.txt
putt your dutch text in here
-------------------------------------------
-- or set login to 0 and you can use it for
-- all your help files activated by pm to bot
]]--


sBotName = "testhelp"   -- botname
Login = 1               -- show login text

tsettings = {           --Who recieves massages at login or/and have acces to text files  1= recieve or/and have acces
["AllowedProfiles"] ={
[0] = 1,   -- Masters
[1] = 1,   -- Operators    
[2] = 0,   -- Vips      
[3] = 0,   -- Regs
[4] = 1,   -- Moderator
[5] = 1,   -- Netfounder      
[-1] = 1,  -- Users      
}
}

function Main()
frmHub:RegBot(sBotName)
end

function ToArrival(user, data)
data=string.sub(data,1,string.len(data)-1)
local s,e,cmd = string.find(data,"%$%b<>%s+(%S+)")
        cmd = string.lower(cmd)
showtext(user, cmd)
return 1
end

NewUserConnected = function(user)
    if tsettings["AllowedProfiles"][user.iProfile] == 1 and Login == 1 then
        cmd = "Language"
        showtext(user, cmd)
    end
end
OpConnected=NewUserConnected

function showtext(user, cmd)
    if tsettings["AllowedProfiles"][user.iProfile] == 1 then
        local contents ="\r\n\r\n"
        local bFile = io.open("Loginmessages/"..cmd..".txt")
        if bFile then
            for line in io.lines("Loginmessages/"..cmd..".txt") do
                line = ("\t"..line)
                contents = contents..line.."\r\n"
            end
            user:SendPM(sBotName,"\r\n"..contents.."\r\n|")
        end
    end
end
   
Title: Re: Simpel send hubrules in own language / or help.txt files
Post by: Markitos on 27 April, 2006, 08:58:13
Just a curiosity...is local s,e,cmd = string.find(data,"%$%b<>%s+(%S+)") the same of %b<>%s+(%S+)$???

Cheers
Title: Re: Simpel send hubrules in own language / or help.txt files
Post by: -RICK- on 28 April, 2006, 12:08:38
its a standard thing in my compiler its not needed but it doesnt harm :)
Title: Re: Simpel send hubrules in own language / or help.txt files
Post by: jiten on 28 April, 2006, 18:44:22
Quote from: Markitos on 27 April, 2006, 08:58:13
Just a curiosity...is local s,e,cmd = string.find(data,"%$%b<>%s+(%S+)") the same of %b<>%s+(%S+)$???

Not really. There's a difference between the usage of a single $ and a %$.

The first one is the opposite of ^, and should be used to define the exact ending of a string - this is what happens in the second string.find.

However, as you can see the latter - %$ - contains a escape for the magic character $, so it matches the $ itself.
Title: Re: Simpel send hubrules in own language / or help.txt files
Post by: Markitos on 28 April, 2006, 21:19:22
Quote from: jiten on 28 April, 2006, 18:44:22
Quote from: Markitos on 27 April, 2006, 08:58:13
Just a curiosity...is local s,e,cmd = string.find(data,"%$%b<>%s+(%S+)") the same of %b<>%s+(%S+)$???

Not really. There's a difference between the usage of a single $ and a %$.

The first one is the opposite of ^, and should be used to define the exact ending of a string - this is what happens in the second string.find.

However, as you can see the latter - %$ - contains a escape for the magic character $, so it matches the $ itself.
thnks
Title: Re: Simpel send hubrules in own language / or help.txt files
Post by: [HE]Newbie on 07 June, 2006, 01:04:01
-- A bit late i know

-- Is there no way to let the hub reconize wich land the user is from, like Verlihub can ( if i'm right ). Would be much easyer and think much users are irritating of the PM on logon
Title: Re: Simpel send hubrules in own language / or help.txt files
Post by: Dessamator on 07 June, 2006, 09:38:42
Indeed it is, u can use the geoip script to find out where a user is from.
You can change this :
user:SendPM(sBotName,"\r\n"..contents.."\r\n|") to this:
user:SendData(sBotName,"\r\n"..contents.."\r\n|")
to avoid those "irritating " PMs.
Title: Re: Simpel send hubrules in own language / or help.txt files
Post by: -RICK- on 09 June, 2006, 04:01:04
thx des i did read it a bit late  ;D
Title: Re: Simpel send hubrules in own language / or help.txt files
Post by: Dessamator on 09 June, 2006, 08:03:22
Ur welcome, btw im not sure why you 're using an endpipe in the sendpm, its not needed under normal conditions.