• 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!

The best VIP system ever! [Action/Movevent/Globalevent]

Kekox

Well-Known Member
Joined
Apr 4, 2009
Messages
1,264
Best answers
0
Reaction score
55
Location
Venezuela
[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:
  • 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!

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
data/talkactions/talkactions.xml/
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
data/talkactions/scripts/talkactions.xml/
Code:
	<talkaction log="yes" words="/removedays" access="5" event="script" value="removedays.lua"/>
VIP Door

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"/>
Effect only for VIP players


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
data/creaturescripts/creaturescripts.xml/
XML:
	<event type="login" name="TempleTeleporter" event="script" value="templeteleport.lua"/>
In /data/creaturescripts/scripts/login.lua add this line:
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:
OP
Kekox

Kekox

Well-Known Member
Joined
Apr 4, 2009
Messages
1,264
Best answers
0
Reaction score
55
Location
Venezuela
Edited and fixed some bugs..
 

chojrak

Banned User
Joined
Oct 25, 2008
Messages
5,832
Best answers
2
Reaction score
159
Code:
name="[B]Arena Svargrond[/B]"
???
 
OP
Kekox

Kekox

Well-Known Member
Joined
Apr 4, 2009
Messages
1,264
Best answers
0
Reaction score
55
Location
Venezuela
HAH FAIL!

I'm sorry I just copied the base of the arena mod to start scripting mine xD!

Fixed.
 

Serginov

Onkonkoronkonk
Joined
Jun 28, 2008
Messages
1,322
Best answers
0
Reaction score
18
Location
Sweden - Dalarna
Cool, rep++ for you :)

EDIT;
instead of using this:
Lua:
function doPlayerTeleportBack(cid)
         if getPlayerLookDir(cid) == 0 then
            doTeleportThing(cid, {x=getPlayerPosition(cid).x, y=getPlayerPosition(cid).y+1, z=getPlayerPosition(cid).z})

         elseif getPlayerLookDir(cid) == 1 then
            doTeleportThing(cid, {x=getPlayerPosition(cid).x-1, y=getPlayerPosition(cid).y, z=getPlayerPosition(cid).z})
            
         elseif getPlayerLookDir(cid) == 2 then
            doTeleportThing(cid, {x=getPlayerPosition(cid).x, y=getPlayerPosition(cid).y-1, z=getPlayerPosition(cid).z})
            
         elseif getPlayerLookDir(cid) == 3 then
            doTeleportThing(cid, {x=getPlayerPosition(cid).x+1, y=getPlayerPosition(cid).y, z=getPlayerPosition(cid).z})
         end
         return true
end
:
Lua:
doPlayerTeleportBack(cid)
use this?:
Lua:
doTeleportThing(cid, fromPosition, FALSE)
or that doesn't work in mod?
 
Last edited:

IMac

entrepreneur
Joined
May 31, 2009
Messages
2,482
Best answers
0
Reaction score
16
Location
Pluto
can you add like a command to add/remove vip days?
 
OP
Kekox

Kekox

Well-Known Member
Joined
Apr 4, 2009
Messages
1,264
Best answers
0
Reaction score
55
Location
Venezuela
Sure, here it is..

Addvip:
Lua:
function doAddVipDays(cid, days)
    db.executeQuery("UPDATE `accounts` SET `vipdays` = `vipdays` + " .. days .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end
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 gave you ".. t[1] .." vip days.")    
	return true
end
Param 1 = vip days
Param 2 = player name

Example:

/whatever-you-want 20, Kekox
You get:
You have added 20 vip days to <playername>

Playername get:
<yourname> just gave you 20 vip days

Remove vip:
Lua:
function doRemoveVipDays(cid, days)
    db.executeQuery("UPDATE `accounts` SET `vipdays` = `vipdays` - " .. days .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end
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
Same as addvip command :)
 

lord azteck

New Member
Joined
Jan 4, 2009
Messages
221
Best answers
0
Reaction score
3
Hello, first of all, I've seen this MOD, in another OT, and let me tell you, something...
GRATZ!, in my opinnion i think this is the BestVipSystem ever made.

I've got an error in console, when it tries to load MOD's,
like this:
Code:
[11/03/2010 01:09:12] > Loading vipsystem.xml...[Error - ScriptingManager::loadFromXml] Cannot load mod mods/vipsystem.xml
[11/03/2010 01:09:12] Line: 46, Info: Extra content at the end of the document
Hope you can help me!
 
Last edited:
OP
Kekox

Kekox

Well-Known Member
Joined
Apr 4, 2009
Messages
1,264
Best answers
0
Reaction score
55
Location
Venezuela
Are you stupid? wich OT? maybe mines.. I made it.. -.-
 

lord azteck

New Member
Joined
Jan 4, 2009
Messages
221
Best answers
0
Reaction score
3
im just telling u that tanks, and i've had seen this vip system in another ots... u don't need to tell me stupid...
and yes, i know u made it, in any time i didn't say that u didn't
fail?
pd: wtf happens with that error?
 

Serginov

Onkonkoronkonk
Joined
Jun 28, 2008
Messages
1,322
Best answers
0
Reaction score
18
Location
Sweden - Dalarna
Is it possible to make for example NPC, Globalevent and creaturescript, in the same mod?
 
OP
Kekox

Kekox

Well-Known Member
Joined
Apr 4, 2009
Messages
1,264
Best answers
0
Reaction score
55
Location
Venezuela
I dont even know xD! I just updated it... :)
 

Shawak

Intermediate OT User
Joined
Sep 11, 2008
Messages
1,976
Best answers
2
Reaction score
103
Location
Germany
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)
            doPlayerPopupFYI(cid, "We have added 30 vip days to your account!\nEnjoy it!.")
            doRemoveItem(item.uid)
         end
        return true
end
Replace with:

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)
            doPlayerPopupFYI(cid, "We have added 30 vip days to your account!\nEnjoy it!.")
            doRemoveItem(item.uid)
         end
        return true
end

EDIT: And replace this:
Lua:
  function doRemoveVipDays(cid, days)
    db.executeQuery("UPDATE `accounts` SET `vipdays` = `vipdays` - " .. days .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end
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
with;

Lua:
  function doRemoveVipDays(cid, days)
    db.executeQuery("UPDATE `accounts` SET `vipdays` = `vipdays` - " .. days .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end
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
Regards,
Shawak
 
Top