Jump to content
Sign in to follow this  
ahmad

vip System States

Recommended Posts

helo
i'm using vip system  by 7n6
but i found a small bug with add States

when player use ship then back to land keep add states without remove old states till relog or use a ticket
this my states add

---vip--
function STATE_vip_Add(Player, StateLv)

	local CON = GetChaAttr(Player, ATTR_STATEV_CON) + 1
	local MSPD = GetChaAttr(Player, ATTR_STATEV_ASPD) + 15
	SetCharaAttr(CON, Player, ATTR_STATEV_CON)
	SetCharaAttr(MSPD, Player, ATTR_STATEV_ASPD)
	

	--AttrRecheck(Player)
end
function STATE_vip_Rem(Player, StateLv)
	
	local CON = GetChaAttr(Player, ATTR_STATEV_CON) - 1
	local MSPD = GetChaAttr(Player, ATTR_STATEV_ASPD) - 15
	SetCharaAttr(CON, Player, ATTR_STATEV_CON)
	SetCharaAttr(MSPD, Player, ATTR_STATEV_ASPD)

 --AttrRecheck(Player)
end

and if teleport to another map show this
LG"check_item_final""

[10-19 16:49:02]ResetCheck Failed 

this the function inside forge.lua
image.png.6996349502207c9d02eac550fe864b6a.png

this the vip function

--[[

							*###########################################################################*
							#                              -Simple VIP by 7n6.-                         #
							#       If used please give credit or I will break your server Kappa.       #
							#                  (But seriously don't remove credits...)                  #
							*###########################################################################*
	

	
	
	
*******************************************************************************************************************************	
###############################################################################################################################
*******************************************************************************************************************************		
	Installation:
		1) Change VIP.SavePath to your desired save path.
		2) Change VIP.State to the state you wish to add to a VIP player
		3) Add lines to iteminfo
			eg:
				8967	VIP 10 Seconds	n1216	10130016	0	0	0	0	0	0	31	0	0	0	0	0	1	1	1	1	1	0	200	-1,-2,-2,-2	0	-1,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2	0	0	-1,-2,-2,-2,-2,-2,-2,-2,-2,-2	-1,-2,-2,-2,-2,-2,-2,-2,-2,-2	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0	0,0	0,0	0	0	0	0	0	0	0	0	0	AddVIP	0	0	0	0,0	0	0	Use to get VIP
				8968	VIP 1 Day	n1216	10130016	0	0	0	0	0	0	31	0	0	0	0	0	1	1	1	1	1	0	200	-1,-2,-2,-2	0	-1,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2	0	0	-1,-2,-2,-2,-2,-2,-2,-2,-2,-2	-1,-2,-2,-2,-2,-2,-2,-2,-2,-2	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0	0,0	0,0	0	0	0	0	0	0	0	0	0	AddVIP	0	0	0	0,0	0	0	Use to get VIP
				8969	VIP 7 Days	n1216	10130016	0	0	0	0	0	0	31	0	0	0	0	0	1	1	1	1	1	0	200	-1,-2,-2,-2	0	-1,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2	0	0	-1,-2,-2,-2,-2,-2,-2,-2,-2,-2	-1,-2,-2,-2,-2,-2,-2,-2,-2,-2	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0	0,0	0,0	0	0	0	0	0	0	0	0	0	AddVIP	0	0	0	0,0	0	0	Use to get VIP
		4) Adjust VIP.Items to have the ID of the item as the index, and the time in seconds that the item will add upon use as the value
			eg : 
				[8967] = 10,
			Means item 8967 will add 10 seconds to VIP.
		5) Load this file with DoFile()
*******************************************************************************************************************************	
###############################################################################################################################
*******************************************************************************************************************************	


]]
--Create VIP object
VIP = {}
--Declare save path
VIP.SavePath = GetResPath("../db/vipeffect/VIP.txt")
--State to add to VIP players
VIP.State = 220
--Items to add VIP
--[8525] = 10  : means item 8967 when used gives VIP for 10 seconds
VIP.Items = {
	[8525] = 10,
	[8526] = (60 * 60 * 24),
	[8527] = (26 * 60 * 60 * 24),
}

--Function to create the savefile upon first load
function VIP.Initial(file)
	Table = io.open(file,"r")
	if Table~=nil then 
		io.close(Table) 
	else 
		table.save({},file,"w")
	end
end
VIP.Initial(VIP.SavePath)

--Item function to add to the VIP time.
--If you use a vip item while already vip, it adds to your vip time
function AddVIP(role,Item)
	local PID = GetRoleID(role)
	local ID = GetItemID(Item)
	local Time = VIP.Items[ID]
	local data = table.load(VIP.SavePath,"r")
	if Time ~= nil then
		if VIP.CheckVIP(role) == false then
			data[PID] = VIP.SystemTimeNow()
		end
		data[PID] = data[PID] + Time
	end
	table.save(data,VIP.SavePath,"w")
	AttrRecheck(role)
end

--Function returns true if user is currently vip, false if they are not
function VIP.CheckVIP(role)
	local data = table.load(VIP.SavePath,"r")
	local PID = GetRoleID(role)
	local ship = TurnToShip(role)
	local k = ChaIsBoat(ship)
	if k == 1 then
	return false
	end
	if data[PID] == nil or data[PID] <= VIP.SystemTimeNow() then
		return false
	else
		return true
	end

end

--Hooked on AttrRecheck, so will check each time players stats update
function VIP.AddState(role)
	if VIP.CheckVIP(role) == true then
		AddState(role,role,VIP.State,1,0)
	else
		if GetChaStateLv ( role , VIP.State ) > 0 then
			RemoveState ( role ,  VIP.State )
		end
	end

end

--Returns systemtime in seconds.
function VIP.SystemTimeNow()
	local TimeNow = os.date("*t")
	local Value = os.time{day = TimeNow.day ,month = TimeNow.month,year = TimeNow.year,hour = TimeNow.hour, min = TimeNow.min,sec = TimeNow.sec}
	return Value 
end

Hook:AddPreHook("AttrRecheck",VIP.AddState)

 

Edited by ahmad

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...