Ir para conteúdo

Featured Replies

Postado

Oiiii Boa Noite !!! , Gostaria de pedir a ajuda de vocês em um poblemas que eu estou tendo,

 

Adicionei recentemente esse Script Abaixo e consegui instalar tudo direitinho, ta rodando liso.. Mas Gostaria de implementar bonus nesse script

Exemplo:

Player Vip: 20% a + de XP

Player Vip: 1%   a + de ATK SPEED

 

abaixo todo o Script

 

[Fonte]

 

Sistema Vip

 

1° execute dentro da sua db

ALTER TABLE `accounts`
        ADD COLUMN `viplastday` int(10) NOT NULL DEFAULT 0 AFTER `lastday`,
        ADD COLUMN `vipdays` int(11) NOT NULL DEFAULT 0 AFTER `lastday`;

 

 

 

2º na pasta data/creaturescripts/scripts procure pelo arquivo login.lua e adicione na segunda linha, logo após o function onLogin(player) isso

player:loadVipData()
player:updateVipTime()

3° na pasta data\ crie um arquivo chamado vipsystem.lua e adicione o seguinte

local config = {
    -- true = player will be teleported to this position if Vip runs out
    -- false = player will not be teleported
    useTeleport = true,
    expirationPosition = Position(95, 114, 7),

    -- true = player will received the message you set
    -- false = player will not receive a message
    useMessage = true,
    expirationMessage = 'Your vip days ran out.',
    expirationMessageType = MESSAGE_STATUS_WARNING
}

if not VipData then
    VipData = { }
end

function Player.onRemoveVip(self)
    if config.useTeleport then
        self:teleportTo(config.expirationPosition)
        config.expirationPosition:sendMagicEffect(CONST_ME_TELEPORT)
    end

    if config.useMessage then
        self:sendTextMessage(config.expirationMessageType, config.expirationMessage)
    end
end

function Player.getVipDays(self)
    return VipData[self:getId()].days
end

function Player.getLastVipDay(self)
    return VipData[self:getId()].lastDay
end

function Player.isVip(self)
    return self:getVipDays() > 0
end

function Player.addInfiniteVip(self)
    local data = VipData[self:getId()]
    data.days = 0xFFFF
    data.lastDay = 0

    db.query(string.format('UPDATE `accounts` SET `vipdays` = %i, `viplastday` = %i WHERE `id` = %i;', 0xFFFF, 0, self:getAccountId()))
end

function Player.addVipDays(self, amount)
    local data = VipData[self:getId()]
    local amount = math.min(0xFFFE - data.days, amount)
    if amount > 0 then
        if data.days == 0 then
            local time = os.time()
            db.query(string.format('UPDATE `accounts` SET `vipdays` = `vipdays` + %i, `viplastday` = %i WHERE `id` = %i;', amount, time, self:getAccountId()))
            data.lastDay = time
        else
            db.query(string.format('UPDATE `accounts` SET `vipdays` = `vipdays` + %i WHERE `id` = %i;', amount, self:getAccountId()))
        end
        data.days = data.days + amount
    end

    return true
end

function Player.removeVipDays(self, amount)
    local data = VipData[self:getId()]
    if data.days == 0xFFFF then
        return false
    end

    local amount = math.min(data.days, amount)
    if amount > 0 then
        db.query(string.format('UPDATE `accounts` SET `vipdays` = `vipdays` - %i WHERE `id` = %i;', amount, self:getAccountId()))
        data.days = data.days - amount

        if data.days == 0 then
            self:onRemoveVip()
        end
    end

    return true
end

function Player.removeVip(self)
    local data = VipData[self:getId()]
    if data.days == 0 then
        return
    end

    data.days = 0
    data.lastDay = 0

    self:onRemoveVip()

    db.query(string.format('UPDATE `accounts` SET `vipdays` = 0, `viplastday` = 0 WHERE `id` = %i;', self:getAccountId()))
end

function Player.loadVipData(self)
    local resultId = db.storeQuery(string.format('SELECT `vipdays`, `viplastday` FROM `accounts` WHERE `id` = %i;', self:getAccountId()))
    if resultId then
        VipData[self:getId()] = {
            days = result.getDataInt(resultId, 'vipdays'),
            lastDay = result.getDataInt(resultId, 'viplastday')
        }

        result.free(resultId)
        return true
    end

    VipData[self:getId()] = { days = 0, lastDay = 0 }
    return false
end

function Player.updateVipTime(self)
    local save = false

    local data = VipData[self:getId()]
    local days, lastDay = data.days, data.lastDay
    local daysBefore = days
    if days == 0 or days == 0xFFFF then
        if lastDay ~= 0 then
            lastDay = 0
            save = true
        end
    elseif lastDay == 0 then
        lastDay = os.time()
        save = true
    else
        local time = os.time()
        local elapsedDays = math.floor((time - lastDay) / 86400)
        if elapsedDays > 0 then
            if elapsedDays >= days then
                days = 0
                lastDay = 0
            else
                days = days - elapsedDays
                lastDay = time - ((time - lastDay) % 86400)
            end
            save = true
        end
    end

    if save then
        if daysBefore > 0 and days == 0 then
            self:onRemoveVip()
        end

        db.query(string.format('UPDATE `accounts` SET `vipdays` = %i, `viplastday` = %i WHERE `id` = %i;', days, lastDay, self:getAccountId()))
        data.days = days
        data.lastDay = lastDay
    end
end

 

4° no arquivo global.lua adicione a seguinte linha

dofile('data/vipsystem.lua')

 

Talkaction !checkvip para todos os players

 

1° vá na pasta data/talkactions/scripts e crie um arquivo chamando checkvip.lua e adicione o seguinte

function onSay(cid, words, param)
    local player = Player(cid)

    local days = player:getVipDays()
    if days == 0 then
        player:sendCancelMessage('You do not have any vip days.')
    else
        player:sendCancelMessage(string.format('You have %s vip day%s left.', (days == 0xFFFF and 'infinite amount of' or days), (days == 1 and '' or 's')))
    end
    return false
end

2° e em data/talkactions/talkactions.xml adicione

 

<talkaction words="!checkvip" script="checkvip.lua"/>

 

Talkaction /vip para membros da staff

- /vip adddays, NomedoPlayer, 5
--> Adiciona 5 dias vip para o Player.
- /vip removedays, NomedoPlayer, 5
--> Remove 5 dias vip do Player.
- /vip remove, PlayerName
--> Remove todos os dias vip do Player.
- /vip check, NomedoPlayer
--> Checa quantos dias vip o Player tem.
- /vip addinfinite, NomedoPlayer
--> Adiciona tempo vip infinito para o Player.

 

Tiles VIP

 

1° em data/movements/movements.xml e adicione

<movevent event="StepIn" actionid="1500" script="viptiles.lua"/>
<movevent event="StepIn" actionid="1501" script="viptiles.lua"/>

2° em data/movements/script crie o arquivo viptiles.lua e adicione o seguinte

local vipPosition = Position(101, 116, 7)

function onStepIn(cid, item, position, fromPosition)
    local player = Player(cid)
    if not player then
        return true
    end

    if item.actionid == 1500 then
        if not player:isVip() then
            player:teleportTo(fromPosition)
            fromPosition:sendMagicEffect(CONST_ME_POFF)
            player:sendCancelMessage('You do not have any vip days.')
        end
    elseif item.actionid == 1501 then
        if player:isVip() then
            player:teleportTo(vipPosition)
            player:say('!* VIP *!', TALKTYPE_MONSTER_SAY)
            vipPosition:sendMagicEffect(CONST_ME_STUN)
        else
            player:teleportTo(fromPosition)
            player:sendCancelMessage('You do not have any vip days.')
            fromPosition:sendMagicEffect(CONST_ME_POFF)
        end
    end
    return true
end

Items que adicionam dias VIP

 

ItemId 10135 adiciona 10 dias vip.
ItemId 10134 adiciona 30 dias vip.
ItemId 10133 adiciona 90 dias vip.

 

 

1° em data/actions/actions.xml adicione

<action fromid="10133" toid="10135" script="vipitems.lua"/>

2° e em data/actions/scripts crie um arquivo chamado vipitems.lua e adicione o seguinte

local vipItems = {
   -- [itemid] = amount of vip days
    [10135] = 10,
    [10134] = 30,
    [10133] = 90
}

function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
    local player = Player(cid)
    local days = vipItems[item.itemid]
    player:addVipDays(days)
    player:say('!* YAY VIP! *!', TALKTYPE_MONSTER_SAY)
    player:getPosition():sendMagicEffect(CONST_ME_STUN)
    player:sendTextMessage(MESSAGE_INFO_DESCR, string.format('You received %s vip days.', days))
    Item(item.uid):remove(1)
    return true
end
Postado

Este tópico foi movido para a seção de Suporte Otserv.

Meu Curso sobre Programação para OTServer

Programando OTServer

 

Peça o seu script! Entre agora mesmo no grupo

Developing

 

Conteúdos:

Mostrar conteúdo oculto

 

Discord: Belmont#7352

Não esqueça do REP+ :)     

Postado
  • Autor
  Em 11/08/2021 em 22:13, Akun disse:

Oiiii Boa Noite !!! , Gostaria de pedir a ajuda de vocês em um poblemas que eu estou tendo,

 

Adicionei recentemente esse Script Abaixo e consegui instalar tudo direitinho, ta rodando liso.. Mas Gostaria de implementar bonus nesse script

Exemplo:

Player Vip: 20% a + de XP

Player Vip: 1%   a + de ATK SPEED

 

abaixo todo o Script

 

[Fonte]

 

Sistema Vip

 

1° execute dentro da sua db


ALTER TABLE `accounts`
        ADD COLUMN `viplastday` int(10) NOT NULL DEFAULT 0 AFTER `lastday`,
        ADD COLUMN `vipdays` int(11) NOT NULL DEFAULT 0 AFTER `lastday`;

 

 

 

2º na pasta data/creaturescripts/scripts procure pelo arquivo login.lua e adicione na segunda linha, logo após o function onLogin(player) isso


player:loadVipData()
player:updateVipTime()

3° na pasta data\ crie um arquivo chamado vipsystem.lua e adicione o seguinte


local config = {
    -- true = player will be teleported to this position if Vip runs out
    -- false = player will not be teleported
    useTeleport = true,
    expirationPosition = Position(95, 114, 7),

    -- true = player will received the message you set
    -- false = player will not receive a message
    useMessage = true,
    expirationMessage = 'Your vip days ran out.',
    expirationMessageType = MESSAGE_STATUS_WARNING
}

if not VipData then
    VipData = { }
end

function Player.onRemoveVip(self)
    if config.useTeleport then
        self:teleportTo(config.expirationPosition)
        config.expirationPosition:sendMagicEffect(CONST_ME_TELEPORT)
    end

    if config.useMessage then
        self:sendTextMessage(config.expirationMessageType, config.expirationMessage)
    end
end

function Player.getVipDays(self)
    return VipData[self:getId()].days
end

function Player.getLastVipDay(self)
    return VipData[self:getId()].lastDay
end

function Player.isVip(self)
    return self:getVipDays() > 0
end

function Player.addInfiniteVip(self)
    local data = VipData[self:getId()]
    data.days = 0xFFFF
    data.lastDay = 0

    db.query(string.format('UPDATE `accounts` SET `vipdays` = %i, `viplastday` = %i WHERE `id` = %i;', 0xFFFF, 0, self:getAccountId()))
end

function Player.addVipDays(self, amount)
    local data = VipData[self:getId()]
    local amount = math.min(0xFFFE - data.days, amount)
    if amount > 0 then
        if data.days == 0 then
            local time = os.time()
            db.query(string.format('UPDATE `accounts` SET `vipdays` = `vipdays` + %i, `viplastday` = %i WHERE `id` = %i;', amount, time, self:getAccountId()))
            data.lastDay = time
        else
            db.query(string.format('UPDATE `accounts` SET `vipdays` = `vipdays` + %i WHERE `id` = %i;', amount, self:getAccountId()))
        end
        data.days = data.days + amount
    end

    return true
end

function Player.removeVipDays(self, amount)
    local data = VipData[self:getId()]
    if data.days == 0xFFFF then
        return false
    end

    local amount = math.min(data.days, amount)
    if amount > 0 then
        db.query(string.format('UPDATE `accounts` SET `vipdays` = `vipdays` - %i WHERE `id` = %i;', amount, self:getAccountId()))
        data.days = data.days - amount

        if data.days == 0 then
            self:onRemoveVip()
        end
    end

    return true
end

function Player.removeVip(self)
    local data = VipData[self:getId()]
    if data.days == 0 then
        return
    end

    data.days = 0
    data.lastDay = 0

    self:onRemoveVip()

    db.query(string.format('UPDATE `accounts` SET `vipdays` = 0, `viplastday` = 0 WHERE `id` = %i;', self:getAccountId()))
end

function Player.loadVipData(self)
    local resultId = db.storeQuery(string.format('SELECT `vipdays`, `viplastday` FROM `accounts` WHERE `id` = %i;', self:getAccountId()))
    if resultId then
        VipData[self:getId()] = {
            days = result.getDataInt(resultId, 'vipdays'),
            lastDay = result.getDataInt(resultId, 'viplastday')
        }

        result.free(resultId)
        return true
    end

    VipData[self:getId()] = { days = 0, lastDay = 0 }
    return false
end

function Player.updateVipTime(self)
    local save = false

    local data = VipData[self:getId()]
    local days, lastDay = data.days, data.lastDay
    local daysBefore = days
    if days == 0 or days == 0xFFFF then
        if lastDay ~= 0 then
            lastDay = 0
            save = true
        end
    elseif lastDay == 0 then
        lastDay = os.time()
        save = true
    else
        local time = os.time()
        local elapsedDays = math.floor((time - lastDay) / 86400)
        if elapsedDays > 0 then
            if elapsedDays >= days then
                days = 0
                lastDay = 0
            else
                days = days - elapsedDays
                lastDay = time - ((time - lastDay) % 86400)
            end
            save = true
        end
    end

    if save then
        if daysBefore > 0 and days == 0 then
            self:onRemoveVip()
        end

        db.query(string.format('UPDATE `accounts` SET `vipdays` = %i, `viplastday` = %i WHERE `id` = %i;', days, lastDay, self:getAccountId()))
        data.days = days
        data.lastDay = lastDay
    end
end

 

4° no arquivo global.lua adicione a seguinte linha


dofile('data/vipsystem.lua')

 

Talkaction !checkvip para todos os players

 

1° vá na pasta data/talkactions/scripts e crie um arquivo chamando checkvip.lua e adicione o seguinte


function onSay(cid, words, param)
    local player = Player(cid)

    local days = player:getVipDays()
    if days == 0 then
        player:sendCancelMessage('You do not have any vip days.')
    else
        player:sendCancelMessage(string.format('You have %s vip day%s left.', (days == 0xFFFF and 'infinite amount of' or days), (days == 1 and '' or 's')))
    end
    return false
end

2° e em data/talkactions/talkactions.xml adicione

 


<talkaction words="!checkvip" script="checkvip.lua"/>

 

Talkaction /vip para membros da staff


- /vip adddays, NomedoPlayer, 5
--> Adiciona 5 dias vip para o Player.
- /vip removedays, NomedoPlayer, 5
--> Remove 5 dias vip do Player.
- /vip remove, PlayerName
--> Remove todos os dias vip do Player.
- /vip check, NomedoPlayer
--> Checa quantos dias vip o Player tem.
- /vip addinfinite, NomedoPlayer
--> Adiciona tempo vip infinito para o Player.

 

Tiles VIP

 

1° em data/movements/movements.xml e adicione


<movevent event="StepIn" actionid="1500" script="viptiles.lua"/>
<movevent event="StepIn" actionid="1501" script="viptiles.lua"/>

2° em data/movements/script crie o arquivo viptiles.lua e adicione o seguinte


local vipPosition = Position(101, 116, 7)

function onStepIn(cid, item, position, fromPosition)
    local player = Player(cid)
    if not player then
        return true
    end

    if item.actionid == 1500 then
        if not player:isVip() then
            player:teleportTo(fromPosition)
            fromPosition:sendMagicEffect(CONST_ME_POFF)
            player:sendCancelMessage('You do not have any vip days.')
        end
    elseif item.actionid == 1501 then
        if player:isVip() then
            player:teleportTo(vipPosition)
            player:say('!* VIP *!', TALKTYPE_MONSTER_SAY)
            vipPosition:sendMagicEffect(CONST_ME_STUN)
        else
            player:teleportTo(fromPosition)
            player:sendCancelMessage('You do not have any vip days.')
            fromPosition:sendMagicEffect(CONST_ME_POFF)
        end
    end
    return true
end

Items que adicionam dias VIP

 


ItemId 10135 adiciona 10 dias vip.
ItemId 10134 adiciona 30 dias vip.
ItemId 10133 adiciona 90 dias vip.

 

 

1° em data/actions/actions.xml adicione


<action fromid="10133" toid="10135" script="vipitems.lua"/>

2° e em data/actions/scripts crie um arquivo chamado vipitems.lua e adicione o seguinte


local vipItems = {
   -- [itemid] = amount of vip days
    [10135] = 10,
    [10134] = 30,
    [10133] = 90
}

function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
    local player = Player(cid)
    local days = vipItems[item.itemid]
    player:addVipDays(days)
    player:say('!* YAY VIP! *!', TALKTYPE_MONSTER_SAY)
    player:getPosition():sendMagicEffect(CONST_ME_STUN)
    player:sendTextMessage(MESSAGE_INFO_DESCR, string.format('You received %s vip days.', days))
    Item(item.uid):remove(1)
    return true
end

T_T

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo