This is a script that you can do it.
And when some players say !quote they will se all this shames
Well it works on MYSQL! if you want it run on sqlite you have to create the row by yourself.
If you use mysql just say it once:
!addquote sql and it run the query.
To add a quote:
!addquote 22:55 Zarox: i am fag
To delete a quote:
!addquote delete ID
To see quote list/id
!quote
To see a quote
!quote ID
Well ad this 2 tags on talkactions.xml:
Now on quote.lua add it:
And enjoy
Code:
22:55 Mock: hi
22:55 Zarox: i am fag
22:55 Mock: QUOTED MWHAHAHAHA!!!
Well it works on MYSQL! if you want it run on sqlite you have to create the row by yourself.
If you use mysql just say it once:
!addquote sql and it run the query.
To add a quote:
!addquote 22:55 Zarox: i am fag
To delete a quote:
!addquote delete ID
To see quote list/id
!quote
To see a quote
!quote ID
Well ad this 2 tags on talkactions.xml:
Code:
<talkaction words="!quote" event="script" value="quote.lua"/>
<talkaction log="yes" words="!addquote" access="2" event="script" value="quote.lua"/>
Now on quote.lua add it:
Lua:
--Quote system by mock the bear (MTB)
function getQuoteN()
local result = db.getResult("SELECT * FROM quote ORDER BY `time` DESC")
local n = 0
repeat
n = n+1
until not result:next()
result:free()
return n
end --- Script By mock!
function checkQuote(n)
local result = db.getResult("SELECT * FROM quote WHERE `id`="..n)
if(result:getID() ~= -1) then
result:free()
return true
else
return false
end
end
function onSay(cid, words, param, channel) --Quote system by mock the bear (MTB)
if words == '!quote' and not tonumber(param) then
local result = db.getResult("SELECT * FROM quote")
local s = 'Quote list\n--------------\n'
if(result:getID() ~= -1) then
repeat
s = s..'['..result:getDataInt("id")..'] - By: '..result:getDataString("player")..' at '..os.date("%d %B %Y %X ", result:getDataInt("time"))..'\n'
until not result:next()
result:free()
end
doShowTextDialog(cid,1953,s..'\n--------------\nSay !quote 1 to see the first quote.')
elseif tonumber(param) then
local result = db.getResult("SELECT * FROM quote WHERE `id`="..tonumber(param))
if(result:getID() ~= -1) then
doShowTextDialog(cid,1953,'Quote id '..tonumber(param)..'\nBY: '..result:getDataString("player")..'\nAt:'..os.date("%d %B %Y %X ", result:getDataInt("time"))..'\n-----------\n'..result:getDataString("quoted"))
else
doPlayerSendTextMessage(cid,25,'Ivalid quote id. Please see the list!')
end
elseif param ~= '' and words == '!addquote' then
if param == 'sql' then
db.executeQuery([[CREATE TABLE `quote` (
`id` INT NOT NULL AUTO_INCREMENT ,
`player` VARCHAR( 50 ) NOT NULL ,
`time` INT( 20 ) NOT NULL ,
`quoted` TEXT NOT NULL ,
PRIMARY KEY ( `id` ) ,
INDEX ( `id` )
) ENGINE = MYISAM ;]])
elseif param:match('delete%s*(%d+)') then
local n = param:match('delete%s*(%d+)')
if checkQuote(n) then
db.executeQuery([[DELETE FROM `quote` WHERE `quote`.`id` = ]]..n)
if checkQuote(n) then
doPlayerSendTextMessage(cid,25,'Cannot delete this quote.')
else
doPlayerSendTextMessage(cid,25,'Quote deleted.')
end
else
doPlayerSendTextMessage(cid,25,'Invalid quote id.')
end
else
db.executeQuery(string.format([[INSERT INTO `quote` (
`id` ,
`player` ,
`time` ,
`quoted`
)
VALUES (
NULL , '%s', '%d', '%s'
);]],getCreatureName(cid),os.time(),param))
doPlayerSendTextMessage(cid,25,'Quote add nº'..getQuoteN()..'!')
doSendMagicEffect(getCreaturePosition(cid),30)
end
end
return true
end