The PtokaX Portal
News: READ THE RULES
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
September 07, 2010, 11:13:34 PM


Login with username, password and session length


Pages: [1]   Go Down
  Print  
Author Topic: Server Board : HELP NEEDED  (Read 774 times)
0 Members and 1 Guest are viewing this topic.
patrick
Junior Member
**

Karma: +0/-11
Offline Offline

Posts: 14


View Profile
« on: January 04, 2009, 04:22:58 PM »

Code:
--Server Board 1.03 10/20/04 LUA 5
--converted to LUA 5 - 09/15/05
--by Mutor
--
-- 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: January 05, 2009, 07:26:57 AM by patrick » Logged
†StIfFLEr†™
Lord
***

Karma: +15/-62
Offline Offline

Posts: 272



View Profile
« Reply #1 on: January 04, 2009, 06:13:27 PM »

I am eagerly waiting for mutor to give you a very nice reply  Tongue
Hope you understand how the forum works soon.
Type or paste your code inside the [ code ]   [ /code ] option please.
Logged
†StIfFLEr†™
Lord
***

Karma: +15/-62
Offline Offline

Posts: 272



View Profile
« Reply #2 on: January 04, 2009, 06:17:10 PM »

Quote
--Server Board 1.03   10/20/04 LUA 5
--converted to LUA 5 - 09/15/05
--by Patrick
LOL
its mutors script u noob patrick dont asct as if you can do anything i am sure one more "-" will be comming by mutor
What say mutor 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 mutor gives me the permission.)
Logged
patrick
Junior Member
**

Karma: +0/-11
Offline Offline

Posts: 14


View Profile
« Reply #3 on: January 04, 2009, 06:31:26 PM »

Sorry Mutor 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  Cry
DID NOT REALLY WANTED TO TAKE YOUR CREDIT

So The Script Goes Like Below
Logged
patrick
Junior Member
**

Karma: +0/-11
Offline Offline

Posts: 14


View Profile
« Reply #4 on: January 04, 2009, 06:33:29 PM »

SORRY Mutor IF U MISUDERSTOOD ME

* servers.lua (6.35 KB - downloaded 23 times.)
Logged
bastya_elvtars
Administrator
Forum God
*****

Karma: +172/-7
Offline Offline

Posts: 3 748


The rock n' roll doctor


View Profile WWW
« Reply #5 on: January 04, 2009, 07:23:34 PM »

If you really want Mutor to forgive, please attach the file to the fist post by editing and remove that huge code snippet. Smiley
Logged

My work is quick, reliable and cheap. You can choose 2 of these options. Smiley
The LawMaker & FreshStuff Site
The LawMaker & FreshStuff Forum
The PtokaX Wiki
†StIfFLEr†™
Lord
***

Karma: +15/-62
Offline Offline

Posts: 272



View Profile
« Reply #6 on: January 04, 2009, 08:13:33 PM »

But i am still waiting for mutors reply.
Eagarly waiting for his dictionary to be open.  Tongue
I hope this time i will be learning some more new words from him.
Please mutor 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.  Tongue
Logged
Yahoo
Lord
***

Karma: +32/-14
Offline Offline

Posts: 265


People Say "I Dont Know English"


View Profile WWW
« Reply #7 on: January 10, 2009, 08:41:19 PM »

forgive me guys
but please remove this noob from the forum
he is taking credit for mutors scripts
we dont want such cheaters and liers on this board
Logged

"BoRN FIGhTEr"
patrick
Junior Member
**

Karma: +0/-11
Offline Offline

Posts: 14


View Profile
« Reply #8 on: January 11, 2009, 08:30:52 AM »

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 !!!
Logged
bastya_elvtars
Administrator
Forum God
*****

Karma: +172/-7
Offline Offline

Posts: 3 748


The rock n' roll doctor


View Profile WWW
« Reply #9 on: January 11, 2009, 12:49:07 PM »

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?
Logged

My work is quick, reliable and cheap. You can choose 2 of these options. Smiley
The LawMaker & FreshStuff Site
The LawMaker & FreshStuff Forum
The PtokaX Wiki
Yahoo
Lord
***

Karma: +32/-14
Offline Offline

Posts: 265


People Say "I Dont Know English"


View Profile WWW
« Reply #10 on: July 19, 2010, 07:40:34 PM »

i will also love to have this script
Logged

"BoRN FIGhTEr"
Mutor
Global Moderator
Forum God
*****

Karma: +372/-18
Offline Offline

Posts: 3 631


To err is human, to arr is pirate...


View Profile WWW
« Reply #11 on: July 19, 2010, 11:26:43 PM »

This is old, Message Board is newer and is already available for API2
Logged

Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg
Yahoo
Lord
***

Karma: +32/-14
Offline Offline

Posts: 265


People Say "I Dont Know English"


View Profile WWW
« Reply #12 on: July 20, 2010, 06:46:05 AM »

oops, wrong post  Huh
Logged

"BoRN FIGhTEr"
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC
TinyPortal v0.9.8 © Bloc


Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 3.122 seconds with 37 queries.