exp statue
script (ex. 'expiry date value') and then compare it in player.lua
to add extra exp (ex. 20% = exp = exp * 1.2)
) to all players as long as this statue
is enabled.Sorry its my bad, i looking for someone ex:If you mean exp boost for all players in-game, it's in this file on TFS 1.2:
You can set some global storage value to some value in![]()
forgottenserver/data/events/scripts/player.lua at 1.2 · otland/forgottenserver
A free and open-source MMORPG server emulator written in C++ - otland/forgottenservergithub.com
exp statue
script (ex. 'expiry date value') and then compare it inplayer.lua
to add extra exp (ex. 20% =exp = exp * 1.2)
) to all players as long as thisstatue
is enabled.
<action actionid="45001" script="experienceStatues.lua" />
<action actionid="45002" script="experienceStatues.lua" />
<action actionid="45049" script="experienceStatues.lua" />
<action actionid="45050" script="experienceStatues.lua" />
local statueCountingStorage = 45000
local statues = {
-- [actionId] = {storageKey = xxxxx, experience = {min, max}},
[45001] = {storageKey = 45001, experience = {100, 1000}},
[45002] = {storageKey = 45002, experience = {100, 1000}},
[45049] = {storageKey = 45049, experience = {100, 1000}},
[45050] = {storageKey = 45050, experience = {100, 1000}}
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local statue = statues[item:getActionId()]
local storage = player:getStorageValue(statue.storageKey)
if storage == 1 then
return true
end
local statueCount = math.max(player:getStorageValue(statueCountingStorage), 0) + 1
player:setStorageValue(statueCountingStorage, statueCount)
player:setStorageValue(statue.storageKey, 1)
local experienceToAdd = math.random(statue.experience[1], statue.experience[2])
player:addExperience(experienceToAdd, true)
local totalStatueCount = 0
for _ in pairs(statues) do
totalStatueCount = totalStatueCount + 1
end
player:say("You discovered " .. statueCount .. " from " .. totalStatueCount .. " exp statues.", TALKTYPE_MONSTER_SAY, false, player, toPosition)
return true
end
Works brilliantly! Could I ask you to still add a message when I click on a statue again that it has already been received? Because at the moment there is no info, and I would really appreciate it, thanksI have no idea how they did the white text. xD
I only know how to do orange.
XML:<action actionid="45001" script="experienceStatues.lua" /> <action actionid="45002" script="experienceStatues.lua" /> <action actionid="45049" script="experienceStatues.lua" /> <action actionid="45050" script="experienceStatues.lua" />
LUA:local statueCountingStorage = 45000 local statues = { -- [actionId] = {storageKey = xxxxx, experience = {min, max}}, [45001] = {storageKey = 45001, experience = {100, 1000}}, [45002] = {storageKey = 45002, experience = {100, 1000}}, [45049] = {storageKey = 45049, experience = {100, 1000}}, [45050] = {storageKey = 45050, experience = {100, 1000}} } function onUse(player, item, fromPosition, target, toPosition, isHotkey) local statue = statues[item:getActionId()] local storage = player:getStorageValue(statue.storageKey) if storage == 1 then return true end local statueCount = math.max(player:getStorageValue(statueCountingStorage), 0) + 1 player:setStorageValue(statueCountingStorage, statueCount) player:setStorageValue(statue.storageKey, 1) local experienceToAdd = math.random(statue.experience[1], statue.experience[2]) player:addExperience(experienceToAdd, true) local totalStatueCount = 0 for _ in pairs(statues) do totalStatueCount = totalStatueCount + 1 end player:say("You discovered " .. statueCount .. " from " .. totalStatueCount .. " exp statues.", TALKTYPE_MONSTER_SAY, false, player, toPosition) return true end
Works brilliantly! Could I ask you to still add a message when I click on a statue again that it has already been received? Because at the moment there is no info, and I would really appreciate it, thanks
34/50 exp statues have been located.
Discovered 13/50 exp statues!
You gain 548 experience!
local statueCountingStorage = 45000
local statues = {
-- [actionId] = {storageKey = xxxxx, experience = {min, max}},
[45001] = {storageKey = 45001, experience = {100, 1000}},
[45002] = {storageKey = 45002, experience = {100, 1000}},
[45049] = {storageKey = 45049, experience = {100, 1000}},
[45050] = {storageKey = 45050, experience = {100, 1000}}
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local statue = statues[item:getActionId()]
local storage = player:getStorageValue(statue.storageKey)
local statueStorage = player:getStorageValue(statueCountingStorage)
local totalStatueCount = 0
for _ in pairs(statues) do
totalStatueCount = totalStatueCount + 1
end
local statueText = statueCount .. "/" .. totalStatueCount .. " exp statues"
if storage == 1 then
player:say(statueText .. " have been located.", TALKTYPE_MONSTER_SAY, false, player, toPosition)
return true
end
local statueCount = math.max(statueStorage), 0) + 1
player:setStorageValue(statueCountingStorage, statueCount)
player:setStorageValue(statue.storageKey, 1)
local experienceToAdd = math.random(statue.experience[1], statue.experience[2])
player:addExperience(experienceToAdd, true)
player:say("Discovered " .. statueText .. "!\nYou gain " .. experienceToAdd .. " experience!", TALKTYPE_MONSTER_SAY, false, player, toPosition)
return true
end
Thank you for your time, everything works as it should!Code:34/50 exp statues have been located.
Code:Discovered 13/50 exp statues! You gain 548 experience!
LUA:local statueCountingStorage = 45000 local statues = { -- [actionId] = {storageKey = xxxxx, experience = {min, max}}, [45001] = {storageKey = 45001, experience = {100, 1000}}, [45002] = {storageKey = 45002, experience = {100, 1000}}, [45049] = {storageKey = 45049, experience = {100, 1000}}, [45050] = {storageKey = 45050, experience = {100, 1000}} } function onUse(player, item, fromPosition, target, toPosition, isHotkey) local statue = statues[item:getActionId()] local storage = player:getStorageValue(statue.storageKey) local statueStorage = player:getStorageValue(statueCountingStorage) local totalStatueCount = 0 for _ in pairs(statues) do totalStatueCount = totalStatueCount + 1 end local statueText = statueCount .. "/" .. totalStatueCount .. " exp statues" if storage == 1 then player:say(statueText .. " have been located.", TALKTYPE_MONSTER_SAY, false, player, toPosition) return true end local statueCount = math.max(statueStorage), 0) + 1 player:setStorageValue(statueCountingStorage, statueCount) player:setStorageValue(statue.storageKey, 1) local experienceToAdd = math.random(statue.experience[1], statue.experience[2]) player:addExperience(experienceToAdd, true) player:say("Discovered " .. statueText .. "!\nYou gain " .. experienceToAdd .. " experience!", TALKTYPE_MONSTER_SAY, false, player, toPosition) return true end
Remove additional ')' next to statueStorage variable.@Xikini today when i launch my local server i found this error:
Code:[Warning - Event::checkScript] Can not load script: scripts/experienceStatues.lua data/actions/scripts/experienceStatues.lua:29: unexpected symbol near ')'
line 29:
Code:local statueCount = math.max(statueStorage), 0) + 1
local statueCount = math.max(statueStorage, 0) + 1
Thanks for your reply!Remove additional ')' next to statueStorage variable.
LUA:local statueCount = math.max(statueStorage, 0) + 1
Lua Script Error: [Action Interface]
data/actions/scripts/experienceStatues.lua:onUse
data/actions/scripts/experienceStatues.lua:22: attempt to concatenate global 'statueCount' (a nil value)
stack traceback:
[C]: in function '__concat'
data/actions/scripts/experienceStatues.lua:22: in function <data/actions/scripts/experienceStatues.lua:11>
It means that it cannot merge string value on line 22:Thanks for your reply!
Next error after this change:
Code:Lua Script Error: [Action Interface] data/actions/scripts/experienceStatues.lua:onUse data/actions/scripts/experienceStatues.lua:22: attempt to concatenate global 'statueCount' (a nil value) stack traceback: [C]: in function '__concat' data/actions/scripts/experienceStatues.lua:22: in function <data/actions/scripts/experienceStatues.lua:11>
local statueText = statueCount .. "/" .. totalStatueCount .. " exp statues"
local statueCount = math.max(statueStorage, 0)
local statueText = statueCount .. "/" .. totalStatueCount .. " exp statues"
player:setStorageValue(statueCountingStorage, statueCount+1)
local statueCountingStorage = 45000
local statues = {
-- [actionId] = {storageKey = xxxxx, experience = {min, max}},
[45001] = {storageKey = 45001, experience = {100, 1000}},
[45002] = {storageKey = 45002, experience = {100, 1000}},
[45049] = {storageKey = 45049, experience = {100, 1000}},
[45050] = {storageKey = 45050, experience = {100, 1000}}
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local statue = statues[item:getActionId()]
local storage = player:getStorageValue(statue.storageKey)
local statueStorage = player:getStorageValue(statueCountingStorage)
local totalStatueCount = 0
for _ in pairs(statues) do
totalStatueCount = totalStatueCount + 1
end
local statueText = statueStorage .. "/" .. totalStatueCount .. " exp statues"
if storage == 1 then
player:say(statueText .. " have been located.", TALKTYPE_MONSTER_SAY, false, player, toPosition)
return true
end
local statueCount = math.max(statueStorage, 0) + 1
player:setStorageValue(statueCountingStorage, statueCount)
player:setStorageValue(statue.storageKey, 1)
local experienceToAdd = math.random(statue.experience[1], statue.experience[2])
player:addExperience(experienceToAdd, true)
player:say("Discovered " .. statueText .. "!\nYou gain " .. experienceToAdd .. " experience!", TALKTYPE_MONSTER_SAY, false, player, toPosition)
return true
end
<talkaction words="!expstatues" script="expstatues.lua" />
local statueCountingStorage = 45000
local statues = {
[45001] = {storageKey = 45001, experience = {100, 1000}},
[45002] = {storageKey = 45002, experience = {100, 1000}},
[45049] = {storageKey = 45049, experience = {100, 1000}},
[45050] = {storageKey = 45050, experience = {100, 1000}}
}
function onSay(player, words, param)
local statueStorage = player:getStorageValue(statueCountingStorage) or 0
local totalStatueCount = 0
for _ in pairs(statues) do
totalStatueCount = totalStatueCount + 1
end
local discoveredStatues = math.max(statueStorage, 0)
local remainingStatues = totalStatueCount - discoveredStatues
local message = "You have discovered " .. discoveredStatues .. " out of " .. totalStatueCount .. " statues. Remaining: " .. remainingStatues
player:sendTextMessage(MESSAGE_INFO_DESCR, message)
return true
end