OTcreator
Active Member
- Joined
- Feb 14, 2022
- Messages
- 425
- Solutions
- 1
- Reaction score
- 44
Hi,
I have a problem with this script.
Namely, after 6 o'clock the shuffle does not change.
If someone chooses Easy and has, for example, rotworms, the next day he will still have the same monster.
I noticed , that it should be given randomly, but before math.random there is a # sign - what does it deselect?
NPC used this code and working, but not math random monsters:
The only # sign that I have yet noticed is in this function:
Link with full code system: DailyTask ~100% (https://otland.net/threads/dailytask-100.272589/#post-2638428)
This probably only works if the server is restarted, but I'm not sure.
If you don't do a server restart, the monsters are not drawn.
Since I don't shut down the server every 24/h, I removed those lines and added in globalevents resetting storage for online players and removing storages from the database for offline players.
This all works, but there is one single problem with the monster draw.
I have a problem with this script.
Namely, after 6 o'clock the shuffle does not change.
If someone chooses Easy and has, for example, rotworms, the next day he will still have the same monster.
I noticed , that it should be given randomly, but before math.random there is a # sign - what does it deselect?
Lua:
DT_CHOSENTASK_EASY = DT_TasksEasy[math.random(#DT_TasksEasy)]
NPC used this code and working, but not math random monsters:
Lua:
if DT_PREMIOQTDE_EASY > 0 then
npcHandler:say("Your EASY daily task today is: Kill {".. DT_NEEDKILL_EASY .."} {".. DT_CHOSENTASK_EASY .."}(s).\nIf you finish before {6:00am (GTM-3)}, you will receive:\n*{".. DT_PREMIOQTDE_EASY .."}x "..getAllTableText(DT_PRIZENAME_EASY, "or")..", chosen at random;\n*{"..DT_PREMIOFIXO_QTDE_EASY.."}x "..DT_PREMIOFIXO_NAME_EASY..";\n*{"..DT_EXPPRIZE_EASY.."} Experience points;\n*{"..DT_TASKPOINTS_EASY.."}x Task Point.\nDo you want to start this {EASY} task?", cid)
else
npcHandler:say("Your EASY daily task today is: Kill {".. DT_NEEDKILL_EASY .."} {".. DT_CHOSENTASK_EASY .."}(s).\nIf you finish before {6:00am (GTM-3)}, you will receive:\n*{"..DT_PREMIOFIXO_QTDE_EASY.."}x "..DT_PREMIOFIXO_NAME_EASY..";\n*{"..DT_EXPPRIZE_EASY.."} Experience points;\n*{"..DT_TASKPOINTS_EASY.."}x Task Point.\nDo you want to start this {EASY} task?", cid)
end
The only # sign that I have yet noticed is in this function:
Lua:
function getAllTableText(aa, bb, cc)
local tablecheck = aa
if not tablecheck then
return false
end
local lang = bb
local ponto = ""
if not lang then
lang = "and"
end
if cc then
ponto = "."
end
local text = ""
for i = 1, #tablecheck do
if i == 1 then
text = tablecheck[i]
elseif i == #tablecheck then
text = text .." "..lang.." "..tablecheck[i]..""..ponto..""
else
text = text ..", "..tablecheck[i]
end
end
return text
end
Link with full code system: DailyTask ~100% (https://otland.net/threads/dailytask-100.272589/#post-2638428)
This probably only works if the server is restarted, but I'm not sure.
If you don't do a server restart, the monsters are not drawn.
Since I don't shut down the server every 24/h, I removed those lines and added in globalevents resetting storage for online players and removing storages from the database for offline players.
This all works, but there is one single problem with the monster draw.
Lua:
--RESETAR STORAGES
for i = 1, 6 do
db.query('DELETE FROM `player_storage` WHERE `player_storage`.`key` = '.. 367643969+i ..'')
end