Mudrock
Member
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!
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
<event type="login" name="free quests" script="script.lua"/>
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
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.
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
Like this.If I wanted to add more than one quest I should for that?
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
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
Or, make it fancier.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
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
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
<event type="login" name="free quests" script="script.lua"/>
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
it will only unlock it for the player if they haven't unlocked it alreadyWhenever 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
test itDoes it work in 1.x? Because I use version 10.99!
If this is really functional I will love you in eternity.