curruwilliam
Hello =]
- Joined
- Apr 22, 2014
- Messages
- 124
- Reaction score
- 2
Hello,
I have a code here, but not updated with the latest update of forgottenserver.
Someone could upgrade to min?
I do not know Mecher with .lua = '[
It is a system of vip
global.lua
actions/scripts/vip.lua
creaturescripts/scripts/vip.lua
movements/scripts/vip.lua
creaturescripts/scripts/extraexp.lua
Someone update me?
With last base in the last TFS: http://nightlies.otland.net/
thanks thanks
I have a code here, but not updated with the latest update of forgottenserver.
Someone could upgrade to min?
I do not know Mecher with .lua = '[
It is a system of vip
global.lua
Code:
-- Vip system lib
function getPlayerAccount(cid)
return getAccountNumberByPlayerName(getPlayerName(cid))
end
function setVipTable()
db.query("ALTER TABLE `accounts` ADD `vip_time` INT( 15 ) NOT NULL;")
end
function getPlayerVip(cid)
local resultId = db.storeQuery("SELECT `id`, `vip_time` FROM `accounts` WHERE `id` = '".. getPlayerAccount(cid) .."';")
if resultId ~= false then
return result.getDataInt(resultId, "vip_time")
else
error('Account not found.')
end
end
function getVipByAcc(acc)
local a = db.storeQuery("SELECT `vip_time` FROM `accounts` WHERE `id` = '"..acc.."';")
if a ~= false then
return result.getDataInt(a, "vip_time")
else
error('Account not found.')
end
end
function setPlayerVip(cid,secs) -- seconds
if isPlayer(cid) then
db.query("UPDATE `accounts` SET `vip_time` = '"..(os.time()+secs).."' WHERE `id` ='".. getPlayerAccount(cid) .."' LIMIT 1 ;")
else
error('Player not found.')
end
end
getVipByAccount = getVipByAcc
function hasVip(cid)
if isPlayer(cid) then
if os.time(day) < getPlayerVip(cid) then
return true
else
return false
end
else
error('Player not found.')
end
end
function accountHasVip(acc)
if os.time() < getVipByAccount(acc) then
return true
else
return false
end
end
function setVipByAccount(acc,secs) -- seconds
local a = getVipByAcc(acc)
if a ~= false then
if tonumber(secs) ~= nil then
db.query("UPDATE `accounts` SET `vip_time` = '"..(os.time()+secs).."' WHERE `id` ='"..acc.."' LIMIT 1 ;")
return true
else
error('Time must be defined as number.')
end
else
error('Account not found.')
end
return false
end
function getPlayerVipTime(cid)
if getPlayerVip(cid)-os.time() > 0 then
return getPlayerVip(cid)-os.time()
else
return 0
end
end
function getAccountVipTime(acc)
if getVipByAcc(acc)-os.time() > 0 then
return getVipByAcc(acc)-os.time()
else
return 0
end
end
function addVipByAccount(acc,secs) -- seconds
local a = getVipByAcc(acc)
if a ~= false then
if tonumber(secs) ~= nil then
db.query("UPDATE `accounts` SET `vip_time` = '"..os.time()+(getAccountVipTime(acc)+secs).."' WHERE `id` ='"..acc.."' LIMIT 1 ;")
return true
else
error('Time must be defined as number.')
end
else
error('Account not found.')
end
return false
end
function doPlayerAddVip(cid,secs) -- seconds
local a = getPlayerVip(cid)
if a ~= false then
if tonumber(secs) ~= nil then
return setPlayerVip(cid,(getPlayerVipTime(cid) + secs))
else
error('Time must be defined as number.')
end
else
error('Player not found.')
end
end
function returnVipString(cid)
if isPlayer(cid) == true then
return os.date("%d %B %Y %X", getPlayerVip(cid))
else
error('Player not found.')
end
end
function returnVipCountdown(num)
local d = (tonumber(string.format("%.0f", os.date("%j",num))) - 1)
local h = (tonumber(string.format("%.0f", os.date("%H",num))) - 1)
local m = (tonumber(string.format("%.0f", os.date("%M",num))))
local s = (tonumber(string.format("%.0f", os.date("%S",num))))
local tvar, tnames, text = {d, h, m, s}, {"day", "hour", "minute", "second"}, ""
local nvar, nnames = {}, {}
for i = 1, #tvar do
local s = ""
table.insert(nvar, tvar)
if tvar > 1 then s = "s" end
table.insert(nnames, tnames..s)
if i == 1 then
if tvar > 0 then text = text..nvar.." "..nnames else text = text end
else
if tvar > 0 then
if text == "" then
text = nvar.." "..nnames
else
if tvar[i+1] ~= nil and tvar[i+1] > 0 then
text = text..", "..nvar.." "..nnames
else
text = text.." and "..nvar.." "..nnames
end
end
else
text = text
end
end
end
if text == "" then
return "no more vip time"
else
return text.." of vip time"
end
end
-- end of vip system lib
actions/scripts/vip.lua
Code:
function onUse(cid, item)
if hasVip(cid) == false then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"Agora voce e um player VIP.")
doPlayerAddVip(cid, 2592000) -- 30 dias tempo em segudos.
doRemoveItem(item.uid, 1)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"Voce ja e VIP so poderá renovar daqui 30 dias.")
end
return TRUE
end
creaturescripts/scripts/vip.lua
Code:
function onLogin(cid)
local player = Player(cid)
if hasVip(cid) == true then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Você tem 50% de exp a mais agora!")
else
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Tornesse vip e ganhe 50% a mais de experiencia!")
end
return true
end
movements/scripts/vip.lua
Code:
function onStepIn(cid, item, position, fromPosition)
local config = {
msgDenied = "Você não e vip ,Compre =D.",
msgWelcome = "Seja Bem Vindo a Area vip."
}
if hasVip(cid) == false then
doTeleportThing(cid, fromPosition, true)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, config.msgDenied)
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
return TRUE
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, config.msgWelcome)
return TRUE
end
creaturescripts/scripts/extraexp.lua
Code:
local rate = 50 --- porcentagem que irá ganhar a mais.
function onKill(cid, target, lastHit)
if hasVip(cid) == true then
local monster = Monster(target)
if not monster then
return true
end
for id, damage in pairs(monster:getDamageMap()) do
local player = Player(id)
if player then
local experience = damage.total / monster:getType():getHealth() * monster:getType():getExperience()
local expFormula = (((experience * Game.getExperienceStage(player:getLevel())) / 100) * rate)
player:addExperience(math.floor(expFormula), true)
end
end
end
return true
end
Someone update me?
With last base in the last TFS: http://nightlies.otland.net/
thanks thanks