Athos:
Distro: TFS 0.3.1++++
Version: 1.0.0
By years i saw MANY vip systems, all systems has one fail, dont work better EVER have an erro on something, and some good vip systems of today its only for one player dont affect all account, Yes have another vip systems w ith account but here its mine (this its not the first and it's not the last its junts only an new one.). This is only an LIB not a sctipt like talk. So lets install it. Go to data/lib on your server, create vip sys.lua, go to data.lua and add it: dofile(getDataDir() .. "lib/vip sys.lua")
Now in vip sys.lua add it:
Now...
You need execute function vip.setTable() ONLY ONE TIME, or enter on your DB and execute this query: ALTER TABLE `accounts` ADD `vip_time` INT( 15 ) NOT NULL
Now you server has an great vip system, and you need only do scripts.
If you find some error please post here.
Sorry for the bad english ^^
Example:
Distro: TFS 0.3.1++++
Version: 1.0.0
By years i saw MANY vip systems, all systems has one fail, dont work better EVER have an erro on something, and some good vip systems of today its only for one player dont affect all account, Yes have another vip systems w ith account but here its mine (this its not the first and it's not the last its junts only an new one.). This is only an LIB not a sctipt like talk. So lets install it. Go to data/lib on your server, create vip sys.lua, go to data.lua and add it: dofile(getDataDir() .. "lib/vip sys.lua")
Now in vip sys.lua add it:
Lua:
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 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
return 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..";")
if a:getID() ~= -1 then
return a:getDataInt("vip_time") or 0
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).." 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;
local t = vip.getVip(cid) or 0
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 `"..sqlDatabase.."`.`accounts` SET `vip_time` = '"..(os.time()+time).."' WHERE `accounts`.`name` ="..acc.." LIMIT 1 ;")
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
You need execute function vip.setTable() ONLY ONE TIME, or enter on your DB and execute this query: ALTER TABLE `accounts` ADD `vip_time` INT( 15 ) NOT NULL
Now you server has an great vip system, and you need only do scripts.
If you find some error please post here.
Sorry for the bad english ^^
Example:
Lua:
function onSay(cid, words, param)
if param == "" then
return doPlayerPopupFYI(cid,"Are you confused?\n Lear the commands!\n---------------\nADD vip:\n/vip add days player\n/vip add 30 mock\n---------------\nDel vip:\n/vip del player\n/vip del mock\n---------------\ncheck vip:\n/vip see player\n/vip see mock\n---------------\n")
end
if param:lower():find('add') == 1 and 3 then
local ret = string.explode(param,' ',3)
if #ret < 3 or tonumber(ret[2]) == nil or getPlayerByName(ret[3]) == false then
return doPlayerSendTextMessage(cid,25,"Add vip:\n/vip add days player\n/vip add 30 mock\n")
end
vip.addVipByAccount( getPlayerAccount(getPlayerByName(ret[3])) ,vip.getDays(ret[2]))
doPlayerSendTextMessage(cid,25,"Has benn added "..tonumber(ret[2]).." days to "..ret[3]..".")
doPlayerSendTextMessage(getPlayerByName(ret[3]),25,"You recivied "..tonumber(ret[2]).." vip days!")
elseif param:lower():find('del') == 1 and 3 then
local ret = string.explode(param,' ',2)
if #ret < 2 or getPlayerByName(ret[2]) == false then
return doPlayerSendTextMessage(cid,25,"Del vip:\n/vip del player\n/vip del mock\n")
end
vip.setVipByAccount(getPlayerAccount(getPlayerByName(ret[2])),-os.time())
doPlayerSendTextMessage(cid,25,ret[2].."'s vip has been deleted.")
elseif param:lower():find('see') == 1 and 3 then
local ret = string.explode(param,' ',2)
if #ret < 2 or getPlayerByName(ret[2]) == false then
return doPlayerSendTextMessage(cid,25,"check vip:\n/vip see player\n/vip see mock\n")
end
local ret_ = vip.getVip(getPlayerByName(ret[2]))
if ret_ == 0 then
return doPlayerSendTextMessage(cid, 25,ret[2].." Dont have any vip")
else
return doPlayerSendTextMessage(cid, 25, "Vip from "..ret[2].." end in "..os.date("%d %B %Y %X ",ret_))
end
end
return TRUE
end
Last edited: