• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua amulet of experience

simson361

The Grim Reaper
Joined
Aug 4, 2010
Messages
626
Reaction score
27
Location
sweden
hey @Cykotitan @Erikas Kontenis and @frankfarmer since the thread http://otland.net/threads/amulet-of-experience-stage.58109/ is closed i cudent ask there. so im making this new thread to ask ^_^
the exp stays forever the think you click on gives you exp in 5h it says to 02:16 but it has bean past 5h and i still have it.. :/ also when i tryed to die to see if i lost it i got a error
Code:
[16/09/2013 05:45:22] [Error - CreatureScript Interface]
[16/09/2013 05:45:22] data/creaturescripts/scripts/onpd.lua:onPrepareDeath
[16/09/2013 05:45:22] Description:
[16/09/2013 05:45:22] data/creaturescripts/scripts/onpd.lua:3: attempt to call field 'query' (a nil value)
[16/09/2013 05:45:22] stack traceback:
[16/09/2013 05:45:22]    data/creaturescripts/scripts/onpd.lua:3: in function <data/creaturescripts/scripts/onpd.lua:1>
 
@Summ ^^
1. Login.lua
Code:
    registerCreatureEvent(cid, "expRate")
2. creaturescript.xml
Code:
<event type="login" name="expRate" event="script" value="extraExpRate.lua"/>
3. creaturescripts/scripts

Code:
 local config = {
rate = 1.6, -- 4x More Experience
time = 5, -- Hours of Exp Time
storage = 20011
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
if(getPlayerStorageValue(cid, config.storage) == -1) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your extra experience rate is now: " .. config.rate .. ". It will last for ".. config.time .." hours.")
doPlayerSetRate(cid, SKILL__LEVEL, config.rate)
setPlayerStorageValue(cid, config.storage, os.time() + config.time * 3600 * 1000)
addEvent(endExpRate, config.time * 3600 * 1000, cid)
doRemoveItem(item.uid, 1)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You still have extra experience time left.")
end
return true
end

local function endExpRate(cid)
doPlayerSetRate(cid, SKILL__LEVEL, 6.0) --config.lua rate
setPlayerStorageValue(cid, config.storage, -1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Your extra experience time has ended.")
end
 
i know xD i dident know where to put it so i put in creaturescript and in action ;D @Ninja it works just fine only thing is the exp dossent end after 5h do you know how to fix it? ^^!
 
@Limos how shold i add to make it work properly please tell me here beg you. else im getting error

[18/09/2013 21:52:27] [Warning - Actions::registerEvent] Duplicate registered item id: 11130
[18/09/2013 21:52:27] [Warning - Event::loadScript] Event onLogin not found (data/creaturescripts/scripts/extraExpRate.lua)
 
Add this script in actions with an itemid that is not used yet in actions.xml
Code:
local config = {
   rate = 1.6,
   time = 5, -- Hours of Exp Time
   storage = 20011
}
local function endExpRate(cid)
   if isPlayer(cid) == TRUE then
     doPlayerSetRate(cid, SKILL__LEVEL, 1)
     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) < 0) then
     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your extra experience rate is now: " .. config.rate .. ". It will last for ".. config.time .." hours.")
     doPlayerSetRate(cid, SKILL__LEVEL, config.rate)
     setPlayerStorageValue(cid, config.storage, os.time() + config.time * 3600)
     addEvent(endExpRate, config.time * 3600 * 1000, cid)
     doRemoveItem(item.uid, 1)
   else
     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You still have extra experience time left.")
   end
   return TRUE
end

Then add this script in creaturescripts with type login (don't register it in login.lua or anywhere else).
Code:
local config = {
   rate = 1.6,
   storage = 20011
}
local function endExpRate(cid)
   if isPlayer(cid) == TRUE then
     doPlayerSetRate(cid, SKILL__LEVEL, 1)
     setPlayerStorageValue(cid, config.storage, -1)
     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Your extra experience time has ended.")
   end
end
function onLogin(cid)
   local str = getPlayerStorageValue(cid, config.storage)
   if(str >= 0 and (str - os.time()) > 0) then
     doPlayerSetRate(cid, SKILL__LEVEL, config.rate)
     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your extra exp rate will expire at: " .. os.date("%X", str))
     addEvent(endExpRate, (str - os.time()) * 1000, cid)
   else
     doPlayerSetRate(cid, SKILL__LEVEL, 1) 
     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You do not have any extra experience time.")
     setPlayerStorageValue(cid, config.storage, -1)
   end
   return TRUE
end
 
Back
Top