• 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!

Lua Amulet of experience

Thorn

Spriting since 2013
Joined
Sep 24, 2012
Messages
2,203
Solutions
1
Reaction score
921
Location
Chile
hiii well i have a amulet of experience action, that gives you x2 exp during a week, the problem is that if you die, the exp comes back to normal :S. Plz guys help me fix this :(
Code:
local config = {
        rate = 2.0, -- 4x More Experience
        time = 168, -- Hours of Exp Time
        storage = 20011
    }
    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
    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
 
Be sure to add these three things in creaturescripts..
CreatureScripts.XML
Code:
    <event type="login" name="expRate" event="script" value="extraExpRate.lua"/>
Login.Lua
Code:
    registerCreatureEvent(cid, "expRate")
And add the script "ExtraExpRate.lua" in creaturescripts.
Code:
local storage = 20011
function onLogin(cid)
if(getPlayerStorageValue(cid, storage) == 1) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your extra exp rate will expire at:")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You do not have any extra experience time.")
setPlayerStorageValue(cid, storage, -1)
end
return true
end
 
Code:
function onLogin(cid)
accountManager = "Account Manager"                     
  managerCounter = 0
  for i, player in ipairs(getOnlinePlayers()) do
      if accountManager:lower() == player:lower() then           
      managerCounter = managerCounter + 1
      end
  end
  if managerCounter >= 3 then
      return false
  end
function onLogin(cid)
    registerCreatureEvent(cid, "Inquisition")
        return true
end
    setPlayerStorageValue(cid,29061,1)
    registerCreatureEvent(cid, "DeathBroadcast")
    registerCreatureEvent(cid, "inquisitionPortals")
    registerCreatureEvent(cid, "PlayerDeath")
    registerCreatureEvent(cid, "PlayerKill")
    registerCreatureEvent(cid, "KilledMonstersCounter")
    registerCreatureEvent(cid, "fragcheck")
    registerCreatureEvent(cid, "onPrepareDeath") 
    registerCreatureEvent(cid, "antha")
    registerCreatureEvent(cid, "RebirthDescription")
    registerCreatureEvent(cid, "Frag Reward")
    registerCreatureEvent(cid, "advancesave")
    registerCreatureEvent(cid, "MageBomb")
    registerCreatureEvent(cid, "MonsterPortal")
    registerCreatureEvent(cid, "MonsterPortal2")                      registerCreatureEvent(cid, "MonsterPortal3")
    registerCreatureEvent(cid, "MonsterPortal4")
    registerCreatureEvent(cid, "MonsterPortal5")
   
    if (InitArenaScript ~= 0) then
    InitArenaScript = 1
    -- make arena rooms free
      for i = 42300, 42309 do
            setGlobalStorageValue(i, 0)
            setGlobalStorageValue(i+100, 0)
        end
    end
for i = 1, 3 do
      if getPlayerStorageValue(cid, 42300 + i * 10 - 1) < 1 then
          for j = 0, 9 do
              setPlayerStorageValue(cid, 42290 + i * 10 + j, 0)
          end
      end
  end
    if getPlayerStorageValue(cid, 42355) == -1 then
        setPlayerStorageValue(cid, 42355, 0) -- did not arena level
    end
    setPlayerStorageValue(cid, 42350, 0) -- time to kick 0
    setPlayerStorageValue(cid, 42352, 0) -- is not in arena 
   
local fromPosition = getPlayerPosition(cid)
local restartOnLogout = 1 -- Set 1 to restart the demon oak stage storage ids on logout.
    if getPlayerStorageValue(cid, 21545) == 1 then
        if getThingfromPos({x = fromPosition.x, y = fromPosition.y, z = fromPosition.z, stackpos = 0}).itemid == 8292 then
            doTeleportThing(cid, {x=1219, y=1135, z=7})
            doSendMagicEffect({x=1219, y=1135, z=7}, 10)
            setPlayerStorageValue(cid, 21545, -1)
        end
        if restartOnLogout == 1 then
            decayIds = {21540, 8288, 8289, 8290, 8291}
            for i = 1, #decayIds do
                setPlayerStorageValue(cid, decayIds[i], -1)
            end
        end
    end

    return TRUE
end
 
Try this.
Code:
function onLogin(cid)
accountManager = "Account Manager"                   
  managerCounter = 0
  for i, player in ipairs(getOnlinePlayers()) do
      if accountManager:lower() == player:lower() then         
      managerCounter = managerCounter + 1
      end
  end
  if managerCounter >= 3 then
      return false
  end
function onLogin(cid)
    registerCreatureEvent(cid, "Inquisition")
        return true
end
    setPlayerStorageValue(cid,29061,1)
    registerCreatureEvent(cid, "DeathBroadcast")
    registerCreatureEvent(cid, "inquisitionPortals")
    registerCreatureEvent(cid, "PlayerDeath")
    registerCreatureEvent(cid, "PlayerKill")
    registerCreatureEvent(cid, "KilledMonstersCounter")
    registerCreatureEvent(cid, "fragcheck")
    registerCreatureEvent(cid, "onPrepareDeath")
    registerCreatureEvent(cid, "antha")
    registerCreatureEvent(cid, "RebirthDescription")
    registerCreatureEvent(cid, "Frag Reward")
    registerCreatureEvent(cid, "advancesave")
    registerCreatureEvent(cid, "MageBomb")
    registerCreatureEvent(cid, "MonsterPortal")
    registerCreatureEvent(cid, "MonsterPortal2")                      registerCreatureEvent(cid, "MonsterPortal3")
    registerCreatureEvent(cid, "MonsterPortal4")
    registerCreatureEvent(cid, "MonsterPortal5")
    registerCreatureEvent(cid, "expRate")
 
    if (InitArenaScript ~= 0) then
    InitArenaScript = 1
    -- make arena rooms free
      for i = 42300, 42309 do
            setGlobalStorageValue(i, 0)
            setGlobalStorageValue(i+100, 0)
        end
    end
for i = 1, 3 do
      if getPlayerStorageValue(cid, 42300 + i * 10 - 1) < 1 then
          for j = 0, 9 do
              setPlayerStorageValue(cid, 42290 + i * 10 + j, 0)
          end
      end
  end
    if getPlayerStorageValue(cid, 42355) == -1 then
        setPlayerStorageValue(cid, 42355, 0) -- did not arena level
    end
    setPlayerStorageValue(cid, 42350, 0) -- time to kick 0
    setPlayerStorageValue(cid, 42352, 0) -- is not in arena
 
local fromPosition = getPlayerPosition(cid)
local restartOnLogout = 1 -- Set 1 to restart the demon oak stage storage ids on logout.
    if getPlayerStorageValue(cid, 21545) == 1 then
        if getThingfromPos({x = fromPosition.x, y = fromPosition.y, z = fromPosition.z, stackpos = 0}).itemid == 8292 then
            doTeleportThing(cid, {x=1219, y=1135, z=7})
            doSendMagicEffect({x=1219, y=1135, z=7}, 10)
            setPlayerStorageValue(cid, 21545, -1)
        end
        if restartOnLogout == 1 then
            decayIds = {21540, 8288, 8289, 8290, 8291}
            for i = 1, #decayIds do
                setPlayerStorageValue(cid, decayIds[i], -1)
            end
        end
    end

    return TRUE
end
 
Add the login script aswell, not only the action script.

Code:
local config = {
   rate = 1.6, -- 4x More Experience
   storage = 20011
}
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 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) -- config.lua rate
     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You do not have any extra experience time.")
     setPlayerStorageValue(cid, config.storage, -1)
   end
   return TRUE
end
 
limos didn't work :(
Code:
[07/09/2013 12:15:49] [Error - LuaScriptInterface::loadFile] data/actions/scripts/amuletofexperience.lua:1: '=' expected near 'config'
[07/09/2013 12:15:49] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/amuletofexperience.lua)
[07/09/2013 12:15:49] data/actions/scripts/amuletofexperience.lua:1: '=' expected near 'config'
 
Try this?
Code:
local t = {
  rate = 1.6, -- 4x More Experience
  storage = 20011
}
local function endExpRate(cid)
  if isPlayer(cid) == TRUE then
    doPlayerSetRate(cid, SKILL__LEVEL, 1) -- config.lua rate
    setPlayerStorageValue(cid, t.storage, -1)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Your extra experience time has ended.")
  end
end
function onLogin(cid)
  local str = getPlayerStorageValue(cid, t.storage)
  if(str >= 0 and (str - os.time()) > 0) then
    doPlayerSetRate(cid, SKILL__LEVEL, t.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) -- config.lua rate
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You do not have any extra experience time.")
    setPlayerStorageValue(cid, t.storage, -1)
  end
  return TRUE
end
 
Back
Top