• 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!

Vip system

ScorpiOOn93

etherno.net
Joined
Jun 19, 2008
Messages
662
Reaction score
1
Location
CookieLand :DDD
http://otland.net/f163/mock-vip-system-vip-account-51512/
Can someone fix bug in this vip system ? Because in this system accounts with account name (for example name=hehe) don't get the vip (error in console) but it's working for accounts with normal acc name (for example name=7485745), yeah I know that I need to change the function but I can't find the good one :p
 
Last edited:
Code:
vip = {
	name = "Vip system",
	author = "Mock",
	version = "1.0.0.0",
	query="ALTER TABLE `accounts` ADD `vip_time` INT( 15 ) NOT NULL"
}

function vip.setTable()
	db.executeQuery(vip.query)
end

function vip.getVip(cid)
	assert(tonumber(cid),'Parameter must be a number')
	if not isPlayer(cid) then error('Player not found') end
	local ae = db.getResult("SELECT `vip_time` FROM `accounts` WHERE `name` = '"..getPlayerAccount(cid).."';")
	return ae:getID() ~= -1 and ae:getDataInt("vip_time") or 0
end

function vip.getVipByAcc(acc)
	assert(acc,'Account is nil')
	local a = db.getResult("SELECT `vip_time` FROM `accounts` WHERE `name` = '"..acc.."';")
	return a:getID() == -1 and error('Account not found') or (a:getDataInt("vip_time") or 0)
end

function vip.setVip(cid,time)
	assert(tonumber(cid),'Parameter must be a number')
	assert(tonumber(time),'Parameter must be a number')
	if not isPlayer(cid) then error('Player not found') end
	db.executeQuery("UPDATE `accounts` SET `vip_time` = "..(os.time()+time).." WHERE `name` = '".. getPlayerAccount(cid).."' LIMIT 1;")
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 error('Player don\'t find') end
	return os.time(day) < (vip.getVip(cid) or 0)
end

function vip.accountHasVip(acc)
	assert(acc,'Account is nil')
	return os.time() < vip.getVipByAccount(acc)
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')
	return vip.setVipByAccount(acc, math.max(0, os.difftime(vip.getVipByAcc(acc), os.time())) + time)
end

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

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