• 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 v2.0

Shawak

Intermediate OT User
Joined
Sep 11, 2008
Messages
1,984
Solutions
2
Reaction score
119
Location
Germany
GitHub
Shawak
Hello,
Since I noticed that a storage value isn't very good for a vip system,
I decided to make a new one, with db qeurys and entrys ^_^.

Credits:
- Idea:
http://otland.net/f82/vip-system-19426/
- Script:
100% by me :)

Version:
- Tested on TFS 0.3.5pl1.
- Should work with other TFSs.

New lua functions:
Code:
setPlayerVipTime(cid, days, hours, minutes, seconds)       -- set player XXX Vip days // return TRUE
getPlayerVipTime(cid, "days"/"hours"/"minutes"/"seconds")  -- get player current Vip time left // return type
isPlayerVip(cid)                                           -- check if player is vip // return TRUE (if player is Vip) or FALSE (if player isn't Vip)
doPlayerAddVipTime(cid, days/hours/minutes/seconds)        -- add player vip time // return TRUE
doPlayerRemoveVip(cid)                                     -- remove player Vip and set Vip time to 0 // return TRUE

Changelog:
v2.0:
Code:
- Changed some lua functions.
- Added db entry + querys.
- Added types in lua functions.
v1.0:
[Old Version] - http://otland.net/f163/full-working-vip-system-shawak-44840/

Script:
- go to your database and enter this query:
HTML:
ALTER TABLE `players` ADD `vip_time` BIGINT(32) NOT NULL DEFAULT 0;
- data/lib/data.lua, at the end:
Lua:
dofile("vip.lua")

After that go to your server file, where you .exe is, and paste this .lua file:

Lua:
--[[
	VIP System by Shawak
	Db Query: "ALTER TABLE `players` ADD `vip_time` BIGINT(32) NOT NULL DEFAULT 0;"
]]--

function setPlayerVipTime(cid, days, hours, minutes, seconds)
	return db.executeQuery("UPDATE `players` SET `vip_time` = ("..os.time().." + "..days.."*86400+"..hours.."*3600+"..minutes.."*60+"..seconds..") WHERE `id` = "..getPlayerGUID(cid)..";")
end

function getPlayerVipTime(cid, type)
	times, r = {
		["days"] = 86400,
		["hours"] = 3600,
		["minutes"] = 60,
		["seconds"] = 1
	}, 0
        query = db.getResult("SELECT `vip_time` FROM `players` WHERE `id` = "..getPlayerGUID(cid)..";")
	if(query:getID() ~= -1) then
		time = times[type]
		if time ~= FALSE then
	 		left = query:getDataInt("vip_time") - os.time()
		 	while left >= time do
				left = left - time
				r = r+1
			end
		end
	end
	query:free()
        return r
end

function isPlayerVip(cid)
	query = db.getResult("SELECT `vip_time` FROM `players` WHERE `id` = "..getPlayerGUID(cid)..";")
	if(query:getID() ~= -1) then
		return query:getDataInt("vip_time") >= os.time() and TRUE or FALSE
	end
	query:free()
	return FALSE
end

function doPlayerAddVipTime(cid, days, hours, minutes, seconds)
	query = db.getResult("SELECT `vip_time` FROM `players` WHERE `id` = "..getPlayerGUID(cid)..";")
	if(query:getDataInt("vip_time") < os.time()) then
		now = os.time()
	else
		now = query:getDataInt("vip_time")
	end
        db.executeQuery("UPDATE `players` SET `vip_time` = "..now.." + ("..days.."*86400+"..hours.."*3600+"..minutes.."*60+"..seconds..") WHERE `id` = "..getPlayerGUID(cid)..";")
	query:free()
	return TRUE
end

function doPlayerRemoveVip(cid)
        return db.executeQuery("UPDATE `players` SET `vip_time` = 0 WHERE `id` = "..getPlayerGUID(cid)..";")
end

Regards,
Shawak
 
Last edited:
This way is better than using Storage values? if so, why? Just wondering, dont get me wrong ;)

Also, you should upload the file on uploadhyper or use Znote's tutorial to upload it here on otland, because on that site when you open it, a HUGE advertisement comes in the window and doesnt let you see anything, and since its on a language I dont understand, I couldnt find the close button :D so it took me a while, I was almost going to quit lol.

Anyways its better to upload it here on otland as an attachment.
 
This way is better than using Storage values? if so, why? Just wondering, dont get me wrong ;)

Also, you should upload the file on uploadhyper or use Znote's tutorial to upload it here on otland, because on that site when you open it, a HUGE advertisement comes in the window and doesnt let you see anything, and since its on a language I dont understand, I couldnt find the close button :D so it took me a while, I was almost going to quit lol.

Anyways its better to upload it here on otland as an attachment.

If I upload it here I can't see how much have downloaded it <_<.
And yes, database entrys are better then storages values.
Also you can add it to the character info at the website.
 
Good job mate! I love your scripts as I said before!
 
Lol... Perfect timing :p
Really great script :p
I just needed a VIP system with minutes xD
 
aff can you re-upload file to other website?

@down
http://uploadhyper******malware.localhost
 
Last edited:
Please, post a exemple for use:
getPlayerVipTime(cid, "days"/"hours"/"minutes"/"seconds")

Ty! =D
 
Example:
Lua:
doPlayerSendTextMessage(cid, 22, "You have "..getPlayerVipTime(cid, "days").." days, "..getPlayerVipTime(cid, "hours").." hours, "..getPlayerVipTime(cid, "minutes").." minutes and "..getPlayerVipTime(cid, "seconds").." seconds vip left.")
 
Stfu husam, your post is just spamming,
"it rly sucks
db queries will lag serv ;s"


@dd queries; HAHA, make better script newbie, you post those spamm post, since I ignored you in msn.
 
Back
Top