Nostradamus
Member
- Joined
- Jun 2, 2007
- Messages
- 219
- Reaction score
- 6
Content removed, i don't want to share my knowleagement with a retarded forum staff. Feel free to contact me if you still want that.
Last edited:
--[[
Offline Messages Alpha 0.1
Nostradamus
Messages DB
playerid
writer
text
read (boolean) [ 1 = read | 0 = new]
TODO
Add an anti-spam thing
DETAIL
Not tested
PURPOSE
Demonstrate a cool way of making talkactions
]]--
Message = inheritsFrom(Talkhandler)
Message:setAttributes({
env = nil,
conn = nil
})
Message:registerWordEvent('!show', Message.showMsg) -- !show
Message:registerWordEvent('!send!', Message.sendMsg) -- !send"<player>, <msg>
function Message:onSay(cid, words, param)
self:callWordEvent(words, cid, param)
return false -- Needed so server wont send messages to client
end
function Message:showMsg(cid, param)
local pid = getPlayerGUID(cid)
local env, con = self:getConnection()
local cur = assert(con:execute('SELECT * FROM `messages` WHERE `playerid` = ' .. Database:quote(pid) .. ' AND `read` = '1';')
if (cur:numrows() > 0) then
local row = cur:fetch({}, "a")
while (row) do
doPlayerSendTextMessage(cid, TALKTYPE_PRIVATE, row.writer .. ": " .. row.text)
row = cur:fetch({},"a")
assert(con:execute('DELETE FROM `messages` WHERE `playerid` = ' .. Database:quote(pid) .. ';'))
end
return true
end
conn:close()
env:close()
return false
end
function Message:sendMsg(cid, param)
local separator = string.explode(param, ",")
local targetId = getPlayerGUIDByName(separator[1])
if not (isPlayer(targetId) == TRUE) then
warnPlayer('Can only send messages to offline and exiting players.')
else
local env, con = Database:getConnection()
local writerName = getPlayerName(cid)
if (separator[2] ~= '' and Database:isPlayer(targetId) == false) then
sql:execute('INSERT INTO `messages` (`playerid`, `writer`, `text`, `read`) VALUES (' .. targetId .. ', ' .. writerName .. ', ' .. separator[2] .. ', '0')')
doPlayerSendCancel(cid, 'Message successfuly sent to ' .. separator[1] .. '.')
return true
end
return false
end
en
function onSay(...)
return OwnLootBag:new():onSay(...)
end
--[[
Offline Messages Alpha 0.1
Nostradamus
Messages DB
playerid
writer
text
read (boolean) [ 1 = read | 0 = new]
TODO
Add an anti-spam thing
DETAIL
Not tested
PURPOSE
Demonstrate a cool way of making talkactions
]]--
Message = inheritsFrom(Talkhandler)
Message:setAttributes({
env = nil,
conn = nil
})
Message:registerWordEvent('!show', Message.showMsg) -- !show
Message:registerWordEvent('!send!', Message.sendMsg) -- !send"<player>, <msg>
function Message:onSay(cid, words, param)
self:callWordEvent(words, cid, param)
return false -- Needed so server wont send messages to client
end
function Message:showMsg(cid, param)
local pid = getPlayerGUID(cid)
local env, con = self:getConnection()
local cur = assert(con:execute('SELECT * FROM `messages` WHERE `playerid` = ' .. Database:quote(pid) .. ' AND `read` = '1';')
if (cur:numrows() > 0) then
local row = cur:fetch({}, "a")
while (row) do
doPlayerSendTextMessage(cid, TALKTYPE_PRIVATE, row.writer .. ": " .. row.text)
row = cur:fetch({},"a")
assert(con:execute('DELETE FROM `messages` WHERE `playerid` = ' .. Database:quote(pid) .. ';'))
end
return true
end
conn:close()
env:close()
return false
end
function Message:sendMsg(cid, param)
local separator = string.explode(param, ",")
local targetId = getPlayerGUIDByName(separator[1])
if not (isPlayer(targetId) == TRUE) then
warnPlayer('Can only send messages to offline and exiting players.')
else
local env, con = Database:getConnection()
local writerName = getPlayerName(cid)
if (separator[2] ~= '' and Database:isPlayer(targetId) == false) then
sql:execute('INSERT INTO `messages` (`playerid`, `writer`, `text`, `read`) VALUES (' .. targetId .. ', ' .. writerName .. ', ' .. separator[2] .. ', '0')')
doPlayerSendCancel(cid, 'Message successfuly sent to ' .. separator[1] .. '.')
return true
end
return false
end
end
<talkaction words="!send" script="offline msg.lua" />
function onSay(...)
return OwnLootBag:new():onSay(...)
end
The Forgotten Server - Version 0.2rc10 (Mystic Spirit).
A server developed by Talaturen, Kiper, Kornholijo, Jonern, Lithium & slawkens.
Visit our forum for updates, support and resources: http://otland.net/.
>> Loading config
>> Loading RSA key
>> Testing SQL connection... SqLite.
>> Loading bans
>> Loading vocations
>> Loading commands
>> Loading items
>> Loading script systems
Warning: [Event::loadScript] Can not load script. data/talkactions/scripts/offli
ne msg.lua
data/talkactions/scripts/offline msg.lua:40: ')' expected near '1'
>> Loading monsters
>> Loading quests
>> Loading outfits
>> Loading admin protocol config
>> Loading experience stages
>> Checking world type... PVP
>> Loading map
> Map size: 1024x1024.
> Map loading time: 4.244 seconds.
>> Loading raids
>> All modules has been loaded, server starting up...
>> Mystic Ot Server Online!