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

Status
Not open for further replies.

frankfarmer

who'r ninja now
Premium User
Joined
Aug 5, 2008
Messages
1,581
Reaction score
80
Hello! Thank you JDB who created this wonderful script, but i have a problem with it. Also players on my server have started to complain.

Here is the script: actions.xml
Lua:
	<action itemid="2196" event="script" value="scroll.lua"/>

scroll.lua

Lua:
  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

and the creaturescript: creaturescript.xml

Lua:
	<event type="login" name="expRate" event="script" value="extraExpRate.lua"/>

login.lua
Lua:
	registerCreatureEvent(cid, "expRate")

and the script: ExtraExpRate.lua

Lua:
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

1. Players have complained that if they die, they loose the exprate bonus.

2. If players relog their character they loose the extra experience bonus.

3. Is it possible to make some kinda lifering function? Meaning; They have a ring they wear, with 300minutes/5 hours and when it wears off the experience bonus is lost?

4. Is it possible the amulet to save the extra experience rate even if they logout or relog their character?

Once again, someone who is nice enough to have a look at this editing my scripts. I am willing to give 5 euros to, if you have paypal.

Thanks in advance!
 
ok i made something :D here is the ring.lua

Code:
-- Not tested

 local config = {
    rate = 1.6, -- 4x More Experience
    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 .. ".")
        doPlayerSetRate(cid, SKILL__LEVEL, config.rate)
    end
    return true
end

and you dont need a creature script... becouse in items.xml already are duration...

the ring is maked from Life ring. so the id of ring is life ring just edited.

Code:
<item id="2168" article="a" name="Experence ring">
		<attribute key="weight" value="80"/>
		<attribute key="slotType" value="ring"/>
		<attribute key="transformEquipTo" value="2205"/>
		<attribute key="duration" value="21600"/>
		<attribute key="stopduration" value="1"/>
		<attribute key="showduration" value="1"/>
	</item>

Accepting Reputations !
 
Last edited:
Code:
local config = {
	rate = 1.6, -- 4x More Experience
	time = 5, -- Hours of Exp Time
	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 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
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
 
Last edited:
Tested the ring script:
IN-game
Lua:
21:47 Your extra experience rate is now: 1.6.

But: The ring dissapeared

Using this:

Lua:
	<item id="2357" article="a" name="ring of experience">
		<attribute key="weight" value="80"/>
		<attribute key="slotType" value="ring"/>
		<attribute key="duration" value="21600"/>
		<attribute key="stopduration" value="1"/>
		<attribute key="showduration" value="1"/>
	</item>

And your script. Why did the ring dissapear?
 
You need to use both of them in order for this to work. Keep in mind that it might not work.

I want to test it, but which one is what? I can understand one of the scripts, but the other one is kinda complicated for me where to use it.

Is it 2 action scripts? 1 for amulet and 1 for ring? Or is it a creaturescript with action script?
 
Remove
Code:
        doRemoveItem(item.uid, 1)
I want to test it, but which one is what? I can understand one of the scripts, but the other one is kinda complicated for me where to use it.

Is it 2 action scripts? 1 for amulet and 1 for ring? Or is it a creaturescript with action script?
The first one is an action script for the item that you're using. The other one is onLogin creaturescript.
They're not intended for use as rings or amulets.
 
Tested the ring script:
IN-game
Lua:
21:47 Your extra experience rate is now: 1.6.

But: The ring dissapeared

Using this:

Lua:
	<item id="2357" article="a" name="ring of experience">
		<attribute key="weight" value="80"/>
		<attribute key="slotType" value="ring"/>
		<attribute key="duration" value="21600"/>
		<attribute key="stopduration" value="1"/>
		<attribute key="showduration" value="1"/>
	</item>

And your script. Why did the ring dissapear?

it cant disspaer :D

becouse
Code:
<attribute key="duration" value="21600"/>
-- 6 hours try use the life ring one :D becouse ring of the wishes dont got a function for duration i thinking so :D realy dont know... try with life ring.
 
Remove
Code:
        doRemoveItem(item.uid, 1)

The first one is an action script for the item that you're using. The other one is onLogin creaturescript.
They're not intended for use as rings or amulets.


Thanks alot of posts and alot of testings, have to restart my server and the players don't like that much.

Btw, what are they intend to work with?
 
Thanks alot of posts and alot of testings, have to restart my server and the players don't like that much.

Btw, what are they intend to work with?
The script should work on any item that doesn't decay. Keep in mind that the item will be removed instantly after it's used once.
Should work with stackables too.
 
amm... but mayby are possible make it with counts? strong write on it then you relog ur exp rate dissaper and if u die same... but the Scroll got 3~ local counts... i think its can by more better? but not best...
 
Please note that I haven't tested the script and have no idea what it's gonna do, so any bug reports or notices are appreciated.
 
Please note that I haven't tested the script and have no idea what it's gonna do, so any bug reports or notices are appreciated.

Code:
[01/12/2009 03:06:44] Lua Script Error: [CreatureScript Interface] 
[01/12/2009 03:06:44] data/creaturescripts/scripts/extraExpRate.lua:onLogin

[01/12/2009 03:06:44] data/creaturescripts/scripts/extraExpRate.lua:16: attempt to concatenate a nil value
[01/12/2009 03:06:44] stack traceback:
[01/12/2009 03:06:44] 	data/creaturescripts/scripts/extraExpRate.lua:16: in function <data/creaturescripts/scripts/extraExpRate.lua:12>
[01/12/2009 03:06:44] GM Real has logged out.

Hmm? Impossible to login atm.
 
Code:
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your extra exp rate will expire at: " .. os.date("%X", str))
I don't see anything wrong with it. Have you modified the script?
 
Well i added this:

login.lua
Lua:
	registerCreatureEvent(cid, "expRate")

and

Lua:
    <event type="login" name="expRate" event="script" value="extraExpRate.lua"/>


Script im using:

Lua:
local config = {
	rate = 1.6, -- 4x More Experience
	storage = 20011
}
local function endExpRate(cid)
	if isPlayer(cid) then
		doPlayerSetRate(cid, SKILL__LEVEL, 1) -- config.lua rate
		setPlayeStorageValue(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, storage)
	if(os.time() - str) > 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, os.time() - str * 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, storage, -1)
	end
	return true
end
 
Status
Not open for further replies.
Back
Top