• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua VIP System TFS 1.0

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
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
 
Use the compat.lua file to find out the new names etc.
Altho:
if hasVip(cid) == false then = if not hasVip(cid) then
if hasVip(cid) == true then = if hasVip(cid) then

There is no reason to use the == false when you have the "not" statment and in programming its always said to be true unless you write something else, so the == true is also not needed.
 
Use the compat.lua file to find out the new names etc.
Altho:
if hasVip(cid) == false then = if not hasVip(cid) then
if hasVip(cid) == true then = if hasVip(cid) then

There is no reason to use the == false when you have the "not" statment and in programming its always said to be true unless you write something else, so the == true is also not needed.

Sorry, but I have not the slightest notion in .lua
 
Sorry, but I have not the slightest notion in .lua

You open compat.lua and serach for ex. doPlayerAddItem(cid, itemid, count) you will then notice that that function is Player(cid):addItem(itemid, count). Then you write:
Code:
local player = Player(cid)
if(not player) then
    return true
end

player:addItem(itemid, count)
 
You open compat.lua and serach for ex. doPlayerAddItem(cid, itemid, count) you will then notice that that function is Player(cid):addItem(itemid, count). Then you write:
Code:
local player = Player(cid)
if(not player) then
    return true
end

player:addItem(itemid, count)
I'll try
 
Just got this:
actions:
Code:
function onUse(cid, item)
local player = Player(cid)
if hasVip(cid) == false then
player:sendTextMessage(MESSAGE_INFO_DESCR,"Agora voce e um player VIP.")
doPlayerAddVip(cid, 2592000) -- 30 dias tempo em segudos.
doRemoveItem(item.uid, 1)
else
player:sendTextMessage(MESSAGE_INFO_DESCR,"Voce ja e VIP so poderá renovar daqui 30 dias.")
end
return TRUE
end

and
creaturescript:
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
 
This give extra exp is not working.

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
 
This give extra exp is not working.

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
What is wrong? We can't help you if don't say the error
Use this script:
Code:
local rate = 1.5 -- 50%
local config = {
vip = "You receive "..((rate - 1)*100).."% more experience now!",
notvip = "Get a Account VIP and get "..((rate - 1)*100).."% more experience, unique features, maps, monster, houses, quests!",
}

if not hasVip(cid) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, config.notvip)
else
doPlayerSetExperienceRate(cid, rate)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, config.vip)
end
return TRUE
end

Ah sorry its for tfs 1.0 idk the new, but i think is:
Player:SendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, config.notvip)

Player:SetExperienceRate(cid, rate)
Player:SendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, config.vip)
 
Last edited:
Code:
function Player:onGainExperience(source, exp, rawExp)
    if hasVip(self:getId()) then
        exp = exp * 1.5
    end

    return exp
end
 
Thank you guys worked everything right

Now to finish:
Code:
function onLogin(cid)
local temple = { x =32369, y = 32246, z = 6}
if vip.hasVip(cid) == true then
if getPlayerStorageValue(cid,55555) ~= 1 then
setPlayerStorageValue(cid,55555,1)
end
else
if getPlayerStorageValue(cid,55555) == 1 then
doTeleportThing(cid, temple)
doPlayerSendTextMessage(cid, 22, "Your VIP Time over!")
db.executeQuery("UPDATE `accounts` SET `vip_time` = 0 WHERE `id` = ".. getAccountIdByName(getPlayerName(cid)) ..";")
setPlayerStorageValue(cid, 55555, 0)
end
end
return true
end

I'm too complex for me to update =D
 
Thank you guys worked everything right

Now to finish:
Code:
function onLogin(cid)
local temple = { x =32369, y = 32246, z = 6}
if vip.hasVip(cid) == true then
if getPlayerStorageValue(cid,55555) ~= 1 then
setPlayerStorageValue(cid,55555,1)
end
else
if getPlayerStorageValue(cid,55555) == 1 then
doTeleportThing(cid, temple)
doPlayerSendTextMessage(cid, 22, "Your VIP Time over!")
db.executeQuery("UPDATE `accounts` SET `vip_time` = 0 WHERE `id` = ".. getAccountIdByName(getPlayerName(cid)) ..";")
setPlayerStorageValue(cid, 55555, 0)
end
end
return true
end

I'm too complex for me to update =D

Code:
function onLogin(cid)
local temple = { x =32369, y = 32246, z = 6}
if hasVip(cid)then
if getPlayerStorageValue(cid,55555) ~= 1 then
setPlayerStorageValue(cid,55555,1)
end
else
if getPlayerStorageValue(cid,55555) == 1 then
doTeleportThing(cid, temple, TRUE)
doPlayerSendTextMessage(cid, 22, "Your VIP Time over!")
db.executeQuery("UPDATE `accounts` SET `vip_time` = 0 WHERE `id` = ".. getAccountIdByName(getPlayerName(cid)) ..";")
setPlayerStorageValue(cid, 55555, 0)
end
end
return true
end

also creaturescripts xml add it:
Code:
  <event type="login" name="checkvip" script="vipend.lua"/>
 
Last edited:
Back
Top