PtokaX forum

Lua 5.3/5.2/5.1 Scripts (for PtokaX 0.4.0.0 and newer) => Help with scripts => Topic started by: sauron747 on 29 July, 2008, 22:33:54

Title: Problem with PM on connect script
Post by: sauron747 on 29 July, 2008, 22:33:54
Hi I have problem with the script. When I wan't to load script to ptokax, show me a error message:
\scripts\PM on connect.lua:7: attempt to index global 'frmHub' (a nil value)
The another problem is that I need a script who will be send to all user PM, when they will connect to my hub. I need this script because I have a rules, and I need show this every time in pm when the users connect. I can't find a good script for that. Do You help me?
This is the script, but for unregister users:

--[[

GuestMsg 1.0 LUA 5.1x [Strict] [API 2]

By Mutor 02/09/08
Requested by Giorgos

Sends a message to all online unregistered users on interval
- Message read from text file to allow ease of message change
- Option to send message in main chat or pm

]]

-- File to send to guests [unregistered user]
local File = "Guest.txt"
-- Interval in minutes to send guest message
local Mins = 5
-- Send in PM? true/false [if false message is sent in main]
SendPm = true


local S,Tm = "",0
OnStartup = function()
if File:len() > 0 then
local f,e = io.open(File)
local s = f:read("*a") f:close()
if s and s:len() > 0 then
S = "\n\n"..s
end
end
if S:len() > 0 then
Tm = TmrMan.AddTimer(Mins * 60000)
OnTimer(Tm)
end
end

OnTimer = function(Id)
if Id == Tm then
local Bot = SetMan.GetString(21)
for _,user in ipairs(Core.GetOnlineUsers(-1)) do
if SendPm then
Core.SendPmToUser(user,Bot,S.."|")
else
Core.SendToUser(user,"<"..Bot.."> "..S.."|")
end
end
end
end


I use many scripts, but when I load and check in hub they doesn't work. Please help.
Thanks for all advice.
Title: Re: Problem with PM on connect script
Post by: sauron747 on 30 July, 2008, 01:21:04
Mutor you are the best of ever on this forum. The script is brilliant  :) You are brilliant  ;) I have hope that You will stay on this forum for many many years, and writes many many scripts because each script or help which You do, is briliant and this is what you must to do.
I wish you every happiness  :) Thanks so much