[TFS 0.3/0.4] The best VIP system ever! [Action/Movevent/Globalevent]
Hello.
First of all If you're going to post it somewhere else, I dont want you to take credits because its 100% mine.
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.
Tested in TheForgottenServer 0.3.6 / 0.4
This VIP system contains:
Okey well here it go.
Go to your phpmyadmin and execute:
Now, go to data/lib/function.lua and add this lines in the top.
Once you done it, add this line in data/creaturescript/login.lua
And now in data/creaturescript/scripts create a new file and name it vipcheck.lua
data/creaturescript/creaturescript.xml
Now, go to data/globalevents/scripts/, create a new file and name it daysremover.lua
data/globalevents/globanevents.xml
You can change the time when the vip day is going to be removed in (time="00:01").
VIP Tile
data/movements/scripts/viptile.lua
data/movements/movements.xml
In you map editor, just set action id 11223 to the tile you want to be vip tile.
VIP Medal
data/actions/scripts/vipmedal.lua
data/actions/actions.xml
Dont forget to change the item ID.
Add VIP days command
data/talkactions/scripts/adddays.lua
data/talkactions/talkactions.xml/
Remove VIP days command
data/talkactions/scripts/removedays.lua
data/talkactions/scripts/talkactions.xml/
VIP Door
data/actions/scripts/vipdoor.lua
data/actions/actions.xml
Effect only for VIP players
globalevents/scripts/vipEffect.lua
data/globalevents/globalevents.xml
Auto temple teleporter when VIP days over!
data/creaturescripts/scripts/templeteleport.lua
data/creaturescripts/creaturescripts.xml/
In /data/creaturescripts/scripts/login.lua add this line:
Functions
Enjoy it and dont forget to REP ++.
Hello.
First of all If you're going to post it somewhere else, I dont want you to take credits because its 100% mine.
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.
Tested in TheForgottenServer 0.3.6 / 0.4
This VIP system contains:
- Own Lua functions
- Automatic day remover.
- VIP tile.
- onLogin script to check vip.
- VIP Medal.
- Remove Vip Days Command.
- Add Vip Days Command.
- Auto temple teleporter when vipdays over!.
Okey well here it go.
Go to your phpmyadmin and execute:
Code:
ALTER TABLE `accounts` ADD
`vipdays` int(11) NOT NULL DEFAULT 0;
Now, go to data/lib/function.lua and add this lines in the top.
Lua:
--- 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
Once you done it, add this line in data/creaturescript/login.lua
Lua:
registerCreatureEvent(cid, "VipCheck")
And now in data/creaturescript/scripts create a new file and name it vipcheck.lua
Lua:
--- 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
data/creaturescript/creaturescript.xml
Code:
<event type="login" name="VipCheck" event="script" value="vipcheck.lua"/>
Now, go to data/globalevents/scripts/, create a new file and name it daysremover.lua
Lua:
--- Script by Kekox
function onTimer()
db.executeQuery("UPDATE accounts SET vipdays = vipdays - 1 WHERE vipdays > 0;")
return true
end
data/globalevents/globanevents.xml
Code:
<globalevent name="VipDaysRemover" time="00:01" event="script" value="daysremover.lua"/>
You can change the time when the vip day is going to be removed in (time="00:01").
If you have more than or just 1 vip day, when you login you'll get a message:
OTHER SCRIPTS!
OTHER SCRIPTS!
VIP Tile
data/movements/scripts/viptile.lua
Lua:
--- Script by Kekox
function onStepIn(cid, item, position, fromPosition)
if getPlayerVipDays(cid) == 0 then
doTeleportThing(cid, fromPosition, FALSE)
end
return true
end
data/movements/movements.xml
Code:
<movevent type="StepIn" actionid="11223" event="script" value="viptile.lua"/>
In you map editor, just set action id 11223 to the tile you want to be vip tile.
VIP Medal
data/actions/scripts/vipmedal.lua
Lua:
-- Vip medal 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")
doPlayerPopupFYI(cid, "We have added 30 vip days to your account!\nEnjoy it!.")
doRemoveItem(item.uid)
end
return true
end
data/actions/actions.xml
Code:
<action itemid="2112" event="script" value="vipmedal.lua"/>
Dont forget to change the item ID.
Add VIP days command
data/talkactions/scripts/adddays.lua
Lua:
--- Script by Kekox.
function onSay(cid, words, param, channel)
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
sender = getPlayerByNameWildcard(cid)
doAddVipDays(pid, t[1])
doPlayerSendTextMessage(cid, "You have added ".. t[1] .." vip days to ".. t[2])
doPlayerSendTextMessage(pid, sender .." just added you ".. t[1] .." vip days.")
return true
end
Code:
<talkaction log="yes" words="/adddays" access="5" event="script" value="adddays.lua"/>
Remove VIP days command
data/talkactions/scripts/removedays.lua
Lua:
--- Script by Kekox fixed by Shawak.
function onSay(cid, words, param, channel)
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
sender = getPlayerByNameWildcard(cid)
doRemoveVipDays(pid, t[1])
doPlayerSendTextMessage(cid, "You have removed ".. t[1] .." vip days to ".. t[2])
doPlayerSendTextMessage(pid, sender .." just removed you ".. t[1] .." vip days.")
return true
end
Code:
<talkaction log="yes" words="/removedays" access="5" event="script" value="removedays.lua"/>
data/actions/scripts/vipdoor.lua
Lua:
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
data/actions/actions.xml
Code:
<action actionid="2112" event="script" value="vipdoor.lua"/>
globalevents/scripts/vipEffect.lua
Lua:
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
data/globalevents/globalevents.xml
Code:
<globalevent name="vipEffect" interval="2" script="vipEffect.lua"/>
Auto temple teleporter when VIP days over!
data/creaturescripts/scripts/templeteleport.lua
Lua:
function onLogin(cid)
if getPlayerVipDays(cid) > 0 then
setPlayerStorageValue(cid, 20500, 1)
elseif getPlayerVipDays(cid) == 0 and getPlayerStorageValue(cid, 20500) == 1 then
doTeleportThing(cid, getPlayerMasterPos(cid))
setPlayerStorageValue(cid, 20500, -1)
end
return true
end
XML:
<event type="login" name="TempleTeleporter" event="script" value="templeteleport.lua"/>
Lua:
registerCreatureEvent(cid, "TempleTeleporter")
Functions
- getPlayerVipDays(cid) --- Use it to check how many vip days the player have.
- doAddVipDays(cid, days) --- Use it to add vip days to someone.
- doRemoveVipDays(cid, days) --- Use it to remove vip days to someone.
Enjoy it and dont forget to REP ++.
Last edited: