Author Topic: Server Board : HELP NEEDED  (Read 4205 times)

0 Members and 1 Guest are viewing this topic.

Offline patrick

  • Junior Member
  • **
  • Posts: 14
  • Karma: +0/-11
Server Board : HELP NEEDED
« on: 04 January, 2009, 16:22:58 »
Code: [Select]
--Server Board 1.03 10/20/04 LUA 5
--converted to LUA 5 - 09/15/05
--by American Idiot
--
-- Provides common message board. Allow users to read/write the board by profiles
-- Option to delete messages, permission bt profile
-- Caches board messages to exteernal text file for script/hub restarts
--
-- +Changes from v 1.00
-- +Added  case sensitive commands, request by NeoUltimicia
-- +Added  date/time to message, request by NeoUltimicia
-- +Errors now sent to PM as well as main
-- +Corrected save string and tweaked table read
-- +Changes from v 1.01
-- +converted to LUA 5 - by blackwings
-- +these prefixes can be used = !+?$# - by blackwings
-- +Changes from v 1.02
-- +fixed a load file bug - by blackwings
-- +Changes from v 1.03
-- +fixed file handling bug
-- +fixed left over lua4 parts
-- -removed VaildCmd stuff
-- +changed MsgBoard function to ToArrival
-- +fixed Prefix error
-- +added auto detect if bot has hubbotname
-- +fixed some minor bugs
-- +added support for mainchat
-- +fixed extra linespacing
-- ^ Moded by Madman ^
-- ?To Do
-- ?Allow users to delete their own messages
-- ?Add context menu
--
--User Settings-------------------------------------------------------------------------------------
Comm1 = string.lower("servers") -- Script Command, read board
Comm2 = string.lower("addserver") -- Script Command, write to board
Comm3 = string.lower("delserver") -- Script Command, delete messages
MaxMessages = 50 -- Max number of messages to cache
MsgBoardFile = "ServerBoard.txt" -- Message file, creat this file in your scripts dir.
rprofiles = {[0]=1,[1]=1,[2]=1,[3]=1,[-1]=1}  -- Which profiles may read the board?
wprofiles = {[0]=1,[1]=1,[2]=1,[3]=1,[-1]=1}  -- Which profiles may write to the board?
dprofiles = {[0]=1,[1]=1,[2]=1,[3]=1,[-1]=1} -- Which profiles may delete messages?
Hub = frmHub:GetHubName() -- Hub name, pulled from the Px
Bot = frmHub:GetHubBotName() -- Botname, use frmHub:GetHubBotName() or "BotName"
--End User Settings----------------------------------------------------------------------------------
BoardMessages = {}

function Main()
LoadFromFile(MsgBoardFile)
if not (Bot == frmHub:GetHubBotName()) then
frmHub:RegBot(Bot)
end
end

function ToArrival(user,data)
local s,e,whoTo = string.find(data, "%$To:%s(%S+)")
if whoTo == Bot then
  return MsgBoard(user, data)
end
end

function ChatArrival(user, data)
return MsgBoard(user, data)
end

function MsgBoard(user, data)
local data = string.sub(data,1, -2)
local s,e,cmd = string.find(data, "%b<>%s+[%!%+%?%$%#](%S+)")
if cmd then
s,e,Prefix = string.find(data, "%b<>%s+(%p)%S+")
local tCmds = {
[Comm1] = function(user, data)
if rprofiles[user.iProfile]==1 then
ReadBoard(user)
end
end,
[Comm2] = function(user, data)
if wprofiles[user.iProfile]==1 then
local s,e,msg = string.find(data, "%b<>%s+%S+%s(.*)")
if msg == nil then
local dsp
dsp = "\r\n\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
dsp = dsp.."\t"..Hub.."\tMessage Board\r\n"
dsp = dsp.."\tDid you forget what you were going to say?\r\n"
dsp = dsp.."\tCommand syntax is ->> "..Prefix..Comm2.." <your message>\r\n"
dsp = dsp.."\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
user:SendData(Bot,dsp)
SendPmToNick(user.sName,Bot,dsp)
return 1
else
Write2Board(user, msg)

end
end
end,
[Comm3] = function(user, data)
if dprofiles[user.iProfile]==1 then
local s,e,delmsg = string.find(data, "%b<>%s+%S+%s+(%d+)")
if (delmsg == nil) then
local dsp0
dsp0 = "\r\n\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
dsp0 = dsp0.."\t"..Hub.."\tMessage Board\r\n"
dsp0 = dsp0.."\tDelete which message? Provide message number\r\n"
dsp0 = dsp0.."\tCommand syntax is ->> "..Prefix..Comm3.." <msg #>\r\n"
dsp0 = dsp0.."\tType ->> "..Prefix..Comm1.."  to list messages \r\n"
dsp0 = dsp0.."\t=-=<>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=<>=-=\r\n"
user:SendData(Bot,dsp0)
SendPmToNick(user.sName,Bot,dsp0)
return 1
else
--if BoardMessages[delmsg] ~= 1 then user:SendData(Bot,dsp0) return 1 end
table.remove(BoardMessages, delmsg)
SaveToFile(MsgBoardFile , BoardMessages , "BoardMessages")
user:SendData(Bot,"Server [ "..delmsg.." ] has been deleted.")

return 0
end
end
end,
}
if tCmds[cmd] then
return tCmds[cmd](user, data)
end
end
end

function ReadBoard(user)
local n = table.getn(BoardMessages)
local dsp1
dsp1 = ""
dsp1 = dsp1.."Servers:-"
dsp1 = dsp1.."\n"
for i = 1, n do
dsp1 = dsp1.."[ "..i.." ]\t"..BoardMessages[i].."\r\n"
end
SendToAll(Bot, dsp1)
end


function Write2Board(user, msg)
local dsp2
dsp2 = ""
dsp2 = dsp2.." "..user.sName.."'s Server added."
dsp2 = dsp2..""
dsp2 = dsp2.."Type "..Prefix..Comm1.." in main."
dsp2 = dsp2.."\t"
SendToAll(Bot, dsp2)
table.insert(BoardMessages, (""..os.date("%B %d %Y %X ").." [ "..user.sName.."'s ] Server: ")..msg)
if table.getn(BoardMessages) > MaxMessages then table.remove(BoardMessages, 1) end
SaveToFile(MsgBoardFile , BoardMessages , "BoardMessages")
end

function Serialize(tTable, sTableName, sTab)
assert(tTable, "tTable equals nil");
assert(sTableName, "sTableName equals nil");
assert(type(tTable) == "table", "tTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");
sTab = sTab or "";
sTmp = ""
sTmp = sTmp..sTab..sTableName.." = {\n"
for key, value in tTable do
local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
if(type(value) == "table") then
sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
else
local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
end
sTmp = sTmp..",\n"
end
sTmp = sTmp..sTab.."}"
return sTmp
end

function SaveToFile(file , table , tablename)
local handle = io.open(file,"w+")
handle:write(Serialize(table, tablename))
handle:flush()
handle:close()
end

function LoadFromFile(file)
local handle = io.open(file,"r")
if (handle ~= nil) then
dofile(file)
handle:flush()
handle:close()
end
end
« Last Edit: 05 January, 2009, 07:26:57 by patrick »

PtokaX forum

Server Board : HELP NEEDED
« on: 04 January, 2009, 16:22:58 »

Offline ?StIfFLEr??

  • Triple Ace
  • **
  • Posts: 241
  • Karma: +17/-63
Re: Server Board : HELP NEEDED
« Reply #1 on: 04 January, 2009, 18:13:27 »
I am eagerly waiting for American Idiot to give you a very nice reply  :P
Hope you understand how the forum works soon.
Type or paste your code inside the [ code ]   [ /code ] option please.

Offline ?StIfFLEr??

  • Triple Ace
  • **
  • Posts: 241
  • Karma: +17/-63
Re: Server Board : HELP NEEDED
« Reply #2 on: 04 January, 2009, 18:17:10 »
Quote
--Server Board 1.03   10/20/04 LUA 5
--converted to LUA 5 - 09/15/05
--by Patrick
LOL
its American Idiots script u noob patrick dont asct as if you can do anything i am sure one more "-" will be comming by American Idiot
What say American Idiot I think some one just took all the credits i hope you will do the needfull.
Well anyways i have the converted version of this script but it wont be posted (untill American Idiot gives me the permission.)

Offline patrick

  • Junior Member
  • **
  • Posts: 14
  • Karma: +0/-11
Re: Server Board : HELP NEEDED
« Reply #3 on: 04 January, 2009, 18:31:26 »
Sorry American Idiot Did Not Want To Take Your Credits
I edited it in the script in the ptokax and forgot to change it
I apologise if u misunderstood it  :'(
DID NOT REALLY WANTED TO TAKE YOUR CREDIT

So The Script Goes Like Below

Offline patrick

  • Junior Member
  • **
  • Posts: 14
  • Karma: +0/-11
Re: Server Board : HELP NEEDED
« Reply #4 on: 04 January, 2009, 18:33:29 »
SORRY American Idiot IF U MISUDERSTOOD ME

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 725
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
Re: Server Board : HELP NEEDED
« Reply #5 on: 04 January, 2009, 19:23:34 »
If you really want American Idiot to forgive, please attach the file to the fist post by editing and remove that huge code snippet. :)
Everything could have been anything else and it would have just as much meaning.

Offline ?StIfFLEr??

  • Triple Ace
  • **
  • Posts: 241
  • Karma: +17/-63
Re: Server Board : HELP NEEDED
« Reply #6 on: 04 January, 2009, 20:13:33 »
But i am still waiting for American Idiots reply.
Eagarly waiting for his dictionary to be open.  :P
I hope this time i will be learning some more new words from him.
Please American Idiot do post to this forum atleast once.I would love if this Patricks gets some good bash from you.He has troubled me a lot.  :P

Offline Yahoo

  • Triple Ace
  • **
  • Posts: 225
  • Karma: +32/-14
  • People Say "I Dont Know English"
    • Yahoo
Re: Server Board : HELP NEEDED
« Reply #7 on: 10 January, 2009, 20:41:19 »
forgive me guys
but please remove this noob from the forum
he is taking credit for American Idiots scripts
we dont want such cheaters and liers on this board
"BoRN FIGhTEr"

Offline patrick

  • Junior Member
  • **
  • Posts: 14
  • Karma: +0/-11
Re: Server Board : HELP NEEDED
« Reply #8 on: 11 January, 2009, 08:30:52 »
Yahoo i said i did not want to take the credits.. and i also apologised for that...
so noo need to take this matter more further !!!

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 725
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
Re: Server Board : HELP NEEDED
« Reply #9 on: 11 January, 2009, 12:49:07 »
Yahoo i said i did not want to take the credits.. and i also apologised for that...
so noo need to take this matter more further !!!

Agreed. Are we going to stop this, or must I wipe all irrelevant posts from here?
Everything could have been anything else and it would have just as much meaning.

Offline Yahoo

  • Triple Ace
  • **
  • Posts: 225
  • Karma: +32/-14
  • People Say "I Dont Know English"
    • Yahoo
Re: Server Board : HELP NEEDED
« Reply #10 on: 19 July, 2010, 19:40:34 »
i will also love to have this script
"BoRN FIGhTEr"

Offline Yahoo

  • Triple Ace
  • **
  • Posts: 225
  • Karma: +32/-14
  • People Say "I Dont Know English"
    • Yahoo
Re: Server Board : HELP NEEDED
« Reply #11 on: 20 July, 2010, 06:46:05 »
oops, wrong post  ???
"BoRN FIGhTEr"

PtokaX forum

Re: Server Board : HELP NEEDED
« Reply #11 on: 20 July, 2010, 06:46:05 »