potinho
Advanced OT User
Good morning people, everything fine?
I'm trying to create a creaturescript that validates the player's VIP time (onLogin), if the time has expired, it sends the player to the temple of TownID 1. Could you help me to create this script? Below are the functions to validate my VIP system.
Something like this:
Its not working.
I'm trying to create a creaturescript that validates the player's VIP time (onLogin), if the time has expired, it sends the player to the temple of TownID 1. Could you help me to create this script? Below are the functions to validate my VIP system.
Lua:
VIP_ACCOUNT_STORAGE = 30009
function getAccountStorage(cid, key)
local ret = db.getResult("SELECT `value` FROM `account_storage` WHERE `account_id` = ".. getPlayerAccountId(cid) .." AND `key` = "..key)
if ret:getID() == -1 then
return -1
end
return ret:getDataInt("value") or ret:getDataString("value")
end
function setAccountStorage(cid, key, value)
local func = db.executeQuery or db.query
local query = db.getResult("SELECT `value` FROM `account_storage` WHERE `key` = ".. key .." AND `account_id` = ".. getPlayerAccountId(cid))
if query:getID() == -1 then
return func("INSERT INTO `account_storage` (`account_id`, `key`, `value`) VALUES (".. getPlayerAccountId(cid) ..", ".. key ..", ".. value ..")")
end
return func("UPDATE `account_storage` SET `value` = ".. value .." WHERE `key` = ".. key .." AND `account_id` = ".. getPlayerAccountId(cid))
end
function isVIP(cid)
return getAccountVIP(cid) > 0
end
function getAccountVIP(cid)
return (getAccountStorage(cid, VIP_ACCOUNT_STORAGE) - os.time() > 0) and getAccountStorage(cid, VIP_ACCOUNT_STORAGE) - os.time() or 0
end
function setAccountVIP(cid, days)
return setAccountStorage(cid, VIP_ACCOUNT_STORAGE, os.time() + (60 * 60 * 24 * days) + (getAccountVIP(cid) > 0 and getAccountVIP(cid) or 0))
end
Something like this:
Lua:
function onLogin(cid)
if isVIP(cid) == false then
doTeleportThing(cid, TownID1)
return true
end
Its not working.
Last edited: