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

[Request] Unlock x Quest access!

Mudrock

Member
Joined
Jan 25, 2017
Messages
102
Reaction score
19
Location
Minas Gerais - Brazil
How do I get everyone on the server to have x quest already completed on the server? Without affecting what he has already done or will do! I want some missions like those of inquisition already released!
 
Solution
based off of @Xikini 's code:
Code:
local freeQuests = {
   {storage = 11111, value = 1, questName = "X"},
   {storage = 22222, value = 17, questName = "Y"},
   {storage = 33333, value = 109, questName = "Z"},
   {storage = 44444, value = 2, questName = "XxX"}
}

function onLogin(player)
   for i = 1, #freeQuests do
      if player:getStorageValue(freeQuests[i].storage) ~= freeQuests[i].value then
          player:setStorageValue(freeQuests[i].storage, freeQuests[i].value)
          player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, freeQuests[i].questName .. " quest unlocked!")
      end
   end
   return true
end

xml:
Code:
<event type="login" name="free quests" script="script.lua"/>

in your default login.lua add "free...
find the storages for those quests and make a onLogin event.. like this or so.
(functions from memory.. don't quote me saying they are wrong. lol)

Code:
local storage = 45001 -- the quest storage value
local quest_state = 3 -- whatever quest state it says for "completed" for that far in the mission

function onLogin(cid)
    if getPlayerStorageValue(cid, storage) < quest_state then
        setPlayerStorageValue(cid, storage, quest_state)
    end
    return true
end

If you know the storage values cannot go backwards in numbers, then like this is fine.
If they can go backwards, then add an additional storage value.. or only allow the storage value change upon the first login of the character.
 
find the storages for those quests and make a onLogin event.. like this or so.
(functions from memory.. don't quote me saying they are wrong. lol)

Code:
local storage = 45001 -- the quest storage value
local quest_state = 3 -- whatever quest state it says for "completed" for that far in the mission

function onLogin(cid)
    if getPlayerStorageValue(cid, storage) < quest_state then
        setPlayerStorageValue(cid, storage, quest_state)
    end
    return true
end

If you know the storage values cannot go backwards in numbers, then like this is fine.
If they can go backwards, then add an additional storage value.. or only allow the storage value change upon the first login of the character.

Thanks for the help, but where do I actually have to add this code?
Sorry for the English, this translator is horrible.
 
data/creaturescripts/creaturescripts.xml
Also, register in login.lua at bottom (data/creaturescripts/scripts)

But make sure you actually change it to the correct storage values..
I just put random numbers
 
data/creaturescripts/creaturescripts.xml
Also, register in login.lua at bottom (data/creaturescripts/scripts)

But make sure you actually change it to the correct storage values..
I just put random numbers

If I wanted to add more than one quest I should for that?

-----------------------------------------------------------------------------------------------------------------------------------
local storage = 45001 -- the quest storage value
local quest_state = 3 -- whatever quest state it says for "completed" for that far in the mission

function onLogin(cid)
if getPlayerStorageValue(cid, storage) < quest_state then
setPlayerStorageValue(cid, storage, quest_state)
end
return true
end
-----------------------------------------------------------------------------------------------------------------------------------
local storage = 45001 -- the quest storage value
local quest_state = 3 -- whatever quest state it says for "completed" for that far in the mission

function onLogin(cid)
if getPlayerStorageValue(cid, storage) < quest_state then
setPlayerStorageValue(cid, storage, quest_state)
end
return true
end
-----------------------------------------------------------------------------------------------------------------------------------
 
If I wanted to add more than one quest I should for that?
Like this.
Note, this is scripting for 0.3.7
If using for 1.0+.. your compat file might allow it to run, but otherwise, replace the functions with the correct ones from your luascript.cpp

Code:
function onLogin(cid)
   if getPlayerStorageValue(cid, 11111) < 1 then
       setPlayerStorageValue(cid, 11111, 1)
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "X quest unlocked!")
   end
   if getPlayerStorageValue(cid, 22222) < 17 then
       setPlayerStorageValue(cid, 22222, 17)
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Y quest unlocked!")
   end
   if getPlayerStorageValue(cid, 33333) < 109 then
       setPlayerStorageValue(cid, 33333, 109)
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Z quest unlocked!")
   end
   if getPlayerStorageValue(cid, 44444) < 2 then
       setPlayerStorageValue(cid, 44444, 2)
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "XxX quest unlocked!")
   end
   return true
end
Or, make it fancier.
Code:
local free_quests = {
   [1] = {storage = 11111, value = 1, quest_name = "X"},
   [2] = {storage = 22222, value = 17, quest_name = "Y"},
   [3] = {storage = 33333, value = 109, quest_name = "Z"},
   [4] = {storage = 44444, value = 2, quest_name = "XxX"}
}

function onLogin(cid)
   for i = 1, #free_quests do
       if getPlayerStorageValue(cid, free_quests[i].storage) < free_quests[i].value then
           setPlayerStorageValue(cid, free_quests[i].storage, free_quests[i].value)
           doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "" .. free_quests[i].quest_name .. " quest unlocked!")
       end
   end
   return true
end
 
Like this.
Note, this is scripting for 0.3.7
If using for 1.0+.. your compat file might allow it to run, but otherwise, replace the functions with the correct ones from your luascript.cpp

Code:
function onLogin(cid)
   if getPlayerStorageValue(cid, 11111) < 1 then
       setPlayerStorageValue(cid, 11111, 1)
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "X quest unlocked!")
   end
   if getPlayerStorageValue(cid, 22222) < 17 then
       setPlayerStorageValue(cid, 22222, 17)
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Y quest unlocked!")
   end
   if getPlayerStorageValue(cid, 33333) < 109 then
       setPlayerStorageValue(cid, 33333, 109)
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Z quest unlocked!")
   end
   if getPlayerStorageValue(cid, 44444) < 2 then
       setPlayerStorageValue(cid, 44444, 2)
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "XxX quest unlocked!")
   end
   return true
end
Or, make it fancier.
Code:
local free_quests = {
   [1] = {storage = 11111, value = 1, quest_name = "X"},
   [2] = {storage = 22222, value = 17, quest_name = "Y"},
   [3] = {storage = 33333, value = 109, quest_name = "Z"},
   [4] = {storage = 44444, value = 2, quest_name = "XxX"}
}

function onLogin(cid)
   for i = 1, #free_quests do
       if getPlayerStorageValue(cid, free_quests[i].storage) < free_quests[i].value then
           setPlayerStorageValue(cid, free_quests[i].storage, free_quests[i].value)
           doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "" .. free_quests[i].quest_name .. " quest unlocked!")
       end
   end
   return true
end

I use a RLmap 10.99 server!

Login.lua: http://pastebin.com/raw/Czjitarf
 
based off of @Xikini 's code:
Code:
local freeQuests = {
   {storage = 11111, value = 1, questName = "X"},
   {storage = 22222, value = 17, questName = "Y"},
   {storage = 33333, value = 109, questName = "Z"},
   {storage = 44444, value = 2, questName = "XxX"}
}

function onLogin(player)
   for i = 1, #freeQuests do
      if player:getStorageValue(freeQuests[i].storage) ~= freeQuests[i].value then
          player:setStorageValue(freeQuests[i].storage, freeQuests[i].value)
          player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, freeQuests[i].questName .. " quest unlocked!")
      end
   end
   return true
end

xml:
Code:
<event type="login" name="free quests" script="script.lua"/>

in your default login.lua add "free quests" to your events array
 
Solution
based off of @Xikini 's code:
Code:
local freeQuests = {
   {storage = 11111, value = 1, questName = "X"},
   {storage = 22222, value = 17, questName = "Y"},
   {storage = 33333, value = 109, questName = "Z"},
   {storage = 44444, value = 2, questName = "XxX"}
}

function onLogin(player)
   for i = 1, #freeQuests do
      if player:getStorageValue(freeQuests[i].storage) ~= freeQuests[i].value then
          player:setStorageValue(freeQuests[i].storage, freeQuests[i].value)
          player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, freeQuests[i].questName .. " quest unlocked!")
      end
   end
   return true
end

xml:
Code:
<event type="login" name="free quests" script="script.lua"/>

in your default login.lua add "free quests" to your events array

Whenever the player has logged in does he win those storages? Or only those he does not have?
Not to get that annoying log message of quest log every time the player enters the server
 
Whenever the player has logged in does he win those storages? Or only those he does not have?
Not to get that annoying log message of quest log every time the player enters the server
it will only unlock it for the player if they haven't unlocked it already
 
This working on my server with tibia, i have this script in creatureevents but i update to tibia 12.4 and not working, anyone know why?
 
Back
Top