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

[MOVEEVENT] Experience ring crashing the server

Status
Not open for further replies.

hxzr

New Member
Joined
Feb 4, 2010
Messages
156
Reaction score
0
movements.xml
Code:
<movevent type="Equip" itemid="6301" slot="ring" event="function" value="onEquipItem"/>
<movevent type="Equip" itemid="6300" slot="ring" event="script" value="expring.lua"/>
<movevent type="DeEquip" itemid="6301" slot="ring" event="script" value="expring.lua"/>

expring.lua
Code:
local config = {

        rate            = 1.25,
        equip        = 6301,
        unequip           = 6300
       
}

function onDeEquip(cid, item, slot)
        doPlayerSetExperienceRate(cid, 1.0)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You no longer recieve extra experience.")
        doTransformItem(item.uid, config.unequip)
        return true
end

function onEquip(cid, item, slot)
        doPlayerSetExperienceRate(cid, config.rate)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You will now recieve " .. config.rate .. "x more experience.")
        doTransformItem(item.uid, config.equip)
        doDecayItem(item.uid)
        return true
end

items.xml
Code:
<item id="6300" article="a" name="Death ring">
		<attribute key="weight" value="80" />
		<attribute key="slotType" value="ring" />
		<attribute key="transformEquipTo" value="6301" />
		<attribute key="stopduration" value="1" />
		<attribute key="showduration" value="0" />
	</item>
	<item id="6301" article="a" name="Death ring">
		<attribute key="weight" value="80" />
		<attribute key="slotType" value="ring" />
		<attribute key="decayTo" value="0" />
		<attribute key="transformDeEquipTo" value="6300" />
		<attribute key="duration" value="3600" />
		<attribute key="armor" value="1" />
		<attribute key="showduration" value="1" />
	</item>

If you throw around the ring quite often it will crash the server, I'm not sure if there's a certain pattern but it can also create a VOID(ID:100) inside a backpack and when you click it, the server goes down.

I'm not 100% sure on this thou: This only happens on items created in that session, once the server comes up IF you still have the ring it will not cause any problem.

(TFS 0.3.6pl1 | ubuntu)
 
Lua:
function onEquip(cid, item, slot)
        doTransformItem(item.uid, 6301, 1)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You will now receive 1.2 extra experience.")
		if getConfigValue("experienceStages") == "yes" then
		        doPlayerSetExperienceRate(cid, getExperienceStage(getPlayerLevel(cid)) * 1.25)
		else
		        doPlayerSetExperienceRate(cid, getConfigValue("rateExperience") * 1.25)
		end
return true
end
function onDeEquip(cid, item, slot)
        doTransformItem(item.uid, 6300, 1)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You no longer receive extra experience")
		doPlayerSetExperienceRate(cid, 1)
		getConfigValue(key)
return true
end
 
That's a quicky, yea well it should work even if a decay was missing..

I'd like to know exactly what went wrong in the script I posted I mean it just seem to cause a huge memory breakdown (resetting id 100?).. Any clues?
 
just a dodecayitem(item.uid) works fine since the onEquip defines the item being equipped and slot= defines your slot type..

Thou what I don't get is the right values needed for the exprate formulas (hence why i used my own) take a 100x exp rate for doPlayerSetExperienceRate(cid, getConfigValue("rateExperience") * 1.25) give a 125x exp rate, which turns out to be a huge boost

while you only change the total experience gained(normalexp*exprate) from that certain monster with doPlayerSetExperienceRate(cid, 1.25)

So really, is it something wrong with just that line (i doubt it)or where can you see yours working and mine isnt?
 
Bump, still want an answer why it becomes a different item (had both void and blood splatter) and causes a crash when you play around with it afterwards..
 
what do you want ? Working ring?
Lua:
local percent = 100
local rate = 1 + (percent / 100)
local effect = math.random(28)
function onEquip(cid, item, slot) 
playerpos = getPlayerPosition(cid)
    if(item.itemid ~= 2166) then     
    	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your exp rate + "..((rate - 1)*100).."%.") 
    	doPlayerSetExperienceRate(cid, rate) 
	doSendMagicEffect(playerpos, 28)
    	doTransformItem(item.uid, 2203 ) 
    	return true
    end  
    return true
end  
function onDeEquip(cid, item, slot) 
playerpo1 = getPlayerPosition(cid)
    if(item.itemid ~= 2203 ) then 
        return true
    end   
	doSendMagicEffect(playerpo1, 28)
    doPlayerSetExperienceRate(cid, 1.0) 
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your extra experience rate has ended.") 
    doTransformItem(item.uid, 2166) 
    return true
end
movements.xml
Code:
  <movevent type="Equip" itemid="2166" event="function" value="onEquipItem"/>
	<movevent type="Equip" itemid="2203" event="script" value="expring.lua"/>
    	<movevent type="DeEquip" itemid="2203" event="script" value="expring.lua"/>
(Don't ask about script, I didn't write that :p)
 
what do you want ? Working ring?
Lua:
local percent = 100
local rate = 1 + (percent / 100)
local effect = math.random(28)
function onEquip(cid, item, slot) 
playerpos = getPlayerPosition(cid)
    if(item.itemid ~= 2166) then     
    	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your exp rate + "..((rate - 1)*100).."%.") 
    	doPlayerSetExperienceRate(cid, rate) 
	doSendMagicEffect(playerpos, 28)
    	doTransformItem(item.uid, 2203 ) 
    	return true
    end  
    return true
end  
function onDeEquip(cid, item, slot) 
playerpo1 = getPlayerPosition(cid)
    if(item.itemid ~= 2203 ) then 
        return true
    end   
	doSendMagicEffect(playerpo1, 28)
    doPlayerSetExperienceRate(cid, 1.0) 
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your extra experience rate has ended.") 
    doTransformItem(item.uid, 2166) 
    return true
end
movements.xml
Code:
  <movevent type="Equip" itemid="2166" event="function" value="onEquipItem"/>
	<movevent type="Equip" itemid="2203" event="script" value="expring.lua"/>
    	<movevent type="DeEquip" itemid="2203" event="script" value="expring.lua"/>
(Don't ask about script, I didn't write that :p)

Well both yes and no, but I'm more interested in knowing what's causing the problem...
 
Yes I check bug ...

On The movements.xml
Code:
	<movevent type="Equip" itemid="6300" slot="ring" event="function" value="onEquipItem"/>
	<movevent type="Equip" itemid="6301" slot="ring" event="script" value="expring.lua"/>
	<movevent type="DeEquip" itemid="6301" slot="ring" event="script" value="expring.lua"/>
And Items.xml:
Code:
	<item id="6300" article="a" name="death ring">
		<attribute key="weight" value="80" />
		<attribute key="slotType" value="ring" />
		<attribute key="transformEquipTo" value="6301" />
		<attribute key="stopduration" value="1" />
		<attribute key="showduration" value="0" />
	</item>
	<item id="6301" article="a" name="death ring">
		<attribute key="weight" value="80" />
		<attribute key="slotType" value="ring" />
		<attribute key="decayTo" value="0" />
		<attribute key="transformDeEquipTo" value="6300" />
		<attribute key="duration" value="480" />
		<attribute key="armor" value="10" />
		<attribute key="showduration" value="1" />
	</item>

Pozdrawiam
Bufo :)
 
Status
Not open for further replies.
Back
Top