Witajcie,
wypada od czasu do czasu coś wrzucić

. Tym razem jest to frag remover, napisany pod najnowszego na tą chwilę (najnowszego dostępnego publicznie) The Forgotten Servera 0.3.6pl1.
Skrypt nie testowałem, ale jest na tyle banalny, że nie powinno być błędów.
Kod:
function onSay(cid, words, param, channel)
local data = {
points = 20,
skull = getCreatureSkullType(cid),
removeFrags = "true",
useLog = "false"
}
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))
if(hasCondition(cid, CONDITION_EXHAUST_HEAL)) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
return true
end
if(data.skull == SKULL_RED or data.skull == SKULL_BLACK) then
local query = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
local playerPremiumPoints = query:getDataInt("premium_points")
local remainingPoints = playerPremiumPoints - data.points
if(playerPremiumPoints >= data.points) then
local updateDatabase = db.executeQuery("UPDATE `accounts` SET `premium_points`= " .. remainingPoints .. " WHERE `id`= " .. getPlayerAccountId(cid) .. ";")
if(updateDatabase == true) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Your skull has been taken off!\nRemaining premium points: " .. remainingPoints)
doCreatureSetSkullType(cid, SKULL_NONE)
if(getBooleanFromString(data.useLog) == true) then
doWriteLogFile("./data/logs/removeskull.log", "Success: " .. getCreatureName(cid))
end
if(getBooleanFromString(data.removeFrags) == true) then
doPlayerSetRedSkullTicks(cid, 0)
end
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_BLUE)
else
doPlayerSendCancel(cid, "Database error, please contact server staff.")
end
else
doPlayerSendCancel(cid, "Sorry, you need " .. data.points .. " premium points to remove skull.")
end
else
doPlayerSendCancel(cid, "Sorry, you don't have skull.")
end
if(query ~= nil) then
query:free()
end
doAddCondition(cid, exhaust)
return true
end
Jeszcze chciałbym zaznaczyć, iż użyłem funkcji, które raczej nie występują w innych silnikach. Również mysql query pasuje do struktury bazy nowego TFSa.
Regards,
Hermes