• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Best VIP Re-edit

Itutorial

Legendary OT User
Joined
Dec 23, 2014
Messages
2,339
Solutions
68
Reaction score
1,024
I made this thread to make the VIP system easier to read. All credits to Kekox.
Even though the system has been made before.


Code:
ALTER TABLE `accounts` ADD
`vipdays` int(11) NOT NULL DEFAULT 0;
Now, go to data/lib/050-function.lua and add this lines in the top.
Code:
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
Code:
registerCreatureEvent(cid, "VipCheck")

And now in data/creaturescript/scripts create a new file and name it vipcheck.lua
Code:
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
data/globalevents/scripts
Code:
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").

!!!!OTHER SCRIPTS!!!!!

VIP Tile

data/movements/scripts/viptile.lua
Code:
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
Code:
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
Code:
--- 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
Code:
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
Code:
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
Code:
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
Code:
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/
Code:
<event type="login" name="TempleTeleporter" event="script" value="templeteleport.lua"/>
In /data/creaturescripts/scripts/login.lua add this line:
Code:
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.
 
Last edited:
IF you want VIP to only be for one player on each account just change to these functions

Code:
function getPlayerVipDays(cid)
local Info = db.getResult("SELECT `vipdays` FROM `players` 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 `players` SET `vipdays` = `vipdays` + " .. days .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end

function doRemoveVipDays(cid, days)
db.executeQuery("UPDATE `players` SET `vipdays` = `vipdays` - " .. days .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end

and execute this into your database instead of the other query.

Code:
ALTER TABLE `players` ADD
`vipdays` int(11) NOT NULL DEFAULT 0;
 
If anyone would like I can script some of these a little nicer and send them too you. Just pm me.
 
In all honesty this hole script can be used with storage values cutting out a lot of the coding hassle.
 
Back
Top