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

Vip System error

Inserindo as funções
Abra a pasta data/lib, crie um arquivo lua e coloque:
vipAccount.lua
Code:
--[[
        Name: Vip System by Account
        Version: 1.0
        Author: Kydrai
        Forum: http://www.xtibia.com/forum/topic/136543-vip-system-by-account-v10/
   
        [Functions]
                -- Install
                installVip()
           
                -- By Account
                doTeleportPlayersByAccount(acc, topos)
                getVipTimeByAccount(acc)
                setVipTimeByAccount(acc, time)
                getVipDaysByAccount(acc)
                isVipAccount(acc)
                addVipDaysByAccount(acc, days)
                doRemoveVipDaysByAccount(acc, days)
                getVipDateByAccount(acc)
           
                -- By Player
                doTeleportPlayers(cid, topos)
                getVipTime(cid)
                setVipTime(cid, time)
                getVipDays(cid)
                isVip(cid)
                addVipDays(cid, days)
                doRemoveVipDays(cid, days)
                getVipDate(cid)
]]--
-- Install
function installVip()
        if db.executeQuery("ALTER TABLE `accounts` ADD viptime INT(15) NOT NULL DEFAULT 0;") then
                print("[Vip System] Vip System instalado com sucesso!")
                return TRUE
        end
        print("[Vip System] Não foi possível instalar o Vip System!")
        return FALSEend
-- By Account
function doTeleportPlayersByAccount(acc, topos)
        if db.executeQuery("UPDATE `players` SET `posx` = "..topos.x..", `posy` = "..topos.y..", `posz` = "..topos.z.." WHERE `account_id` = "..acc..";") then
                return TRUE
        end
        return FALSEend
function getVipTimeByAccount(acc)
        local vip = db.getResult("SELECT `viptime` FROM `accounts` WHERE `id` = "..acc..";")
        if vip:getID() == -1 then
                print("[Vip System] Account not found!")
                return FALSE
        end
        return vip:getDataInt("viptime")
end
function setVipTimeByAccount(acc, time)
        if db.executeQuery("UPDATE `accounts` SET `viptime` = "..time.." WHERE `id` = "..acc..";") then
                return TRUE
        end
        return FALSEend
function getVipDaysByAccount(acc)
        local vipTime = getVipTimeByAccount(acc)
        local timeNow = os.time()
        local days = math.ceil((vipTime - timeNow)/(24 * 60 * 60))
        return days <= 0 and 0 or daysend
function isVipAccount(acc)
        return getVipDaysByAccount(acc) > 0 and TRUE or FALSEend
function addVipDaysByAccount(acc, days)
        if days > 0 then
                local daysValue = days * 24 * 60 * 60
                local vipTime = getVipTimeByAccount(acc)
                local timeNow = os.time()
                local time = getVipDaysByAccount(acc) == 0 and (timeNow + daysValue) or (vipTime + daysValue)
                setVipTimeByAccount(acc, time)
                return TRUE
        end
        return FALSEend
function doRemoveVipDaysByAccount(acc, days)
        if days > 0 then
                local daysValue = days * 24 * 60 * 60
                local vipTime = getVipTimeByAccount(acc)
                local time = vipTime - daysValue
                setVipTimeByAccount(acc, (time <= 0 and 1 or time))
                return TRUE
        end
        return FALSEend
function getVipDateByAccount(acc)
        if isVipAccount(acc) then
                local vipTime = getVipTimeByAccount(acc)
                return os.date("%d/%m/%y %X", vipTime)
        end
        return FALSEend
-- By Player
function doTeleportPlayers(cid, topos)
        doTeleportPlayersByAccount(getPlayerAccountId(cid), topos)
end
function getVipTime(cid)
        return getVipTimeByAccount(getPlayerAccountId(cid))
end
function setVipTime(cid, time)
        return setVipTimeByAccount(getPlayerAccountId(cid), time)
end
function getVipDays(cid)
        return getVipDaysByAccount(getPlayerAccountId(cid))
end
function isVip(cid)
        return isVipAccount(getPlayerAccountId(cid))
end
function addVipDays(cid, days)
        return addVipDaysByAccount(getPlayerAccountId(cid), days)
end
function doRemoveVipDays(cid, days)
        return doRemoveVipDaysByAccount(getPlayerAccountId(cid), days)
end
function getVipDate(cid)
        return getVipDateByAccount(getPlayerAccountId(cid))
end

Exemplos de uso
Talkaction

GOD:
/installvip
/addvip name, days
/removevip name, days
/checkvip name


Player:
/buyvip
/vipdays


talkactions.xml:
Code:
<talkactionlog="yes"access="5"words="/installvip;/addvip;/removevip;/checkvip"event="script"value="vipaccgod.lua"/><talkactionwords="/buyvip;/vipdays"event="script"value="vipaccplayer.lua"/>

vipaccgod.lua:
Code:
function onSay(cid, words, param, channel)local t = param:explode(",")local name, days = t[1], tonumber(t[2])if words =="/installvip"thenif installVip()then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"Vip System instalado com sucesso!")else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"Não foi possível instalar o Vip System!")end
elseif words =="/addvip"thenif name thenif days thenlocal acc = getAccountIdByName(name)if acc ~=0then
addVipDaysByAccount(acc, days)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"Você adicionou "..days.." dia(s) de vip ao "..name..", agora ele possui "..getVipDaysByAccount(acc).." dia(s) de vip.")else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"Este player não existe.")endelse
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"Você não pode adicionar essa quantidade de dia(s) de vip.")endelse
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"Você não pode adicionar dia(s) de vip a este player.")end
elseif words =="/removevip"thenif name thenif days thenlocal acc = getAccountIdByName(name)if acc ~=0then
doRemoveVipDaysByAccount(acc, days)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"Você retirou "..days.." dia(s) de vip do "..name..", agora ele possui "..getVipDaysByAccount(acc).." dia(s) de vip.")else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"Este player não existe.")endelse
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"Você não pode retirar essa quantidade de dia(s) de vip.")endelse
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"Você não pode retirar dia(s) de vip a este player.")end
elseif words =="/checkvip"thenif name thenlocal acc = getAccountIdByName(name)if acc ~=0thenlocal duration = getVipDateByAccount(acc)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"O "..name.." possui "..getVipDaysByAccount(acc).." dias de vip."..(duration and(" Ela irá durar até "..duration..".")or""))else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"Este player não existe.")endelse
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"Você não pode visualizar os dias de vip a este player.")endendreturnTRUEend
vipaccplayer.lua:
Code:
function onSay(cid, words, param, channel)if words =="/buyvip"thenlocal price =1000000local days =30if doPlayerRemoveMoney(cid, price)then
addVipDays(cid, days)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"Você adicionou "..days.." dia(s) de vip, agora você possui "..getVipDays(cid).." dia(s) de vip.")else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"Você precisa de "..price.." para adicionar "..days.." dia(s) de vip.")end

elseif words =="/vipdays"thenlocal duration = getVipDate(cid)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"Você possui "..getVipDays(cid).." dia(s) de vip."..(duration and(" Ela irá durar até "..duration..".")or""))endreturnTRUEend
Movement (Tile)

Coloque actionid 15000 em um tile onde somente os vips poderão passar.
movements.xml:

Code:
<moveventtype="StepIn"actionid="15000"event="script"value="viptile.lua"/>

viptile.lua:
function onStepIn(cid, item, position, fromPosition)if isVip(cid)== FALSE then
doTeleportThing(cid, fromPosition,false)
doSendMagicEffect(position, CONST_ME_MAGIC_BLUE)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"Somente players vip podem passar.")endreturnTRUEend

Creaturescript (Login)

Quando player logar irá verificar se a vip do player acabou, se sim então irá teleportar todos os players da account para o templo, se não irá mostrar o tempo da vip.

creaturescripts.xml:
<eventtype="login"name="viplogin"script="viplogin.lua"/>

viplogin.lua:

Code:
function onLogin(cid)
        local vip = isVip(cid)
        if getVipTime(cid) > 0  and vip == FALSE then
                local townid = 1
                doPlayerSetTown(cid, townid)
                local templePos = getTownTemplePosition(getPlayerTown(cid))
                doTeleportThing(cid, templePos, false)
                setVipTime(cid, 0)
                doTeleportPlayers(cid, templePos)
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sua Vip acabou!")
        elseif vip == TRUE then
                local duration = getVipDate(cid)
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você possui "..getVipDays(cid).." dia(s) de vip."..(duration and (" Ela irá durar até "..duration..".") or ""))
        end
        return TRUEend
 
Last edited:
Code:
--[[
        Name: Vip System by Account
        Version: 1.0
        Author: Kydrai
        Forum: http://www.xtibia.com/forum/topic/136543-vip-system-by-account-v10/
    
        [Functions]
                -- Install
                installVip()
            
                -- By Account
                doTeleportPlayersByAccount(acc, topos)
                getVipTimeByAccount(acc)
                setVipTimeByAccount(acc, time)
                getVipDaysByAccount(acc)
                isVipAccount(acc)
                addVipDaysByAccount(acc, days)
                doRemoveVipDaysByAccount(acc, days)
                getVipDateByAccount(acc)
            
                -- By Player
                doTeleportPlayers(cid, topos)
                getVipTime(cid)
                setVipTime(cid, time)
                getVipDays(cid)
                isVip(cid)
                addVipDays(cid, days)
                doRemoveVipDays(cid, days)
                getVipDate(cid)
]]--
-- Install
    function installVip()
        if db.executeQuery("ALTER TABLE `accounts` ADD viptime INT(15) NOT NULL DEFAULT 0;") then
                print("[Vip System] Vip System instalado com sucesso!")
                return TRUE
        end
        print("[Vip System] Não foi possível instalar o Vip System!")
        return FALSE
    end
-- By Account
    function doTeleportPlayersByAccount(acc, topos)
        if db.executeQuery("UPDATE `players` SET `posx` = "..topos.x..", `posy` = "..topos.y..", `posz` = "..topos.z.." WHERE `account_id` = "..acc..";") then
                return TRUE
        end
        return FALSE
    end
   
    function getVipTimeByAccount(acc)
        local vip = db.getResult("SELECT `viptime` FROM `accounts` WHERE `id` = "..acc..";")
        if vip:getID() == -1 then
                print("[Vip System] Account not found!")
                return FALSE
        end
        return vip:getDataInt("viptime")
    end
   
    function setVipTimeByAccount(acc, time)
        if db.executeQuery("UPDATE `accounts` SET `viptime` = "..time.." WHERE `id` = "..acc..";") then
                return TRUE
        end
        return FALSE
    end
   
    function getVipDaysByAccount(acc)
        local vipTime = getVipTimeByAccount(acc)
        local timeNow = os.time()
        local days = math.ceil((vipTime - timeNow)/(24 * 60 * 60))
        return days <= 0 and 0 or days
    end

    function isVipAccount(acc)
        return getVipDaysByAccount(acc) > 0 and TRUE or FALSE
    end
   
    function addVipDaysByAccount(acc, days)
        if days > 0 then
            local daysValue = days * 24 * 60 * 60
            local vipTime = getVipTimeByAccount(acc)
            local timeNow = os.time()
            local time = getVipDaysByAccount(acc) == 0 and (timeNow + daysValue) or (vipTime + daysValue)
            setVipTimeByAccount(acc, time)
            return TRUE
        end
        return FALSE
    end
   
    function doRemoveVipDaysByAccount(acc, days)
        if days > 0 then
            local daysValue = days * 24 * 60 * 60
            local vipTime = getVipTimeByAccount(acc)
            local time = vipTime - daysValue
            setVipTimeByAccount(acc, (time <= 0 and 1 or time))
            return TRUE
        end
        return FALSE
    end
   
    function getVipDateByAccount(acc)
        if isVipAccount(acc) then
            local vipTime = getVipTimeByAccount(acc)
            return os.date("%d/%m/%y %X", vipTime)
        end
        return FALSE
    end
-- By Player
    function doTeleportPlayers(cid, topos)
        doTeleportPlayersByAccount(getPlayerAccountId(cid), topos)
    end
   
    function getVipTime(cid)
        return getVipTimeByAccount(getPlayerAccountId(cid))
    end
   
    function setVipTime(cid, time)
        return setVipTimeByAccount(getPlayerAccountId(cid), time)
    end
   
    function getVipDays(cid)
        return getVipDaysByAccount(getPlayerAccountId(cid))
    end
   
    function isVip(cid)
        return isVipAccount(getPlayerAccountId(cid))
    end
   
    function addVipDays(cid, days)
        return addVipDaysByAccount(getPlayerAccountId(cid), days)
    end
   
    function doRemoveVipDays(cid, days)
        return doRemoveVipDaysByAccount(getPlayerAccountId(cid), days)
    end
   
    function getVipDate(cid)
        return getVipDateByAccount(getPlayerAccountId(cid))
    end
Code:
    function onLogin(cid)
        local vip = isVip(cid)
        if getVipTime(cid) > 0  and vip == FALSE then
            local townid = 1
            doPlayerSetTown(cid, townid)
            local templePos = getTownTemplePosition(getPlayerTown(cid))
            doTeleportThing(cid, templePos, false)
            setVipTime(cid, 0)
            doTeleportPlayers(cid, templePos)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sua Vip acabou!")
        elseif vip == TRUE then
            local duration = getVipDate(cid)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você possui "..getVipDays(cid).." dia(s) de vip."..(duration and (" Ela irá durar até "..duration..".") or ""))
        end
        return TRUE
    end
 
vipaccgod.lua is just retardedly written..
Anyway most of the code you provided is compact, this isn't javascript you can't squeeze code together and expect it to work, there needs to be spacing in between key words, functions and or containers..

If you don't understand what I am saying then use something less complicated, because this is over your head :p
 
but the problem is in viplogin.lua, no?

Vipaccgod.lua
Code:
function onSay(cid, words, param, channel)
        local t = param:explode(",")
        local name, days = t[1], tonumber(t[2])
        if words == "/installvip" then
                if installVip() then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Vip System instalado com sucesso!")
                else
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Não foi possível instalar o Vip System!")
                end
        elseif words == "/addvip" then
                if name then
                        if days then
                                local acc = getAccountIdByName(name)
                                if acc ~= 0 then
                                        addVipDaysByAccount(acc, days)
                                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você adicionou "..days.." dia(s) de vip ao "..name..", agora ele possui "..getVipDaysByAccount(acc).." dia(s) de vip.")
                                else
                                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Este player não existe.")
                                end
                        else
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você não pode adicionar essa quantidade de dia(s) de vip.")
                        end
                else
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você não pode adicionar dia(s) de vip a este player.")
                end
        elseif words == "/removevip" then
                if name then
                        if days then
                                local acc = getAccountIdByName(name)
                                if acc ~= 0 then
                                        doRemoveVipDaysByAccount(acc, days)
                                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você retirou "..days.." dia(s) de vip do "..name..", agora ele possui "..getVipDaysByAccount(acc).." dia(s) de vip.")
                                else
                                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Este player não existe.")
                                end
                        else
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você não pode retirar essa quantidade de dia(s) de vip.")
                        end
                else
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você não pode retirar dia(s) de vip a este player.")
                end
        elseif words == "/checkvip" then
                if name then
                        local acc = getAccountIdByName(name)
                        if acc ~= 0 then
                                local duration = getVipDateByAccount(acc)
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "O "..name.." possui "..getVipDaysByAccount(acc).." dias de vip."..(duration and (" Ela irá durar até "..duration..".") or ""))
                        else
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Este player não existe.")
                        end
                else
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você não pode visualizar os dias de vip a este player.")
                end
        end
        return TRUE
end
 
but the problem is in viplogin.lua, no?

Vipaccgod.lua
Code:
function onSay(cid, words, param, channel)
        local t = param:explode(",")
        local name, days = t[1], tonumber(t[2])
        if words == "/installvip" then
                if installVip() then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Vip System instalado com sucesso!")
                else
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Não foi possível instalar o Vip System!")
                end
        elseif words == "/addvip" then
                if name then
                        if days then
                                local acc = getAccountIdByName(name)
                                if acc ~= 0 then
                                        addVipDaysByAccount(acc, days)
                                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você adicionou "..days.." dia(s) de vip ao "..name..", agora ele possui "..getVipDaysByAccount(acc).." dia(s) de vip.")
                                else
                                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Este player não existe.")
                                end
                        else
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você não pode adicionar essa quantidade de dia(s) de vip.")
                        end
                else
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você não pode adicionar dia(s) de vip a este player.")
                end
        elseif words == "/removevip" then
                if name then
                        if days then
                                local acc = getAccountIdByName(name)
                                if acc ~= 0 then
                                        doRemoveVipDaysByAccount(acc, days)
                                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você retirou "..days.." dia(s) de vip do "..name..", agora ele possui "..getVipDaysByAccount(acc).." dia(s) de vip.")
                                else
                                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Este player não existe.")
                                end
                        else
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você não pode retirar essa quantidade de dia(s) de vip.")
                        end
                else
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você não pode retirar dia(s) de vip a este player.")
                end
        elseif words == "/checkvip" then
                if name then
                        local acc = getAccountIdByName(name)
                        if acc ~= 0 then
                                local duration = getVipDateByAccount(acc)
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "O "..name.." possui "..getVipDaysByAccount(acc).." dias de vip."..(duration and (" Ela irá durar até "..duration..".") or ""))
                        else
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Este player não existe.")
                        end
                else
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você não pode visualizar os dias de vip a este player.")
                end
        end
        return TRUE
end
You post this code originally in a quote and looks like shit and then post it formatted.. ignored forever!
 
Back
Top