Well I'll explain the system.. Most of the vip system use a globalevent to remove 1 day vip every 24 hours but, what if the serv have 23 hours uptime and it crash? The day would not be removed, so I fixed it, now the vip day will be removed at an specific hour, if you set it to 2pm, the vip day will be removed at 2 pm so if the serv crash for like 3 mins it still will remove the vip days at 2pm..
Also it works to all the account, just like a premium account.
Well, Nothing new, only doesn't have Talkaction of removedays and adddays & this is a MOD
Mysql Table
Code:
ALTER TABLE `accounts` ADD
`vipdays` int(11) NOT NULL DEFAULT 0;
MOD Tested in Tfs 0.3.6
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Vipsystem" version="1.0"
author="Aco" contact="http://otland.net/members/acordion" enabled="yes">
<!--- Information
Vip Item = 10503
set action id 11223 to the tile you want to be vip tile
set action id 2112 to the door you want to be vip door
MYSQL TABLE
........................................................
ALTER TABLE `accounts` ADD
`vipdays` int(11) NOT NULL DEFAULT 0;
........................................................
-->
<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 onTimer()
db.executeQuery("UPDATE accounts SET vipdays = vipdays - 1 WHERE vipdays > 0;")
return true
end
]]></globalevent>
<globalevent name="vipEffect" interval="2" event="script"><![CDATA[
domodlib('VipFuctions')
--- Script By Kekox.
function onThink(interval, lastExecution)
for _, name in ipairs(getOnlinePlayers()) do
local cid = getPlayerByName(name)
if getPlayerVipDays(cid) >= 1 then
doSendMagicEffect(getPlayerPosition(cid), 27)
doSendAnimatedText(getPlayerPosition(cid), "VIP!", TEXTCOLOR_RED)
end
end
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="10503" 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, 30)
doCreatureSay(cid, "Vip", TALKTYPE_ORANGE_1)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "We have added 30 vip days to your account.")
doRemoveItem(item.uid)
end
return true
end
]]></action>
</mod>
Tatu hunter: With promotion, talkactions and new fuctions
oh nice, I have made a MOD of Vip system too using some of these functions =D
--- edit ---
lets share my vip mod too =]
this vip system works with the actionid 5788, just set this actionid on a tile or door to only vips players enter.
and I added the talkactions too
/adddays XXX, PlayerName
/removedays XXX, PlayerName
PHP:<?xml version="1.0" encoding="UTF-8"?> <mod name="Vip System" version="1.0" author="Kekox and Diorges" contact="" enabled="yes"> <config name="vipFunctions"> <=!=[=C=D=A=T=A=[ local config = { vipVocation = true, -- Vip have new vocations? vipPromotionStorage = 49159, -- Store if the player had promotion vip isVipStorage = 49160, -- Storage to check if the player had or no vip vipGroup = 1, -- not added yet playerGroup = 1, -- not added yet freeVip = false, -- not added yet restoreStamina = true, -- restore ur stamina after relogin? townId = 1 -- teleport the player to this town when player lost vip } 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) if (getPlayerVipDays(cid) <= days) then db.executeQuery("UPDATE `accounts` SET `vipdays` = 0 WHERE `id` = " .. getPlayerAccountId(cid) .. ";") else db.executeQuery("UPDATE `accounts` SET `vipdays` = `vipdays` - " .. days .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";") end end ]=]=> </config> <event type="login" name="vipRegister" event="script"> <=!=[=C=D=A=T=A=[ function onLogin(cid) registerCreatureEvent(cid, "vipCheck") return true end ]=]=> </event> <event type="login" name="vipCheck" event="script"> <=!=[=C=D=A=T=A=[ domodlib('vipFunctions') function onLogin(cid) -- Add the storage of promotion to player if(getPlayerStorageValue(cid, config.vipPromotionStorage) == -1 and config.vipVocation == true) then setPlayerStorageValue(cid, config.vipPromotionStorage, 1) end if (getPlayerVipDays(cid) >= 1) then -- Restore the stamina of player if(config.restoreStamina) then doPlayerSetStamina(cid, 2520) end -- Add a storage to player to check later if he had VIP if(getPlayerStorageValue(cid, config.isVipStorage) == -1) then setPlayerStorageValue(cid, config.isVipStorage, 1) end -- Add a storage to player to keep him promotion after he lose ur vipdays if(config.vipVocation == true and getPlayerPromotionLevel(cid) == 2 and getPlayerStorageValue(cid, config.vipPromotionStorage) == 1) then setPlayerStorageValue(cid, config.vipPromotionStorage, 2) end - -- Add back the old promotion of player if he buy more vipdays if (config.vipVocation == true and getPlayerPromotionLevel(cid) == 1 and getPlayerStorageValue(cid, config.vipPromotionStorage) == 2) then doPlayerSetPromotionLevel(cid, 2) end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have '.. getPlayerVipDays(cid) ..' vip days left.') else -- Reset the promotion of player if(getPlayerPromotionLevel(cid) > 1 and config.vipVocation == true) then doPlayerSetPromotionLevel(cid, 1) end -- Teleport the player to town if(getPlayerStorageValue(cid, config.isVipStorage) == 1) then doPlayerSetTown(cid, config.townId) doTeleportThing(cid, getTownTemplePosition(config.townId)) setPlayerStorageValue(cid, config.isVipStorage, 0) end end return true end ]=]=> </event> <globalevent name="VipDaysRemover" time="00:01" event="script"> <=!=[=C=D=A=T=A=[ function onTime() db.executeQuery("UPDATE accounts SET vipdays = vipdays - 1 WHERE vipdays > 0;") return true end ]=]=> </globalevent> <action actionid="5788" event="script"> <=!=[=C=D=A=T=A=[ domodlib('vipFunctions') function onUse(cid, item, fromPosition, itemEx, toPosition) local cidPosition = getCreaturePosition(cid) if (item.actionid == 5788 and getPlayerVipDays(cid) >= 1) then if getCreaturePosition(cid).y < toPosition.y then doTeleportThing(cid, {x=toPosition.x,y=toPosition.y+1,z=toPosition.z}, TRUE) else doTeleportThing(cid, {x=toPosition.x,y=toPosition.y-1,z=toPosition.z}, TRUE) end else doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sorry, you are not a VIP player.") end return TRUE end ]=]=> </action> <movevent type="StepIn" actionid="5788" event="script"> <=!=[=C=D=A=T=A=[ domodlib('vipFunctions') function onStepIn(cid, item, position, fromPosition) if (getPlayerVipDays(cid) == 0) then doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sorry, you are not a VIP player.") doTeleportThing(cid, fromPosition, TRUE) end end ]=]=> </movevent> <talkaction words="/adddays; /removedays" access="5" event="script"> <=!=[=C=D=A=T=A=[ function onSay(cid, words, param, channel) domodlib('vipFunctions') if words == '/adddays' then if(param == '') then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.") return true end local t = string.explode(param, ",") t[1] = tonumber(t[1]) if(not t[1]) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires numeric param.") return true end local pid = cid if(t[2]) then pid = getPlayerByNameWildcard(t[2]) if(not pid) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[2] .. " not found.") return true end end if(t[1] > 365) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can only add max 365 vip days.") return true end doAddVipDays(pid, t[1]) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have added ".. t[1] .." vip days to ".. t[2]) doPlayerSendTextMessage(pid, MESSAGE_STATUS_CONSOLE_BLUE, getPlayerName(cid) .." just added you ".. t[1] .." vip days.") return true elseif words == '/removedays' then if(param == '') then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.") return true end local t = string.explode(param, ",") t[1] = tonumber(t[1]) if(not t[1]) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires numeric param.") return true end local pid = cid if(t[2]) then pid = getPlayerByNameWildcard(t[2]) if(not pid) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[2] .. " not found.") return true end end if(t[1] > 365) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can only add max 365 vip days.") return true end doRemoveVipDays(pid, t[1]) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have removed ".. t[1] .." vip days to ".. t[2]) doPlayerSendTextMessage(pid, MESSAGE_STATUS_CONSOLE_BLUE, getPlayerName(cid) .." just removed you ".. t[1] .." vip days.") return true end end ]=]=> </talkaction> </mod>
If you want to use vipVocations add or make your own custom vocations like this:
PHP:<!-- VIP --> <vocation id="9" name="Suprem Wizardy" description="a supremo wizardy" needpremium="1" gaincap="10" gainhp="5" gainmana="30" gainhpticks="3" gainhpamount="100" gainmanaticks="1" gainmanaamount="100" manamultiplier="1.1" attackspeed="1000" soulmax="200" gainsoulticks="15" fromvoc="5" lessloss="50"> <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/> <skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/> </vocation> <vocation id="10" name="Demon Priest" description="a demon priest" needpremium="1" gaincap="10" gainhp="5" gainmana="30" gainhpticks="3" gainhpamount="100" gainmanaticks="1" gainmanaamount="100" manamultiplier="1.1" attackspeed="1000" soulmax="200" gainsoulticks="15" fromvoc="6" lessloss="50"> <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/> <skill fist="1.5" club="1.8" sword="1.8" axe="1.8" distance="1.8" shielding="1.5" fishing="1.1" experience="1.0"/> </vocation> <vocation id="11" name="Master Bowman" description="a master bowman" needpremium="1" gaincap="20" gainhp="10" gainmana="15" gainhpticks="2" gainhpamount="100" gainmanaticks="2" gainmanaamount="100" manamultiplier="1.4" attackspeed="1000" soulmax="200" gainsoulticks="15" fromvoc="7" lessloss="50"> <formula meleeDamage="1.0" distDamage="1.4" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/> <skill fist="1.2" club="1.2" sword="1.2" axe="1.2" distance="1.1" shielding="1.1" fishing="1.1" experience="1.0"/> </vocation> <vocation id="12" name="Gladiator" description="a gladiator" needpremium="1" gaincap="25" gainhp="15" gainmana="5" gainhpticks="1" gainhpamount="100" gainmanaticks="3" gainmanaamount="100" manamultiplier="3.0" attackspeed="1000" soulmax="200" gainsoulticks="15" fromvoc="8" lessloss="50"> <formula meleeDamage="1.3" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/> <skill fist="1.1" club="1.1" sword="1.1" axe="1.1" distance="1.4" shielding="1.1" fishing="1.1" experience="1.0"/> </vocation> <!-- FIM VIP -->
now open your promotion npc script and replace with this:
I just added the parameter vip.PHP:local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end local node1 = keywordHandler:addKeyword({'promotion'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can promote you for 20000 gold coins. Do you want me to promote you?'}) node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, level = 20, promotion = 1, vip = 0, text = 'Congratulations! You are now promoted.'}) node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true}) local node2 = keywordHandler:addKeyword({'vip'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can promote you for 20000 gold coins. Do you want me to promote you?'}) node2:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, level = 100, promotion = 2, vip = 1, text = 'Congratulations! You are now promoted.'}) node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true}) npcHandler:addModule(FocusModule:new())
but to it work edit your npc modules (data/npc/lib/npcsystem/modules.lua)
search this function:
PHP:function StdModule.promotePlayer(cid, message, keywords, parameters, node)
and change this:
PHP:if(getPlayerPromotionLevel(cid) >= parameters.promotion) then npcHandler:say('You are already promoted!', cid)
with this:
PHP:if(parameters.vip == 1 and getPlayerVipDays(cid) == 0) then npcHandler:say('You must buy VIP Account first!', cid) elseif(getPlayerPromotionLevel(cid) >= parameters.promotion) then npcHandler:say('You are already promoted!', cid)
now open your (data/lib/050-function.lua) and add in somewhere this:
PHP: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
now youre done!
Show vip system [Gesior/Modern Acc]
This mod is only if you need money to payment from host,
OTs Isn't Merchantable
Last edited: