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

CreatureEvent Perfect Vip System 100%

LucasFerraz

Systems Analyst
Joined
Jun 10, 2010
Messages
2,858
Reaction score
96
Location
Brazil
I didn't made this, credits to Mock.

If you are using sqlite then
PHP:
ALTER TABLE `accounts` ADD `vip_time` INTEGER;
If you are using mysql then
PHP:
ALTER TABLE `accounts` ADD `vip_time` INT(15) NOT NULL

Lib
Create 049-vipsys.lua in data/lib
Lua:
vip = {
   name = "Vip system";
   author = "Mock";
   version = "1.0.0.0";
   query="ALTER TABLE `accounts` ADD `vip_time` INTEGER";
   query2="ALTER TABLE `accounts` ADD `vip_time` INT(15) NOT NULL"
}

function vip.setTable()
   dofile('config.lua')
   if sqlType == "sqlite" then
   	db.executeQuery(vip.query)
   else
        db.executeQuery(vip.query2)
   end
end

function vip.getVip(cid)
         assert(tonumber(cid),'Parameter must be a number') 
         if isPlayer(cid) == FALSE then error('Player don\'t find') end; 
         ae =  db.getResult("SELECT `vip_time` FROM `accounts` WHERE `name` = '"..getPlayerAccount(cid).."';")
         if ae:getID() == -1 then
            return 0
         end

local retee = ae:getDataInt("vip_time") or 0
ae:free()
         return retee
end

function vip.getVipByAcc(acc)
         assert(acc,'Account is nil')
         local a = db.getResult("SELECT `vip_time` FROM `accounts` WHERE `name` = '"..acc.."';")
         if a:getID() ~= -1 then
             return a:getDataInt("vip_time") or 0, a:free()
         else
             error('Account don\'t find.')
         end
end

function vip.setVip(cid,time)
         dofile("config.lua")
         assert(tonumber(cid),'Parameter must be a number')
         assert(tonumber(time),'Parameter must be a number')
         if isPlayer(cid) == FALSE then error('Player don\'t find') end; 
         db.executeQuery("UPDATE `"..sqlDatabase.."`.`accounts` SET `vip_time` = '"..(os.time()+time).."' WHERE `accounts`.`name` ='".. getPlayerAccount(cid).."';")
end

function vip.getVipByAccount(acc)
         assert(acc,'Account is nil')
         return db.getResult("SELECT `vip_time` FROM `accounts` WHERE `name` = '"..acc.."';"):getDataInt("vip_time") or 0
end                                      

function vip.hasVip(cid)
         assert(tonumber(cid),'Parameter must be a number')
         if isPlayer(cid) == FALSE then return end;
         local t = vip.getVip(cid) or 0
         if os.time(day) < t then
            return TRUE
         else
            return FALSE
         end
end

function vip.hasVips(cid)
         assert(tonumber(cid),'Parameter must be a number')
         if isPlayer(cid) == FALSE then return end;
         local t = vip.getVip(cid)
         if os.time(day) < t then
            return TRUE
         else
            return FALSE
         end
end

function vip.accountHasVip(acc)
         assert(acc,'Account is nil')
         if os.time() < vip.getVipByAccount(acc) then
            return TRUE
         else
            return FALSE
         end
end
function vip.getDays(days)
   return (3600 * 24 * days)
end

function vip.addVipByAccount(acc,time)
   assert(acc,'Account is nil')
   assert(tonumber(time),'Parameter must be a number')
   local a = vip.getVipByAcc(acc)
   a = os.difftime(a,os.time())
   if a < 0 then a = 0 end;
   a = a+time
   return vip.setVipByAccount(acc,a)
end

function vip.setVipByAccount(acc,time)
         dofile("config.lua")
         assert(acc,'Account is nil')
         assert(tonumber(time),'Parameter must be a number')
         db.executeQuery("UPDATE `accounts` SET `vip_time` = '"..(os.time()+time).."' WHERE `accounts`.`name` ='"..acc.."';")
         return TRUE
end

function vip.returnVipString(cid)
   assert(tonumber(cid),'Parameter must be a number')
   if isPlayer(cid) == TRUE then
      return os.date("%d %B %Y %X ", vip.getVip(cid))
   end
end


Talkactions
XML:
	<!-- VIP System -->
	<talkaction log="yes" words="/vip" access="6" event="script" value="VIP/addvipp.lua" />
	<talkaction words="!vipdays;/vipdays" event="script" value="VIP/vipdays.lua" />

vipdays.lua
Lua:
function onSay(cid, words, param)
         if vip.hasVip(cid) == TRUE then
            doPlayerSendTextMessage(cid, 22, "Your vip will end in "..os.date("%d %B %Y %X ",vip.getVip(cid)))
         else
             if vip.getVip(cid) ~= 0 then
                doPlayerSendTextMessage(cid, 22, "Your vip has finished in "..os.date("%d %B %Y %X ", vip.getVip(cid)).." and now is "..os.date("%d %B %Y %X ", os.time()))
             else
                doPlayerSendTextMessage(cid, 22, "You naver has a vip.")
             end
         end
         return TRUE
end

addvip.lua
Lua:
function onSay(cid, words, param)
         if param == "" then
            return  doPlayerPopupFYI(cid,"Está com problemas?\n Aprenda os comandos!\n---------------\nAdicionar vip:\n/vip add days player\n/vip add 30 Real\n---------------\nDeletar vip:\n/vip del player\n/vip del Real\n---------------\nVer a vip:\n/vip see player\n/vip see Real\n---------------\n")
         end
         if param:lower():find('add') == 1 and 3 then
            local _,_,id,name = param:lower():find('add (%d+) (.+)')
            name = name or ""
            id = tonumber(id or 1) or 1
            if tonumber(id) == nil or getPlayerByName(name) == false then
               return doPlayerSendTextMessage(cid,25,"Adicionar vip:\n/vip add days player\n/vip add 30 Real\n [Player: "..name.."]")
            end  
            if isPlayer(getPlayerByName(name)) == TRUE then
            vip.addVipByAccount(getPlayerAccount(getPlayerByName(name)) ,vip.getDays(id))

            doPlayerSendTextMessage(cid,25,"Foram adicionados "..tonumber(id).." dias de vip a "..name..".")
            doPlayerSendTextMessage(getPlayerByName(name),25,"You received "..tonumber(id).." days of VIP.")
         else
           doPlayerSendTextMessage(cid,25,name.." is not online or do not exist.")
         end
         elseif param:lower():find('del') == 1 and 3 then
            local _,_,name = param:lower():find('del (.+)')
            if getPlayerByName(name) == false then
               return doPlayerSendTextMessage(cid,25,"Deletar vip:\n/vip del player\n/vip del Real\n")
            end

            vip.setVipByAccount(getPlayerAccount(getPlayerByName(name)),-os.time())
            doPlayerSendTextMessage(cid,25,"The VIP of "..name.." was successfully removed.")                                                                                                                                               
         elseif param:lower():find('see') == 1 and 3 then
            local _,_,name = param:lower():find('see (.+)')
            name = name or ""
            if getPlayerByName(name) == false then
               return doPlayerSendTextMessage(cid,25,"See the vip:\n/vip see player\n/vip see Real\n")
            end
            local ret_ = vip.getVip(getPlayerByName(name))
            if ret_ == 0 then
              return doPlayerSendTextMessage(cid, 25,name.." has not VIP and never had.")
            else
              return doPlayerSendTextMessage(cid, 25, "The VIP of "..name.." finish/finished in "..os.date("%d %B %Y %X ",ret_))
            end
         end
         return TRUE
end


Movements
Viptile(tp or stairs)
Lua:
function onStepIn(cid, item, position, fromPosition)

local tileConfig = {
	kickPos = fromPosition, kickEffect = CONST_ME_POFF,
	kickMsg = "You need to be a vip player to access this area.",
	enterMsg = "Welcome to area VIP",
	enterEffect = CONST_ME_MAGIC_RED,
}
if isPlayer(cid) == true then   
if vip.hasVip(cid) == FALSE then 
        doTeleportThing(cid, tileConfig.kickPos)
        doSendMagicEffect(tileConfig.kickPos, tileConfig.kickEffect)
        doPlayerSendCancel(cid, tileConfig.kickMsg)
        return
    end
 
        doPlayerSendTextMessage(cid, 22, tileConfig.enterMsg)
        doSendMagicEffect(position, tileConfig.enterEffect)
        return true
end
end


Creaturescript
XML:
<event type="login" name="VipFim" event="script" value="VipFim.lua"/>
VipFim.lua
Lua:
function onLogin(cid)
	if vip.hasVip(cid) == true then
		setPlayerStorageValue(cid, 20500, 1)
	elseif vip.hasVip(cid) == false and getPlayerStorageValue(cid, 20500) == 1 then
		doTeleportThing(cid, getPlayerMasterPos(cid))	
		db.executeQuery("UPDATE `accounts` SET `vip_time` = 0 WHERE `id` = ".. getAccountIdByName(getPlayerName(cid)) ..";")
                doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Your VIP has expired. The gods has therefore transported you to safety in Carlin.")	
		setPlayerStorageValue(cid, 20500, -1)
		setPlayerPromotionLevel(cid,1)
	end
	return true
end

Extra
You can also use this talkaction.
How it work: If VIP_PLAYER are in correct x.y.z position he can be teleported.
Lua:
function onSay(cid, words, param, channel)
        if getCreaturePosition(cid, { x = 500, y = 500, z = 7}) == TRUE then --where he must be
		doTeleportThing(cid, { x = 900, y = 900, z = 7 }, true) -- where he will go
                doSendMagicEffect(getCreaturePosition(cid),10)
	else
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
		doPlayerSendCancel(cid, "You aren\'t in right position to teleport.") -- fail msg
        end    
        return TRUE
end

If your website do not add Vip_Time you can use an item
Lua:
local days = 15

function onUse(cid, item, itemEx)
	local name = getCreatureName(cid)
		vip.addVipByAccount(getPlayerAccount(getPlayerByName(name)) ,vip.getDays(days))
		doCreatureSay(cid,"You received "..days.." days of VIP.", TALKTYPE_ORANGE_1)
		doRemoveItem(item.uid, 1)
       return TRUE
end
 
Last edited:
i have add this. exept the event cus it dont work for me. dont have "event" have globalevent. btw.. my problem is taht i have vip on home page but when i say /vip i dont have ip and i cant use my vip runes cus i dont haev vip know how to fix?
 
i have add this. exept the event cus it dont work for me. dont have "event" have globalevent. btw.. my problem is taht i have vip on home page but when i say /vip i dont have ip and i cant use my vip runes cus i dont haev vip know how to fix?

what
 
If you are using sqlite then
PHP:
ALTER TABLE `accounts` ADD `vip_time` INTEGER;
If you are using mysql then
PHP:
ALTER TABLE `accounts` ADD `vip_time` INT(15) NOT NULL
 
I try adding the query but this message comes up

Code:
You have to choose at least one column to display

Can you help me please? my msn is [email protected]
 
Last edited:
Fixed***


Sorryto trouble you through it, but i thought it was just easier to delete xammp and install a older version and i got it working.
 
Last edited:
excellent script, i put this script in my server work 100%. thanks! how i can give a free time period VIP?
 
Lua:
local viptasteconfig = {
level = 100,
days = 1,
storage = 20503,
msg = "You received a VIP day as a tasting.",
msgtype = MESSAGE_EVENT_ADVANCE
}
local function freevip(cid)
	if (getPlayerStorageValue(cid, viptasteconfig.storage) == -1) and (getPlayerLevel(cid) >= viptasteconfig.level) then
		setPlayerStorageValue(cid, viptasteconfig.storage, 1)
		vip.addVipByAccount(getPlayerAccount(cid), vip.getDays(viptasteconfig.days))
		doPlayerSendTextMessage(cid, viptasteconfig.msgtype, viptasteconfig.msg)
	end
end
 
Excellent bro thank very much

Lua:
local viptasteconfig = {
level = 100,
days = 1,
storage = 20503,
msg = "You received a VIP day as a tasting.",
msgtype = MESSAGE_EVENT_ADVANCE
}
local function freevip(cid)
	if (getPlayerStorageValue(cid, viptasteconfig.storage) == -1) and (getPlayerLevel(cid) >= viptasteconfig.level) then
		setPlayerStorageValue(cid, viptasteconfig.storage, 1)
		vip.addVipByAccount(getPlayerAccount(cid), vip.getDays(viptasteconfig.days))
		doPlayerSendTextMessage(cid, viptasteconfig.msgtype, viptasteconfig.msg)
	end
end
 
Bro i have a proble with my action.

I put your code in vipitem.lua

Lua:
local viptasteconfig = {
	level = 1,
	days = 3,
	storage = 20503,
	msg = "You received three VIP day.",
	msgtype = MESSAGE_EVENT_ADVANCE
}
function onUse(cid, item)
	if (getPlayerStorageValue(cid, viptasteconfig.storage) == -1) and (getPlayerLevel(cid) >= viptasteconfig.level) then
		setPlayerStorageValue(cid, viptasteconfig.storage, 1)
		vip.addVipByAccount(getPlayerAccount(cid), vip.getDays(viptasteconfig.days))
		doPlayerSendTextMessage(cid, viptasteconfig.msgtype, viptasteconfig.msg)
		doRemoveItem(item.uid)
	else
		doPlayerSendTextMessage(cid, viptasteconfig.msgtype, getPlayerStorageValue(cid, viptasteconfig.storage))
	end
end

It works fine the first time used, but then when the player wants to use it again the item does not work.



Lua:
local viptasteconfig = {
level = 100,
days = 1,
storage = 20503,
msg = "You received a VIP day as a tasting.",
msgtype = MESSAGE_EVENT_ADVANCE
}
local function freevip(cid)
	if (getPlayerStorageValue(cid, viptasteconfig.storage) == -1) and (getPlayerLevel(cid) >= viptasteconfig.level) then
		setPlayerStorageValue(cid, viptasteconfig.storage, 1)
		vip.addVipByAccount(getPlayerAccount(cid), vip.getDays(viptasteconfig.days))
		doPlayerSendTextMessage(cid, viptasteconfig.msgtype, viptasteconfig.msg)
	end
end
 
Lua:
local viptasteconfig = {
	level = 1,
	days = 3,
	storage = 20503,
	msg = "You received three VIP day.",
	msgtype = MESSAGE_EVENT_ADVANCE
}
function onUse(cid, item)
	if (getPlayerLevel(cid) >= viptasteconfig.level) then
		setPlayerStorageValue(cid, viptasteconfig.storage, 1)
		vip.addVipByAccount(getPlayerAccount(cid), vip.getDays(viptasteconfig.days))
		doPlayerSendTextMessage(cid, viptasteconfig.msgtype, viptasteconfig.msg)
		doRemoveItem(item.uid)
	else
		doPlayerSendTextMessage(cid, viptasteconfig.msgtype, getPlayerStorageValue(cid, viptasteconfig.storage))
	end
end
 
Movements
Viptile(tp or stairs)
Lua Code:
function onStepIn(cid, item, position, fromPosition)

local tileConfig = {
kickPos = fromPosition, kickEffect = CONST_ME_POFF,
kickMsg = "You need to be a vip player to access this area.",
enterMsg = "Welcome to area VIP",
enterEffect = CONST_ME_MAGIC_RED,
}
if isPlayer(cid) == true then
if vip.hasVip(cid) == FALSE then
doTeleportThing(cid, tileConfig.kickPos)
doSendMagicEffect(tileConfig.kickPos, tileConfig.kickEffect)
doPlayerSendCancel(cid, tileConfig.kickMsg)
return
end

doPlayerSendTextMessage(cid, 22, tileConfig.enterMsg)
doSendMagicEffect(position, tileConfig.enterEffect)
return true
end
end

were to put that??
 
1. "You cannot executre this talkaction" when I'm trying to add vip.(/vip add days playername)
2. How I'm making vip tp/stairs?
3. about the Extra, i have to make a new .lua file(whats name is so) or enter it to one of them(also what's his name if so).

Sorry for the stuped questions.. hard to be a newbie :D
 
Last edited:
Back
Top