Tutorial baseado em SQL!
Bem, eu tenho aqui para apresentar dois scripts. Um é para você ver a lista de mortes de alguem, por exemplo:
Você quer saber para quem seu amigo morreu, você fala: !deathlist "nome. Ai aparece uma telinha que mostra as mortes, quando e em que level. Ai vai o script:
function onSay(cid, words, param)dofile("./config.lua")
if sqlType == "mysql" then
env = assert(luasql.mysql())
con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
else -- sqlite
env = assert(luasql.sqlite3())
con = assert(env:connect(sqliteDatabase))
end
local cur = assert(con:execute("SELECT `name`, `id` FROM `players` WHERE `name` = '" .. escapeString(param) .. "';"))
local row = cur:fetch({}, "a")
cur:close()
if row ~= nil then
local targetName = row.name
local targetGUID = row.id
local str = ""
local breakline = ""
for time, level, killed_by, is_player in rows(con, "SELECT `time`, `level`, `killed_by`, `is_player` FROM `player_deaths` WHERE `player_id` = " .. targetGUID .. " ORDER BY `time` DESC;") do
if str ~= "" then
breakline = "\n"
end
local date = os.date("*t", time)
local article = ""
if tonumber(is_player) ~= TRUE then
killed_by = string.lower(killed_by)
article = getArticle(killed_by) .. " "
end
if date.day < 10 then date.day = "0" .. date.day end
if date.hour < 10 then date.hour = "0" .. date.hour end
if date.min < 10 then date.min = "0" .. date.min end
if date.sec < 10 then date.sec = "0" .. date.sec end
str = str .. breakline .. " " .. date.day .. getMonthDayEnding(date.day) .. " " .. getMonthString(date.month) .. " " .. date.year .. " " .. date.hour .. ":" .. date.min .. ":" .. date.sec .. " Died at Level " .. level .. " by " .. article .. killed_by .. "."
end
if str == "" then
str = "No deaths."
end
doPlayerPopupFYI(cid, "Deathlist for player, " .. targetName .. ".\n\n" .. str)
else
doPlayerSendCancel(cid, "A player with that name does not exist.")
end
con:close()
env:close()
end
Eu só pesso que não editem, pois é muito complicado. Aconselho a usarem ele somente em server com SQL, pois só consegui testa-lo em servers com SQL!
Premium Account
Agora vai um que é para você comprar 90 dias de premium por 10k, somente falando uma coisa. Este segundo pode até funcionar em XML, você só precisa do comando "doPlayerAddPremiumDays" que vem no TFS.
function onSay(cid, words, param)if getPlayerPremiumDays(cid) <= 360 then
if doPlayerRemoveMoney(cid, 10000) == TRUE then
doPlayerAddPremiumDays(cid, 90)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought 90 days of premium account.")
else
doPlayerSendCancel(cid, "You don't have enough money, 90 days premium account costs 10000 gold coins.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
end
else
doPlayerSendCancel(cid, "You can not buy more than one year of Premium Account.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
end
end
Aí você coloca o máximo de dias.
Aí você edita o preço.
Onde tem as mensagens, é o que aparece quando:
1º- Quando compra a P.A.
2º- Quando o player não tem dinheiro.
3º-Quando alguem tenta comprar mais do que o tempo determinado no começo.
Mais um tutorial! Cyaaa!