potinho
Advanced OT User
Hi guys, I have two exp scroll, one that is sold on the website (1.5 exp) and another in game (1.3 exp). What is sold on the site is not working after the character logs out and comes back, could you help me?
EXP Scroll who works:
Exp Scroll who not working after logout and login
in login.lua i have:
in creaturescripts.xml we have
EXP Scroll who works:
Lua:
local config = {
rate = 1.3,
time = 1 * 60 * 60, -- (2 hours) in seconds
storage = 20015
}
local function endExpRate(cid)
if isPlayer(cid) == TRUE then
doPlayerSetRate(cid, SKILL__LEVEL, 1) -- config.lua rate
setPlayerStorageValue(cid, config.storage, -1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Your extra experience time has ended.")
end
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerStorageValue(cid, config.storage) < os.time() then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have experience rate x1.3 It will last for ".. (config.time / 3600) .." hours.")
doPlayerSetRate(cid, SKILL__LEVEL, config.rate)
setPlayerStorageValue(cid, config.storage, os.time() + config.time)
addEvent(endExpRate, config.time * 1000, cid)
doRemoveItem(item.uid, 1)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You still have " .. (os.date('!%H:%M:%S', getPlayerStorageValue(cid, config.storage) - os.time())) .. " extra experience time left.")
end
return true
end
Lua:
local storage = 20015
local function endExpRate(cid)
if isPlayer(cid) then
doPlayerSetRate(cid, SKILL__LEVEL, 1) -- config.lua rate
setPlayerStorageValue(cid, storage, -1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Your extra experience time has ended.")
end
end
function onLogin(cid)
local storageValue = getPlayerStorageValue(cid, storage)
local timeLeft = storageValue - os.time()
if storageValue > os.time() then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Extra experience rate is now: 1.3x than normal. It will last for " .. (math.ceil(timeLeft/60)) .. " minutes.")
doPlayerSetRate(cid, SKILL__LEVEL, 1.3)
addEvent(endExpRate, timeLeft * 1000, cid)
else
doPlayerSetRate(cid, SKILL__LEVEL, 1.0)
end
return true
end
Exp Scroll who not working after logout and login
Lua:
local config = {
rate = 1.5,
time = 2 * 60 * 60, -- (2 hours) in seconds
storage = 20014
}
local function endExpRate(cid)
if isPlayer(cid) == TRUE then
doPlayerSetRate(cid, SKILL__LEVEL, 1) -- config.lua rate
setPlayerStorageValue(cid, config.storage, -1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Your extra experience time has ended.")
end
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerStorageValue(cid, config.storage) < os.time() then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have experience rate x1.5 It will last for ".. (config.time / 3600) .." hours.")
doPlayerSetRate(cid, SKILL__LEVEL, config.rate)
setPlayerStorageValue(cid, config.storage, os.time() + config.time)
addEvent(endExpRate, config.time * 1000, cid)
doRemoveItem(item.uid, 1)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You still have " .. (os.date('!%H:%M:%S', getPlayerStorageValue(cid, config.storage) - os.time())) .. " extra experience time left.")
end
return true
end
Lua:
local storage = 20014
local function endExpRate(cid)
if isPlayer(cid) then
doPlayerSetRate(cid, SKILL__LEVEL, 1) -- config.lua rate
setPlayerStorageValue(cid, storage, -1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Your extra experience time has ended.")
end
end
function onLogin(cid)
local storageValue = getPlayerStorageValue(cid, storage)
local timeLeft = storageValue - os.time()
if storageValue > os.time() then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Extra experience rate is now: 1.5x than normal. It will last for " .. (math.ceil(timeLeft/60)) .. " minutes.")
doPlayerSetRate(cid, SKILL__LEVEL, 1.5)
addEvent(endExpRate, timeLeft * 1000, cid)
else
doPlayerSetRate(cid, SKILL__LEVEL, 1.0)
end
return true
end
in login.lua i have:
Lua:
registerCreatureEvent(cid, "extraExperienceScroll")
registerCreatureEvent(cid, "freeextraExperienceScroll")
in creaturescripts.xml we have
XML:
<creatureevent type="login" name="extraExperienceScroll" event="script" value="extraExperienceScroll.lua"/>
<creatureevent type="login" name="freeextraExperienceScroll" event="script" value="freeextraExperienceScroll.lua"/>
Last edited: