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

[MOD] Kekox "The best VIP system ever!" rewritten to MOD!

Pheenix

Mr.Plain Awesome
Joined
Mar 28, 2011
Messages
152
Reaction score
14
Location
Sweden
So i took my time to rewrite this awesome VIP system to a single mod file! Awesome right?
All you need to do is a sql query and check that your actionids/itemids is not in use/or change them in the mod.

Functions of the original script included:
  • VIP Tile Pheenix edition (actionId: 4445)
  • VIP Item (can be set to enabled or disabled) (itemId: 2112)
  • Add VIP days command Pheenix edition ( /addvip days,playername )
  • Remove VIP days command Pheenix edition ( /removevip days,playername )
  • VIP Door (actionId: 4444)
  • Auto temple teleporter when the account is out of VIP days!

New Talkaction: /checkvip playername (displays how many vip days playername has left)

You can find Kekox original thread here:
http://otland.net/f163/best-vip-system-ever-action-movevent-globalevent-71638/




SQL Query in your TFSdb (server database):
sqlclearance.png
PHP:
ALTER TABLE `accounts` ADD
`vipdays` int(11) NOT NULL DEFAULT 0;

Create a file in your mods folder called vipsystem.xml and paste this:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="thebestvipever" version="1.0" author="Pheenix" contact="otland.net" enabled="true">
	<description><![CDATA[


 ______   _         _                                                               ______                _                                          
(_____ \ | |       (_)            /\                                               / _____)              (_)                                         
 _____) )| |  ____  _  ____      /  \   _ _ _   ____   ___   ___   ____    ____   | /  ___   ____  ____   _  ____    ____                            
|  ____/ | | / _  || ||  _ \    / /\ \ | | | | / _  ) /___) / _ \ |    \  / _  )  | | (___) / _  ||    \ | ||  _ \  / _  |                           
| |      | |( ( | || || | | |  | |__| || | | |( (/ / |___ || |_| || | | |( (/ /   | \____/|( ( | || | | || || | | |( ( | |                           
|_|      |_| \_||_||_||_| |_|  |______| \____| \____)(___/  \___/ |_|_|_| \____)   \_____/  \_||_||_|_|_||_||_| |_| \_|| |                           
                               ______                                                                              (_____|                           
                              (_____ \                                    _                                                                          
                               _____) )  ____   ____   ___   ____  ____  | |_    ___  _                                                              
                              |  ____/  / ___) / _  ) /___) / _  )|  _ \ |  _)  /___)(_)                                                             
                              | |      | |    ( (/ / |___ |( (/ / | | | || |__ |___ | _                                                              
                              |_|      |_|     \____)(___/  \____)|_| |_| \___)(___/ (_)                                                             
 _______  _               ______                        _    _  _              _                                        _______                      
(_______)| |             (____  \               _      | |  | |(_)            | |                 _                    (_______)                     
 _       | | _    ____    ____)  )  ____   ___ | |_    | |  | | _  ____        \ \   _   _   ___ | |_    ____  ____     _____    _   _   ____   ____ 
| |      | || \  / _  )  |  __  (  / _  ) /___)|  _)    \ \/ / | ||  _ \        \ \ | | | | /___)|  _)  / _  )|    \   |  ___)  | | | | / _  ) / ___)
| |_____ | | | |( (/ /   | |__)  )( (/ / |___ || |__     \  /  | || | | |   _____) )| |_| ||___ || |__ ( (/ / | | | |  | |_____  \ V / ( (/ / | |    
 \______)|_| |_| \____)  |______/  \____)(___/  \___)     \/   |_|| ||_/   (______/  \__  |(___/  \___) \____)|_|_|_|  |_______)  \_/   \____)|_|    
                                                                  |_|               (____/                                                           

					The best VIP system ever originally written by Keekox @otland.net
-------------------------------------------------------------------------------------------------------------------------------------------

						Functions of the original script included:

					    VIP Tile *Pheenix edition* (actionId: 4445)
					    VIP Item (can be set to enabled or disabled) (itemId: 2112)
					    Add VIP days command *Pheenix edition* ( /addvip days,playername )
					    Remove VIP days command *Pheenix edition* ( /removevip days,playername )
					    VIP Door (actionId: 4444)
					    Auto temple teleporter when the account is out of VIP days!

						SQL Query:
						ALTER TABLE `accounts` ADD
						`vipdays` int(11) NOT NULL DEFAULT 0;


					Talkactions/Commands:			Examples:
				    /removevip [days],[playername] 	/removevip 30,God Random
				    /addvip	 [days],[playername]  	/addvip 30,God Random
				    /checkvip [playername]			/checkvip God Random

-------------------------------------------------------------------------------------------------------------------------------------------
								*Rewritten to mod
								*Added configurations
								*Added Talkaction /checkvip playername
								 by Pheenix @otland.net
-------------------------------------------------------------------------------------------------------------------------------------------


	]]></description>
<config name="vipsys-conf"><![CDATA[
	vipConf = { -- Dont touch this
								-- Configuration --
-------------------------------------------------------------------------------------------------------------------------------------------

			vMuse = false, -- VIP item set to true to enable or false to disable

			vMft = "The gods of this server has disabled this VIP item!", -- Text sent to player when trying to use VIP item if disabled, change to whatever you want but leave quotations and comma (" ",)

			vMadd = 30,  -- Days the VIP item will reward the player when used.

			vTy = "[VIP SYSTEM]: You are VIP, you may pass!",  -- Text sent to non-VIP player on VIP tile, change to whatever you want but leave quotations and comma (" ",)

			vTn = "[VIP SYSTEM]: You need to be VIP to enter this area!", -- Text sent to VIP player on VIP tile, change to whatever you want but leave quotations and comma (" ",)

			vTey = 14,  -- Effect sent to VIP player when walking on a VIP tile

			vTen = 50,  -- Effect sent to non-VIP player when trying to walk on a VIP tile

			vDe = 14,  -- Effect sent to VIP player when walking through a VIP door

			vDy = "[VIP SYSTEM]: You are VIP, Welcome in!",  -- Text sent to VIP player when trying to open VIP-door, change to whatever you want but leave quotations and comma (" ",)

			vDn = "[VIP SYSTEM]: You need to be VIP to open this door!",	-- Text sent to non-VIP player when trying to open VIP-door, change to whatever you want but leave quotations and comma (" ",)

			vipMax = 365  -- Max VIP days (only in commands, can be altered via sql)
-------------------------------------------------------------------------------------------------------------------------------------------
								-- Configuration End --




		} -- Dont touch this



]]></config>
 
<lib name="vipsys-lib"><![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.query("UPDATE `accounts` SET `vipdays` = `vipdays` + " .. days .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
 end
 
function doRemoveVipDays(cid, days)
    db.query("UPDATE `accounts` SET `vipdays` = `vipdays` - " .. days .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end
]]></lib>
 
 
<action itemid="2112" event="script"><![CDATA[
domodlib('vipsys-lib')
domodlib('vipsys-conf')
-- Vip medal by Kekox
function onUse(cid, item, fromPosition, itemEx, toPosition)
		if vipConf.vMuse == true then
			if getPlayerVipDays(cid) > vipConf.vipMax or (getPlayerVipDays(cid)+vipConf.vMadd) > vipConf.vipMax then
				doPlayerSendTextMessage(cid, 17, "[VIP SYSTEM]: You have reached the maximum amount of VIP days allowed on your account.")
			else
				doAddVipDays(cid, vipConf.vMadd)
				doCreatureSay(cid, "VIP",34)
				doPlayerPopupFYI(cid, "We have added ".. vipConf.vMadd .." VIP days to your account!\nEnjoy it!")
				doRemoveItem(item.uid)
			end
			return true
		elseif vipConf.vMuse == false then
			doPlayerPopupFYI(cid,vipConf.vMft)
		end
        return true
end]]></action>
 
 
<action actionid="4444" event="script"> <![CDATA[
domodlib('vipsys-lib')
domodlib('vipsys-conf')
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,28,"[VIP SYSTEM]: Stand in front of the door.")
            return true
            end
            doPlayerSendTextMessage(cid,28,vipConf.vDy)
            doTeleportThing(cid,pos)
            doSendMagicEffect(topos,vipConf.vDe)
         else
            doPlayerSendTextMessage(cid,28,vipConf.vDn)
         end
         return true
end]]></action>
 
 
<movevent type="StepIn" actionid="4445" event="script"><![CDATA[
domodlib('vipsys-lib')
domodlib('vipsys-conf')
function onStepIn(cid, item, position, fromPosition)
         if getPlayerVipDays(cid) == 0 then
             doTeleportThing(cid, fromPosition, FALSE)
             doPlayerSendTextMessage(cid, 28, vipConf.vTn)
             doSendMagicEffect(getCreaturePosition(cid), vipConf.vTen)
              return true
         end
 
         currentVip = getPlayerVipDays(cid)
         if (currentVip > 0) then
             doPlayerSendTextMessage(cid, 28, vipConf.vTy)
             doSendMagicEffect(getCreaturePosition(cid), vipConf.vTey)
             return true
         end
end
]]></movevent>
 
 
<talkaction log="yes" words="/checkvip" access="5" event="script"><![CDATA[
domodlib('vipsys-lib')
function onSay(cid, words, param, channel)
	local pid = getPlayerByNameWildcard(param)
	local currentVip = getPlayerVipDays(pid)
 
        if(param == '') then
                doPlayerSendTextMessage(cid, 35, "[VIP SYSTEM]: Command requires param.")
                return true
        end
 
 
	if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then
		doPlayerSendTextMessage(cid, 35, "[VIP SYSTEM]: Player " .. param .. " not found.")
		return true
	end
 
	if(currentVip > 1) or (currentVip < 1) then
	doPlayerSendTextMessage(cid, 4, "[VIP SYSTEM]: ".. param .." has ".. currentVip .." VIP days left.")
		return true
	end
doPlayerSendTextMessage(cid, 4, "[VIP SYSTEM]: ".. param .." has ".. currentVip .." VIP day left.")
 
return true
end
]]></talkaction>
 
 
<talkaction log="yes" words="/removevip" access="5" event="script"><![CDATA[
domodlib('vipsys-lib')
function onSay(cid, words, param, channel)
        if(param == '') then
                doPlayerSendTextMessage(cid, 35, "[VIP SYSTEM]: Command requires param.")
                return true
        end
 
        local t = string.explode(param, ",")
        t[1] = tonumber(t[1])
        if(not t[1]) then
                doPlayerSendTextMessage(cid, 35, "[VIP SYSTEM]: Command requires numeric param.")
                return true
        end
 
        local pid = cid
        if(t[2]) then
                pid = getPlayerByNameWildcard(t[2])
                if(not pid) then
                        doPlayerSendTextMessage(cid, 35, "[VIP SYSTEM]: Player " .. t[2] .. " was not found.")
                        return true
                end
        end
 
pid = getPlayerByNameWildcard(t[2])
cid = cid
currentVip = getPlayerVipDays(pid)
        if(t[1] > currentVip) then
                doPlayerSendTextMessage(cid, 35, "[VIP SYSTEM]: You can not remove more VIP days than the player has, the player currently has ".. currentVip .." .")
                return true
        end
if(t[1] == 0) or (t[1] < 0) then
    doPlayerSendTextMessage(cid,35, "[VIP SYSTEM]: You cant remove a negative value of days.")
	return true
end
    doRemoveVipDays(pid, t[1])

if(t[1] > 1) then
    doPlayerSendTextMessage(cid,4, "[VIP SYSTEM]: You have removed ".. t[1] .." VIP days from ".. t[2] .." .")
    doPlayerSendTextMessage(pid,17, "[VIP SYSTEM]: A god just removed ".. t[1] .." VIP days from you.")    
return true
end
    doPlayerSendTextMessage(cid,4, "[VIP SYSTEM]: You have removed ".. t[1] .." VIP day from ".. t[2] .." .")
    doPlayerSendTextMessage(pid,17, "[VIP SYSTEM]: A god just removed ".. t[1] .." VIP day from you.")  
        return true
end
]]></talkaction>
 
 
<talkaction log="yes" words="/addvip" access="5" event="script"><![CDATA[
domodlib('vipsys-lib')
domodlib('vipsys-conf')
function onSay(cid, words, param, channel)
        if(param == '') then
                doPlayerSendTextMessage(cid, 35, "[VIP SYSTEM]: Command requires param.")
                return true
        end
 
        local t = string.explode(param, ",")
        t[1] = tonumber(t[1])
        if(not t[1]) then
                doPlayerSendTextMessage(cid, 35, "[VIP SYSTEM]: Command requires numeric param.")
                return true
        end
 
        local pid = cid
        if(t[2]) then
                pid = getPlayerByNameWildcard(t[2])
                if(not pid) then
                        doPlayerSendTextMessage(cid, 35, "[VIP SYSTEM]: Player " .. t[2] .. " was not found.")
                        return true
                end
        end
 
        if(t[1] > vipConf.vipMax) then
                doPlayerSendTextMessage(cid, 35, "[VIP SYSTEM]: You can only add a maximum of ".. vipConf.vipMax .." VIP days.")
                return true
        end
		
		pid = getPlayerByNameWildcard(t[2])

		if (getPlayerVipDays(pid) == vipConf.vipMax) then
		         doPlayerSendTextMessage(cid, 35, "[VIP SYSTEM]: "..t[2].." already has the max amount of VIP days allowed!")
				 return true
		end
		
		if ((t[1]+getPlayerVipDays(pid)) > vipConf.vipMax) then
		local maxAdd = (vipConf.vipMax-getPlayerVipDays(pid))
		local currentVip = getPlayerVipDays(pid)
		         doPlayerSendTextMessage(cid, 35, "[VIP SYSTEM]: You can only add a maximum of ".. maxAdd .." VIP days to " .. t[2] .. ", " .. t[2] .. " currently has "..currentVip..".")
				 return true
		end
		if(t[1] == 0) or (t[1] < 0) then
			doPlayerSendTextMessage(cid, 35, "[VIP SYSTEM]: You cant add a negative value of days.")
			return true
		end
 

 
    doAddVipDays(pid, t[1])
        if(t[1] > 1) then
    doPlayerSendTextMessage(cid,4, "[VIP SYSTEM]: You gave ".. t[1] .." VIP days to ".. t[2] .." .")
    doPlayerSendTextMessage(pid,18, "[VIP SYSTEM]: You have received ".. t[1] .." VIP days from a god.")    
        return true
	elseif(t[1] == 1) then
    doPlayerSendTextMessage(cid,4, "[VIP SYSTEM]: You gave ".. t[1] .." VIP day to ".. t[2] .." .")
    doPlayerSendTextMessage(pid,18, "[VIP SYSTEM]: You have received ".. t[1] .." VIP day from a god.")  
        return true
	end
end
]]></talkaction>
 
 
<globalevent name="VipDaysRemover" time="00:01" event="script"><![CDATA[
--- Script by Kekox
function onTime()
                 db.query("UPDATE 'accounts' SET 'vipdays' = 'vipdays' - 1 WHERE 'vipdays' > 0;")
        return true
end]]></globalevent>
 
<event type="login" name="TempleTeleporter" event="script"><![CDATA[
domodlib('vipsys-lib')
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
]]></event>
</mod>

It was a fun experience rewriting this system to mod and i can promise i will make more but i dont know if i will release them to the public at once.

- - - Updated - - -

I have updated the code a bit with more configuration options, grammar errors and locals to clean up the code a bit but I didn't have time to post it, will do when I'm back on.

- - - Updated - - -

New code posted
 
Last edited:
SQL Query:
PHP Code:
ALTER TABLE `accounts` ADD
`vipdays` int(11) NOT NULL DEFAULT 0;

where do i post that what folder. and sorry im new to this but i learn fast.
 
Didnt i post it in "Mods & Lua Functions" ??

- - - Updated - - -

SQL Query:
PHP Code:
ALTER TABLE `accounts` ADD
`vipdays` int(11) NOT NULL DEFAULT 0;

where do i post that what folder. and sorry im new to this but i learn fast.

In your TFS database with phpmyadmin :) check first post for clearance (updated it)
 
Last edited:
Removed "Vip Check", it caused players to be unable to login if the server had been on for a while. (the one that told you how many days you have left)
 
Alright I found the problem... the vip for the PHP that was given automatically sets VIP days as NULL<< = it obviously wont work. you have to change the default to none and the null to NO. (would be a good thing to know for people who are NEW to PHP
 
[08/02/2013 21:28:37] [Error - Action Interface]
[08/02/2013 21:28:37] buffer:eek:nUse
[08/02/2013 21:28:37] Description:
[08/02/2013 21:28:37] [string "--- Vip functions by Kekox..."]:13: attempt to call field 'query' (a nil value)
[08/02/2013 21:28:37] stack traceback:
[08/02/2013 21:28:37] [string "--- Vip functions by Kekox..."]:13: in function 'doAddVipDays'
[08/02/2013 21:28:37] [string "loadBuffer"]:9: in function <[string "loadBuffer"]:4>
???
 
Himii you gotta go into your database and set the VIP value to 0 as the default value the table they give you to add is stupid and makes it a NULL value.
 
when i use ID: 2112 game crashes but i get my VIP days. and it works geat.
But when ever i use it and if someone is close to me when i use it. they got the same crash.

Any ides whats wrong ?
 
when i use ID: 2112 game crashes but i get my VIP days. and it works geat.
But when ever i use it and if someone is close to me when i use it. they got the same crash.

Any ides whats wrong ?

What TFS version do you use?
Can you post the script of your VIP medal?

If you're using the same from the script above try to replace this line:
Code:
doCreatureSay(cid, "VIP",34)
with this:
Code:
doCreatureSay(cid, "VIP", TALKTYPE_MONSTER_SAY)
 
Use constant names instead of numbers for textmessages.
Code:
doPlayerSendTextMessage(cid, 17, "[VIP SYSTEM]: You have reached the maximum amount of VIP days allowed on your account.")
doCreatureSay(cid, "VIP", 34)
You can find them in data/lib/000-constant.lua.
Use a constant name that starts with MESSAGE_ for doPlayerSendTextMessage and TALKTYPE_MONSTER or TALKTYPE_MONSTER_SAY for doCreatureSay.
 
It's also possible that the item itself is making the bug. Probably not, but you would try using a different item if what they said doesn't work for you.
 
Back
Top