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

Erro Script Premium End go Temple

nanduzenho

Member
Joined
Mar 21, 2021
Messages
190
Solutions
1
Reaction score
16
GitHub
nanduzenho
Good morning, I'm having a problem again in this script where when a prize runs out the char goes back to the temple. It turns out that when I create a new char, either in rook or in main (in other cities) the char always starts in the temple where the script is programmed with the warning that the premium ended. And when the character in rook finishes the premium he goes to main. Can someone fix this for me?

Lua:
local premiumResetStorage = 45055
local TOWN_ID = 2

function onLogin(cid)
    local player = Player(cid)
 
    local resultId = db.storeQuery("SELECT `premdays` FROM `accounts` WHERE `id` = " .. player:getAccountId())

    local premDays = false
    if resultId ~= false then
        premDays = result.getNumber(resultId, "premdays")
        result.free(resultId)
    end

    -- no premium
    if premDays and premDays < 1 then
        -- if player's town has not been reset
        if player:getStorageValue(premiumResetStorage) ~= 1 then
            local town = Town(TOWN_ID)
            player:setTown(town)
           
            local templePosition = town:getTemplePosition()
            player:teleportTo(templePosition)
            templePosition:sendMagicEffect(CONST_ME_TELEPORT)
   
            player:setStorageValue(premiumResetStorage, 1)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Sua premium acabou!")
        end
       
    -- has premium
    elseif premDays and premDays > 0 then
        if player:getStorageValue(premiumResetStorage) ~= -1 then
            player:setStorageValue(premiumResetStorage, -1)
        end
    end

    return true
end
 
Last edited:
Good morning, I'm having a problem again in this script where when a prize runs out the char goes back to the temple. It turns out that when I create a new char, either in rook or in main (in other cities) the char always starts in the temple where the script is programmed with the warning that the premium ended. And when the character in rook finishes the premium he goes to main. Can someone fix this for me?

Lua:
local premiumResetStorage = 45055
local TOWN_ID = 2

function onLogin(cid)
    local player = Player(cid)
 
    local resultId = db.storeQuery("SELECT `premdays` FROM `accounts` WHERE `id` = " .. player:getAccountId())

    local premDays = false
    if resultId ~= false then
        premDays = result.getNumber(resultId, "premdays")
        result.free(resultId)
    end

    -- no premium
    if premDays and premDays < 1 then
        -- if player's town has not been reset
        if player:getStorageValue(premiumResetStorage) ~= 1 then
            local town = Town(TOWN_ID)
            player:setTown(town)
          
            local templePosition = town:getTemplePosition()
            player:teleportTo(templePosition)
            templePosition:sendMagicEffect(CONST_ME_TELEPORT)
  
            player:setStorageValue(premiumResetStorage, 1)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Sua premium acabou!")
        end
      
    -- has premium
    elseif premDays and premDays > 0 then
        if player:getStorageValue(premiumResetStorage) ~= -1 then
            player:setStorageValue(premiumResetStorage, -1)
        end
    end

    return true
end

If they are vocation 0, they will be sent to rookgaard temple.
If they are any other vocation, they will be sent to normal town.

If it's a brand-new player, no action is taken.

Lua:
local premiumResetStorage = 45055
local TOWN_ID = 2
local ROOK_TOWN_ID = ??

function onLogin(cid)
    local player = Player(cid)
 
    local resultId = db.storeQuery("SELECT `premdays` FROM `accounts` WHERE `id` = " .. player:getAccountId())

    local premDays = false
    if resultId ~= false then
        premDays = result.getNumber(resultId, "premdays")
        result.free(resultId)
    end

    local currentStorageValue = player:getStorageValue(premiumResetStorage)
    
    -- no premium
    if premDays and premDays < 1 then
        -- if player's town has not been reset
        if currentStorageValue ~= 1 then
            -- if a new player, don't reset town
            if currentStorageValue == -1 then
                player:setStorageValue(premiumResetStorage, 1)
            end
            
            -- otherwise reset town
            local town = Town(player:getVocation():getId() == 0 and ROOK_TOWN_ID or TOWN_ID) -- if vocation is 0 (rookgaardian) use rook town, otherwise use normal town
            player:setTown(town)
           
            local templePosition = town:getTemplePosition()
            player:teleportTo(templePosition)
            templePosition:sendMagicEffect(CONST_ME_TELEPORT)
   
            player:setStorageValue(premiumResetStorage, 1)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Sua premium acabou!")
        end
       
    -- has premium
    elseif premDays and premDays > 0 then
        if currentStorageValue ~= 0 then
            player:setStorageValue(premiumResetStorage, 0)
        end
    end

    return true
end
 
If they are vocation 0, they will be sent to rookgaard temple.
If they are any other vocation, they will be sent to normal town.

If it's a brand-new player, no action is taken.

Lua:
local premiumResetStorage = 45055
local TOWN_ID = 2
local ROOK_TOWN_ID = ??

function onLogin(cid)
    local player = Player(cid)
 
    local resultId = db.storeQuery("SELECT `premdays` FROM `accounts` WHERE `id` = " .. player:getAccountId())

    local premDays = false
    if resultId ~= false then
        premDays = result.getNumber(resultId, "premdays")
        result.free(resultId)
    end

    local currentStorageValue = player:getStorageValue(premiumResetStorage)
   
    -- no premium
    if premDays and premDays < 1 then
        -- if player's town has not been reset
        if currentStorageValue ~= 1 then
            -- if a new player, don't reset town
            if currentStorageValue == -1 then
                player:setStorageValue(premiumResetStorage, 1)
            end
           
            -- otherwise reset town
            local town = Town(player:getVocation():getId() == 0 and ROOK_TOWN_ID or TOWN_ID) -- if vocation is 0 (rookgaardian) use rook town, otherwise use normal town
            player:setTown(town)
          
            local templePosition = town:getTemplePosition()
            player:teleportTo(templePosition)
            templePosition:sendMagicEffect(CONST_ME_TELEPORT)
  
            player:setStorageValue(premiumResetStorage, 1)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Sua premium acabou!")
        end
      
    -- has premium
    elseif premDays and premDays > 0 then
        if currentStorageValue ~= 0 then
            player:setStorageValue(premiumResetStorage, 0)
        end
    end

    return true
end

I will test thank you very much!!!
Post automatically merged:

If they are vocation 0, they will be sent to rookgaard temple.
If they are any other vocation, they will be sent to normal town.

If it's a brand-new player, no action is taken.

Lua:
local premiumResetStorage = 45055
local TOWN_ID = 2
local ROOK_TOWN_ID = ??

function onLogin(cid)
    local player = Player(cid)
 
    local resultId = db.storeQuery("SELECT `premdays` FROM `accounts` WHERE `id` = " .. player:getAccountId())

    local premDays = false
    if resultId ~= false then
        premDays = result.getNumber(resultId, "premdays")
        result.free(resultId)
    end

    local currentStorageValue = player:getStorageValue(premiumResetStorage)
   
    -- no premium
    if premDays and premDays < 1 then
        -- if player's town has not been reset
        if currentStorageValue ~= 1 then
            -- if a new player, don't reset town
            if currentStorageValue == -1 then
                player:setStorageValue(premiumResetStorage, 1)
            end
           
            -- otherwise reset town
            local town = Town(player:getVocation():getId() == 0 and ROOK_TOWN_ID or TOWN_ID) -- if vocation is 0 (rookgaardian) use rook town, otherwise use normal town
            player:setTown(town)
          
            local templePosition = town:getTemplePosition()
            player:teleportTo(templePosition)
            templePosition:sendMagicEffect(CONST_ME_TELEPORT)
  
            player:setStorageValue(premiumResetStorage, 1)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Sua premium acabou!")
        end
      
    -- has premium
    elseif premDays and premDays > 0 then
        if currentStorageValue ~= 0 then
            player:setStorageValue(premiumResetStorage, 0)
        end
    end

    return true
end
can I enjoy and ask you to do the same with this blessing script? Only player from level 8 to 20 gain blessing...

Lua:
local freeBlessMaxLevel = 20

function onLogin(cid)
    local player = Player(cid)
    if player:getLevel() <= freeBlessMaxLevel then
        for i = 1, 8 do
            if not player:hasBlessing(i) then
                player:addBlessing(i, 1)
            end
        end
        
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE,'You received adventurers blessings for you to be level less than ' .. freeBlessMaxLevel .. '!')
        player:getPosition():sendMagicEffect(CONST_ME_HOLYDAMAGE)
    end
    return true
end
 
Last edited:
I will test thank you very much!!!
Post automatically merged:


can I enjoy and ask you to do the same with this blessing script? Only player from level 8 to 20 gain blessing...

Lua:
local freeBlessMaxLevel = 20

function onLogin(cid)
    local player = Player(cid)
    if player:getLevel() <= freeBlessMaxLevel then
        for i = 1, 8 do
            if not player:hasBlessing(i) then
                player:addBlessing(i, 1)
            end
        end
       
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE,'You received adventurers blessings for you to be level less than ' .. freeBlessMaxLevel .. '!')
        player:getPosition():sendMagicEffect(CONST_ME_HOLYDAMAGE)
    end
    return true
end
To be more specific, is it the level issue, or that you don't want rookgaardians to have free bless?
 
Yes rook without a bless
Lua:
local freeBlessMaxLevel = 20

function onLogin(cid)
    local player = Player(cid)
    if player:getVocation():getId() == 0 then
        return true
    end
    if player:getLevel() > freeBlessMaxLevel then
        return true
    end
    
    for i = 1, 8 do
        if not player:hasBlessing(i) then
            player:addBlessing(i, 1)
        end
    end    
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received free adventurer blessings because your level is under " .. freeBlessMaxLevel + 1 .. "!")
    player:getPosition():sendMagicEffect(CONST_ME_HOLYDAMAGE)
    return true
end
 
Lua:
local freeBlessMaxLevel = 20

function onLogin(cid)
    local player = Player(cid)
    if player:getVocation():getId() == 0 then
        return true
    end
    if player:getLevel() > freeBlessMaxLevel then
        return true
    end
   
    for i = 1, 8 do
        if not player:hasBlessing(i) then
            player:addBlessing(i, 1)
        end
    end   
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received free adventurer blessings because your level is under " .. freeBlessMaxLevel + 1 .. "!")
    player:getPosition():sendMagicEffect(CONST_ME_HOLYDAMAGE)
    return true
end
thx bro you are very good =D
 
If they are vocation 0, they will be sent to rookgaard temple.
If they are any other vocation, they will be sent to normal town.

If it's a brand-new player, no action is taken.

Lua:
local premiumResetStorage = 45055
local TOWN_ID = 2
local ROOK_TOWN_ID = ??

function onLogin(cid)
    local player = Player(cid)
 
    local resultId = db.storeQuery("SELECT [ICODE]premdays[/ICODE] FROM [ICODE]accounts[/ICODE] WHERE [ICODE]id[/ICODE] = " .. player:getAccountId())

    local premDays = false
    if resultId ~= false then
        premDays = result.getNumber(resultId, "premdays")
        result.free(resultId)
    end

    local currentStorageValue = player:getStorageValue(premiumResetStorage)
   
    -- no premium
    if premDays and premDays < 1 then
        -- if player's town has not been reset
        if currentStorageValue ~= 1 then
            -- si es un jugador nuevo, no reinicie la ciudad
            si currentStorageValue == -1 entonces
                reproductor:setStorageValue(premiumResetStorage, 1)
            final
           
            -- de lo contrario reinicia la ciudad
            ciudad local = Ciudad(jugador:getVocation():getId() == 0 and ROOK_TOWN_ID o TOWN_ID) -- si la vocación es 0 (rookgaardian) use rook town, de lo contrario use normal town
            jugador:setTown(ciudad)
          
            posición del templo local = ciudad: obtener posición del templo ()
            jugador: teletransportarse a (posición del templo)
            posición del templo: enviar efecto mágico (CONST_ME_TELEPORT)
  
            reproductor:setStorageValue(premiumResetStorage, 1)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "¡Sua premium acabou!")
        final
      
    -- tiene prima
    elseif premDays y premDays > 0 entonces
        si currentStorageValue ~= 0 entonces
            reproductor:setStorageValue(premiumResetStorage, 0)
        final
    final

    volver verdadero
fin[/codigo]
[/QUOTE]
Compatible con canary 1286????
 
Back
Top