PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: b_w_johan on 06 March, 2005, 13:49:44

Title: check nick and start a function
Post by: b_w_johan on 06 March, 2005, 13:49:44
this is what i want ..

a users connects ...

the script checks his nick,
if the first 5 symbols in his nick are correct there will be a function started


if --user nick has 5 symbols like [MNH]
doMNH(user)
return 1
end
end

function doMNH(user)
-- some function i have to make for those users
end


and i asked before how to give a key to a user as well ..
without user being registerd .. i guess this must be possible ... but this is yust an addition nothing importands to the rest of the script

Greetings Johan
Title:
Post by: TTB on 06 March, 2005, 15:24:21
Hi,

I'm not that good (in LUA), but I think this is it what you are looking for:

function NewUserConnected(user)
if strlower(strsub(user.sName,1,5) == "[BLA]" then
Bla(user)
end

function Bla(user)
end

To give every user a key? -> don't know that.
Title:
Post by: b_w_johan on 08 March, 2005, 09:44:53
Thx ill try if it works

greetings Johan
Title:
Post by: b_w_johan on 08 March, 2005, 09:53:51
it gives this error ..


No syntax errors in script file test.lua
Script started.
Syntax error: attempt to concat global `maxslots' (a nil value)
stack traceback:
   1:  function `doInfo' at line 41 [file `...VER.000\Bureaublad\2nlmoviehub\scripts\test.lua']
   2:  function `DataArrival' at line 19 [file `...VER.000\Bureaublad\2nlmoviehub\scripts\test.lua']

maxslots ok ii get that one it says 0 slots so ..

this is all in the script i have now ..




botName = "[MNH]"
function Main()
frmHub:RegBot(botName)
SendToAll(" ? "..botName.." launched"..date(" the %d/%m/%Y at %X ")..". ? type !info to test")
end


function NewUserConnected(user)
if strlower(strsub(user.sName,1,5)) == "[MNH]" then
doInfo(user)
end
end

function DataArrival(user,data)
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")

if cmd=="!info" then
doInfo(user)
return 1
end
end

function doInfo(user)
user:SendData(botName,"De hubnaam: "..frmHub:GetHubName()..".|") -- hubname
user:SendData(botName,"De hub discriptie "..frmHub:GetHubDescr()..".|") -- discriptie
user:SendData(botName,"Er zijn nu: "..frmHub:GetUsersCount().." Users aanwezig zouden meer moeten zijn dus reset de array =-p |") -- aantal users
user:SendData(botName,"Het Redirect adres is: "..frmHub:GetRedirectAddress()..".|") -- redirectadres
if frmHub:GetRedirectAll()==0 then
user:SendData(botName,"Verbindende users worden niet automatisch geredirect.|") -- als geen adres
else
user:SendData(botName,"Verbindende users worden automatich gestuurd naar: "..frmHub:GetRedirectAddress()..".|") -- als wel adres
end
if frmHub:GetRedirectFull()==0 then
user:SendData(botName,"Verbindende users worden niet geredirect als de hub vol is.|") -- bij vol niet redirect
else
user:SendData(botName,"Verbindende users worden geredirect naar: "..frmHub:GetRedirectAddress().." als de hub vol is.|") -- bij vol wel redirect
end
user:SendData(botName,"Hub is geregistreerd bij deze hubs lists: "..frmHub:GetRegServer()..".|") -- registerd in hublists
user:SendData(botName,"Max users staat op: "..frmHub:GetMaxUsers()..".|") -- maxusers
user:SendData(botName,"Max slots staat op: "..maxslots..".|") -- maxslots
end
 


but the only problem is: when connecting with the nick
[MNH]johan

nothing happens ...
only those errors on top
!info works correct...

well not totally =-p


all stuff from above + this message =-p

[09:50] *** You are not allowed to use this command!
hope someone can help me

Greetings Johan
Title:
Post by: b_w_johan on 08 March, 2005, 17:39:55
yust found out this error:
stack traceback:
1: function `doInfo' at line 41 [file `...VER.000\Bureaublad\2nlmoviehub\scripts\test.lua']
2: function `DataArrival' at line 19 [file `...VER.000\Bureaublad\2nlmoviehub\scripts\test.lua']

comes when i say in main !info

so i think that the nick isn't checked at al while connecting ...

maybe someone else now how to get it work ??

Greetings Johan
Title:
Post by: b_w_johan on 08 March, 2005, 17:53:57
if its difficult to show some stats while connecting.....

maybe there is a possibility to check who uses the command !info ...
so only users wich has [MNH]nick
can use it ....

but i like the option send when connect ...
but i can use it this way to ..

greetings Johan
Title:
Post by: b_w_johan on 08 March, 2005, 17:58:42
ok ive found the error myself ...

for the ones who like to use it ...
here is it again...


botName = "Hubstats" -- botname

function Main()
frmHub:RegBot(botName)
SendToAll(" ? "..botName.." launched"..date(" the %d/%m/%Y at %X ")..". ? type !info to test")
end

function NewUserConnected(user)
if strlower(strsub(user.sName,1,5)) == "[mnh]" then -- Make sure its lowercase !
doInfo(user)
end
end

function DataArrival(user,data)
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")

if cmd=="!info" then
doInfo(user)
return 1
end
end

function doInfo(user)
user:SendData(botName,"De hubnaam: "..frmHub:GetHubName()..".|") -- hubname
user:SendData(botName,"De hub discriptie "..frmHub:GetHubDescr()..".|") -- discriptie
user:SendData(botName,"Er zijn nu: "..frmHub:GetUsersCount().." Users aanwezig zouden meer moeten zijn dus reset de array =-p |") -- aantal users
user:SendData(botName,"Het Redirect adres is: "..frmHub:GetRedirectAddress()..".|") -- redirectadres
if frmHub:GetRedirectAll()==0 then
user:SendData(botName,"Verbindende users worden niet automatisch geredirect.|") -- als geen adres
else
user:SendData(botName,"Verbindende users worden automatich gestuurd naar: "..frmHub:GetRedirectAddress()..".|") -- als wel adres
end
if frmHub:GetRedirectFull()==0 then
user:SendData(botName,"Verbindende users worden niet geredirect als de hub vol is.|") -- bij vol niet redirect
else
user:SendData(botName,"Verbindende users worden geredirect naar: "..frmHub:GetRedirectAddress().." als de hub vol is.|") -- bij vol wel redirect
end
user:SendData(botName,"Hub is geregistreerd bij deze hubs lists: "..frmHub:GetRegServer()..".|") -- registerd in hublists
user:SendData(botName,"Max users staat op: "..frmHub:GetMaxUsers()..".|") -- maxusers
user:SendData(botName,"Max slots staat op: "..maxslots..".|") -- maxslots
end

 


Greetings Johan..

btw:

still looking for this option when someone uses !info check his nick if its [MHN] then send the function doInfo(user)

if its else send youre not supposed to use this command !
Title:
Post by: TTB on 13 March, 2005, 17:29:38
You finished script... You got it already from me, but maybe other users would like to use this!


botName = "Hubstats"                                                                -- botname

function Main()
    frmHub:RegBot(botName)
    SendToAll("    ? "..botName.." launched"..date(" the %d/%m/%Y at %X ")..". ? type !info to test")
end

function DataArrival(user,data)
 data=strsub(data,1,strlen(data)-1)
 s,e,cmd = strfind(data,"%b<>%s+(%S+)")
 if cmd=="!info" then
  doInfo(user)
 end
 return 1
end

function doInfo(user)
 if strsub(user.sName,1,5) == "[mnh]" then
    user:SendData(botName,"De hubnaam: "..frmHub:GetHubName()..".|")                                    -- hubname
    user:SendData(botName,"De hub discriptie "..frmHub:GetHubDescr()..".|")                                    -- discriptie
    user:SendData(botName,"Er is/zijn nu: "..frmHub:GetUsersCount().." user(s) aanwezig. Dit zouden meer moeten zijn dus, reset de array =] |")    -- aantal users
    user:SendData(botName,"Het Redirect adres is: "..frmHub:GetRedirectAddress()..".|")                            -- redirectadres
    if frmHub:GetRedirectAll()==0 then
        user:SendData(botName,"Verbindende users worden niet automatisch geredirect.|")                            -- als geen adres
    else
        user:SendData(botName,"Verbindende users worden automatich gestuurd naar: "..frmHub:GetRedirectAddress()..".|")            -- als wel adres
    end
    if frmHub:GetRedirectFull()==0 then
        user:SendData(botName,"Verbindende users worden niet geredirect als de hub vol is.|")                        -- bij vol niet redirect
    else
        user:SendData(botName,"Verbindende users worden geredirect naar: "..frmHub:GetRedirectAddress().." als de hub vol is.|")    -- bij vol wel redirect
    end
    user:SendData(botName,"Hub is geregistreerd bij deze hubs lists: "..frmHub:GetRegServer()..".|")                    -- registerd in hublists
    user:SendData(botName,"Max users staat op: "..frmHub:GetMaxUsers()..".|")                                -- maxusers
 else
 user:SendData(botName, " *** You are not allowed to use this command ***")
 end
end

Note: The prefix is case sensitive.