Saint Spear
Veteran OT User
- Joined
- Jun 22, 2016
- Messages
- 1,547
- Solutions
- 18
- Reaction score
- 379
Hello , I'm using tfs 0.4 3777 and I'm having this problem :
When players use vip medal it works fine , but after 00:01 days still are same..
10:31 You have 14 vip days left.
and after 3-4 days
10:31 You have 14 vip days left.
Heres the script I'm using
Also I carefully added in my sql table
When players use vip medal it works fine , but after 00:01 days still are same..
10:31 You have 14 vip days left.
and after 3-4 days
10:31 You have 14 vip days left.
Heres the script I'm using
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Vipsystem" version="1.0"
author="Aco" contact="http://otland.net/members/acordion" enabled="yes">
<config name="VipFuctions"><![CDATA[
--- Vip functions by Kekox
function getPlayerVipDays(cid)
local Info = db.getResult("SELECT `vipdays` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. " LIMIT 1")
if Info:getID() ~= LUA_ERROR then
local days= Info:getDataInt("vipdays")
Info:free()
return days
end
return LUA_ERROR
end
function doAddVipDays(cid, days)
db.executeQuery("UPDATE `accounts` SET `vipdays` = `vipdays` + " .. days .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end
function doRemoveVipDays(cid, days)
db.executeQuery("UPDATE `accounts` SET `vipdays` = `vipdays` - " .. days .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end
]]></config>
<globalevent name="VipDaysRemover" time="00:01" event="script"><![CDATA[
--- Script by Kekox.
function onTime()
db.executeQuery("UPDATE accounts SET vipdays = vipdays - 1 WHERE vipdays > 0;")
return true
end
]]></globalevent>
<event type="login" name="Vip" event="script"><![CDATA[
--- Script by Kekox.
function onLogin(cid)
registerCreatureEvent(cid, "VipCheck")
return true
end]]></event>
<event type="login" name="VipCheck" event="script"><![CDATA[
domodlib('VipFuctions')
--- Script by Kekox.
function onLogin(cid)
if getPlayerVipDays(cid) >= 1 then
doPlayerSendTextMessage(cid, 19, "You have ".. getPlayerVipDays(cid) .." vip days left.")
end
return true
end
]]></event>
<movevent type="StepIn" actionid="11223" event="script"><![CDATA[
domodlib('VipFuctions')
--- Script by Kekox.
function onStepIn(cid, item, position, fromPosition)
if getPlayerVipDays(cid) == 0 then
doTeleportThing(cid, fromPosition, FALSE)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only VIP Account can go there.")
end
return true
end
]]></movevent>
<action actionid="2112" event="script"><![CDATA[
domodlib('VipFuctions')
--- Script by Kekox.
function onUse(cid, item, frompos, item2, topos)
if getPlayerVipDays(cid) >= 1 then
pos = getPlayerPosition(cid)
if pos.x == topos.x then
if pos.y < topos.y then
pos.y = topos.y + 1
else
pos.y = topos.y - 1
end
elseif pos.y == topos.y then
if pos.x < topos.x then
pos.x = topos.x + 1
else
pos.x = topos.x - 1
end
else
doPlayerSendTextMessage(cid,22,"Stand in front of the door.")
return true
end
doTeleportThing(cid,pos)
doSendMagicEffect(topos,12)
else
doPlayerSendTextMessage(cid,22,'Only VIP Account can go there.')
end
return true
end
]]></action>
<action itemid="5785" event="script"><![CDATA[
domodlib('VipFuctions')
--- Script by Kekox.
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerVipDays(cid) > 365 then
doPlayerSendCancel(cid, "You can only have 1 year of vip account or less.")
else
doAddVipDays(cid, 14)
doCreatureSay(cid, "Vip", TALKTYPE_ORANGE_1)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "We have added 14 vip days to your account.")
doRemoveItem(item.uid)
end
return true
end
]]></action>
</mod>
Code:
ALTER TABLE `accounts` ADD
`vipdays` int(11) NOT NULL DEFAULT 0;