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

Scroll Quest

nanduzenho

Member
Joined
Mar 21, 2021
Messages
187
Solutions
1
Reaction score
15
GitHub
nanduzenho
Good morning, i have this script that gives access to djins green and blue. However, the player can use both, but I wanted him to use only one. For example, if he already has Green, he won't be able to use Blue. Could someone help me?

Lua:
    local config = {
    [13275] = 13, --Blue Djinn scroll
    [13276] = 14, --Green Djinn scroll
    }
    function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    
    local scroll = config[item.itemid]
    if not scroll then
        return true
    end
    
    if scroll == 13 then
        --Blue Djinn scroll
        --Marid Faction (Blue Djinn)
        player:setStorageValue(Storage.DjinnWar.MaridFaction.Mission01, 2)
        player:setStorageValue(Storage.DjinnWar.MaridFaction.Mission02, 2)       
        player:setStorageValue(Storage.DjinnWar.MaridFaction.Mission03, 3)
        player:setStorageValue(Storage.DjinnWar.MaridFaction.DoorToEfreetTerritory, 1)
        player:setStorageValue(Storage.OrcKingGreeting, 1)
        player:setStorageValue(Storage.DjinnWar.MaridFaction.DoorToLamp, 1)
        player:setStorageValue(Storage.DjinnWar.ReceivedLamp, 1)
        player:addAchievement('Marid Ally')       
        player:addItem(2146, 3)
        player:addItem(2356, 1)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The Gods blessed you.. now you are one Marid Ally.")
    end
    
    if scroll == 14 then
        --Green Djinn scroll
        --Efreet Faction (Green Djinn)
        player:setStorageValue(Storage.DjinnWar.Faction.Efreet, 1)
        player:setStorageValue(Storage.DjinnWar.Faction.Greeting, 0)
        player:setStorageValue(Storage.DjinnWar.EfreetFaction.Start, 1)
        player:setStorageValue(Storage.DjinnWar.EfreetFaction.Mission01, 3)       
        player:setStorageValue(Storage.DjinnWar.EfreetFaction.Mission02, 3)
        player:setStorageValue(Storage.DjinnWar.EfreetFaction.Mission03, 3)
        player:setStorageValue(Storage.DjinnWar.EfreetFaction.DoorToMaridTerritory, 1)
        player:addAchievement('Efreet Ally')
        player:setStorageValue(Storage.DjinnWar.EfreetFaction.DoorToLamp, 1)
        player:setStorageValue(Storage.DjinnWar.ReceivedLamp, 1)
        player:addItem(2356, 1)       
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The Gods blessed you.. now you are one Efreet Ally.")
    end
    
        Item(item.uid):remove(1)
    return true
end
 
Solution
Lua:
local config = {
    [13275] = 13, --Blue Djinn scroll
    [13276] = 14, --Green Djinn scroll
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    
    local scroll = config[item.itemid]
    if not scroll then
        return true
    end
    
    -- Xikini's edit.
    if player:hasAchievement("Marid Ally") or player:hasAchievement("Efreet Ally") then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You have already chosen whom will be your ally. You cannot change your decision.")
        return true
    end
    
    if scroll == 13 then
        --Blue Djinn scroll
        --Marid Faction (Blue Djinn)
        player:setStorageValue(Storage.DjinnWar.MaridFaction.Mission01, 2)...
Lua:
local config = {
    [13275] = 13, --Blue Djinn scroll
    [13276] = 14, --Green Djinn scroll
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    
    local scroll = config[item.itemid]
    if not scroll then
        return true
    end
    
    -- Xikini's edit.
    if player:hasAchievement("Marid Ally") or player:hasAchievement("Efreet Ally") then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You have already chosen whom will be your ally. You cannot change your decision.")
        return true
    end
    
    if scroll == 13 then
        --Blue Djinn scroll
        --Marid Faction (Blue Djinn)
        player:setStorageValue(Storage.DjinnWar.MaridFaction.Mission01, 2)
        player:setStorageValue(Storage.DjinnWar.MaridFaction.Mission02, 2)       
        player:setStorageValue(Storage.DjinnWar.MaridFaction.Mission03, 3)
        player:setStorageValue(Storage.DjinnWar.MaridFaction.DoorToEfreetTerritory, 1)
        player:setStorageValue(Storage.OrcKingGreeting, 1)
        player:setStorageValue(Storage.DjinnWar.MaridFaction.DoorToLamp, 1)
        player:setStorageValue(Storage.DjinnWar.ReceivedLamp, 1)
        player:addAchievement('Marid Ally')       
        player:addItem(2146, 3)
        player:addItem(2356, 1)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The Gods blessed you.. now you are one Marid Ally.")
    end
    
    if scroll == 14 then
        --Green Djinn scroll
        --Efreet Faction (Green Djinn)
        player:setStorageValue(Storage.DjinnWar.Faction.Efreet, 1)
        player:setStorageValue(Storage.DjinnWar.Faction.Greeting, 0)
        player:setStorageValue(Storage.DjinnWar.EfreetFaction.Start, 1)
        player:setStorageValue(Storage.DjinnWar.EfreetFaction.Mission01, 3)       
        player:setStorageValue(Storage.DjinnWar.EfreetFaction.Mission02, 3)
        player:setStorageValue(Storage.DjinnWar.EfreetFaction.Mission03, 3)
        player:setStorageValue(Storage.DjinnWar.EfreetFaction.DoorToMaridTerritory, 1)
        player:addAchievement('Efreet Ally')
        player:setStorageValue(Storage.DjinnWar.EfreetFaction.DoorToLamp, 1)
        player:setStorageValue(Storage.DjinnWar.ReceivedLamp, 1)
        player:addItem(2356, 1)       
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The Gods blessed you.. now you are one Efreet Ally.")
    end
    
    Item(item.uid):remove(1)
    return true
end
 
Solution
Lua:
local config = {
    [13275] = 13, --Blue Djinn scroll
    [13276] = 14, --Green Djinn scroll
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
   
    local scroll = config[item.itemid]
    if not scroll then
        return true
    end
   
    -- Xikini's edit.
    if player:hasAchievement("Marid Ally") or player:hasAchievement("Efreet Ally") then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You have already chosen whom will be your ally. You cannot change your decision.")
        return true
    end
   
    if scroll == 13 then
        --Blue Djinn scroll
        --Marid Faction (Blue Djinn)
        player:setStorageValue(Storage.DjinnWar.MaridFaction.Mission01, 2)
        player:setStorageValue(Storage.DjinnWar.MaridFaction.Mission02, 2)      
        player:setStorageValue(Storage.DjinnWar.MaridFaction.Mission03, 3)
        player:setStorageValue(Storage.DjinnWar.MaridFaction.DoorToEfreetTerritory, 1)
        player:setStorageValue(Storage.OrcKingGreeting, 1)
        player:setStorageValue(Storage.DjinnWar.MaridFaction.DoorToLamp, 1)
        player:setStorageValue(Storage.DjinnWar.ReceivedLamp, 1)
        player:addAchievement('Marid Ally')      
        player:addItem(2146, 3)
        player:addItem(2356, 1)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The Gods blessed you.. now you are one Marid Ally.")
    end
   
    if scroll == 14 then
        --Green Djinn scroll
        --Efreet Faction (Green Djinn)
        player:setStorageValue(Storage.DjinnWar.Faction.Efreet, 1)
        player:setStorageValue(Storage.DjinnWar.Faction.Greeting, 0)
        player:setStorageValue(Storage.DjinnWar.EfreetFaction.Start, 1)
        player:setStorageValue(Storage.DjinnWar.EfreetFaction.Mission01, 3)      
        player:setStorageValue(Storage.DjinnWar.EfreetFaction.Mission02, 3)
        player:setStorageValue(Storage.DjinnWar.EfreetFaction.Mission03, 3)
        player:setStorageValue(Storage.DjinnWar.EfreetFaction.DoorToMaridTerritory, 1)
        player:addAchievement('Efreet Ally')
        player:setStorageValue(Storage.DjinnWar.EfreetFaction.DoorToLamp, 1)
        player:setStorageValue(Storage.DjinnWar.ReceivedLamp, 1)
        player:addItem(2356, 1)      
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The Gods blessed you.. now you are one Efreet Ally.")
    end
   
    Item(item.uid):remove(1)
    return true
end
Thank u broo!!!! It worked!!!
 
Back
Top