• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua vip time remove

di12345di

New Member
Joined
Aug 1, 2012
Messages
105
Reaction score
0
my vip that ends are not removing storage or the VIP team, plus the player can not enter the area vip and Gesior continues vip status even without.

action/scripts
Code:
local days = 1

function onUse(cid, item, itemEx)
        local name = getCreatureName(cid)
                vip.addVipByAccount(getPlayerAccount(getPlayerByName(name)) ,vip.getDays(days))
                doCreatureSay(cid,"You received "..days.." days of VIP.", TALKTYPE_ORANGE_1)
                doRemoveItem(item.uid, 1)
           return TRUE
end

lib
Code:
vip = {
name = "VIP System";
author = "Mock";
version = "1.0.0.0";
query="ALTER TABLE `accounts` ADD `vip_time` INTEGER";
query2="ALTER TABLE `accounts` ADD `vip_time` INT(15) NOT NULL"
}

function vip.setTable()
dofile('config.lua')
if sqlType == "sqlite" then
db.executeQuery(vip.query)
else
db.executeQuery(vip.query2)
end
end

function vip.getVip(cid)
assert(tonumber(cid),'Parameter must be a number')
if isPlayer(cid) == FALSE then error('Player don\'t find') end;
ae = db.getResult("SELECT `vip_time` FROM `accounts` WHERE `name` = '"..getPlayerAccount(cid).."';")
if ae:getID() == -1 then
return 0
end

local retee = ae:getDataInt("vip_time") or 0
ae:free()
return retee
end

function vip.getVipByAcc(acc)
assert(acc,'Account is nil')
local a = db.getResult("SELECT `vip_time` FROM `accounts` WHERE `name` = '"..acc.."';")
if a:getID() ~= -1 then
return a:getDataInt("vip_time") or 0, a:free()
else
error('Account don\'t find.')
end
end

function vip.setVip(cid,time)
dofile("config.lua")
assert(tonumber(cid),'Parameter must be a number')
assert(tonumber(time),'Parameter must be a number')
if isPlayer(cid) == FALSE then error('Player don\'t find') end;
db.executeQuery("UPDATE `"..sqlDatabase.."`.`accounts` SET `vip_time` = '"..(os.time()+time).."' WHERE `accounts`.`name` ='".. getPlayerAccount(cid).."';")
end

function vip.getVipByAccount(acc)
assert(acc,'Account is nil')
return db.getResult("SELECT `vip_time` FROM `accounts` WHERE `name` = '"..acc.."';"):getDataInt("vip_time") or 0
end

function vip.hasVip(cid)
assert(tonumber(cid),'Parameter must be a number')
if isPlayer(cid) == FALSE then return end;
local t = vip.getVip(cid) or 0
if os.time(day) < t then
return TRUE
else
return FALSE
end
end

function vip.hasVips(cid)
assert(tonumber(cid),'Parameter must be a number')
if isPlayer(cid) == FALSE then return end;
local t = vip.getVip(cid)
if os.time(day) < t then
return TRUE
else
return FALSE
end
end

function vip.accountHasVip(acc)
assert(acc,'Account is nil')
if os.time() < vip.getVipByAccount(acc) then
return TRUE
else
return FALSE
end
end
function vip.getDays(days)
return (3600 * 24 * days)
end

function vip.addVipByAccount(acc,time)
assert(acc,'Account is nil')
assert(tonumber(time),'Parameter must be a number')
local a = vip.getVipByAcc(acc)
a = os.difftime(a,os.time())
if a < 0 then a = 0 end;
a = a+time
return vip.setVipByAccount(acc,a)
end

function vip.setVipByAccount(acc,time)
dofile("config.lua")
assert(acc,'Account is nil')
assert(tonumber(time),'Parameter must be a number')
db.executeQuery("UPDATE `accounts` SET `vip_time` = '"..(os.time()+time).."' WHERE `accounts`.`name` ='"..acc.."';")
return TRUE
end

function vip.returnVipString(cid)
assert(tonumber(cid),'Parameter must be a number')
if isPlayer(cid) == TRUE then
return os.date("%d %B %Y %X ", vip.getVip(cid))
end
end


creaturescripts/script
Code:
function onLogin(cid)
local temple = { x =160, y = 54, z = 7}
if vip.hasVip(cid) == true then
if getPlayerStorageValue(cid,23510) ~= 1 then
setPlayerStorageValue(cid,23510,1)
end
else
if getPlayerStorageValue(cid,23510) == 1 then
doTeleportThing(cid, temple)
doPlayerSendTextMessage(cid, 22, "Sua Vip Acabou!")
db.executeQuery("UPDATE `accounts` SET `vip_time` = 0 WHERE `id` = ".. getAccountIdByName(getPlayerName(cid)) ..";")
setPlayerStorageValue(cid, 23510, 0)
end
end
return true
end

and
login.lua
registerCreatureEvent(cid, "FimVip")
 
I know this but my vip already're all set up the only poblem is at the end vip, not goes to the temple and do not remove the VIP time.
 
I know this but my vip already're all set up the only poblem is at the end vip, not goes to the temple and do not remove the VIP time.
What is the storagevalue supposed to do? Because that's the part that is stopping the player from getting teleported to temple if logging in without vip (if removed or whatever)
 
tokenzz
What is the storagevalue supposed to do? Because that's the part that is stopping the player from getting teleported to temple if logging in without vip (if removed or whatever)

Code:
function onLogin(cid)
local temple = { x =160, y = 54, z = 7}
if vip.hasVip(cid) == true then
if getPlayerStorageValue(cid,23510) ~= 1 then
setPlayerStorageValue(cid,23510,1)
end
else
if getPlayerStorageValue(cid,23510) == 1 then
doTeleportThing(cid, temple)
doPlayerSendTextMessage(cid, 22, "Sua Vip Acabou!")
db.executeQuery("UPDATE `accounts` SET `vip_time` = 0 WHERE `id` = ".. getAccountIdByName(getPlayerName(cid)) ..";")
setPlayerStorageValue(cid, 23510, 0)
end
end
return true
end



http://prntscr.com/c1dxel

although the player does not have access to VIP area, the only error it gives is the Gesior and he is not teleported to the temple understand?

for some reason the vip team is not getting 0
 
Last edited:
Check out this man:

Code:
function onLogin(cid)
local temple = { x =160, y = 54, z = 7}
if vip.hasVip(cid) == true then
if getPlayerStorageValue(cid,23510) ~= 1 then
setPlayerStorageValue(cid,23510,1)
elseif getPlayerStorageValue(cid,23510) == 1 then
doTeleportThing(cid, temple)
doPlayerSendTextMessage(cid, 22, "Sua Vip Acabou!")
db.executeQuery("UPDATE `accounts` SET `vip_time` = 0 WHERE `id` = ".. getAccountIdByName(getPlayerName(cid)) ..";")
setPlayerStorageValue(cid, 23510, -1)
end
end
return true
end
 
Back
Top