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

[Mods] Help with mods!

Renusek

beton beton beton punk!
Joined
Jul 24, 2008
Messages
1,047
Reaction score
9
Location
Poland - Katowice/Ruda Śląska
Hello :p.
I'm now rewritting my scripts to mod system :p. And I have few problems :(. Help plx and fix that...

Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Deaths Channel" version="1.0" author="Renusek and Zonet" contact="otland.net" enabled="no">
	<description>
		This mod will add new channel - Deaths.
		It's kind of deathlist. Last deaths on serv.
	</description>
	<config name="deaths_channel_config"><![CDATA[
		config = {
			channel = 11
		}
	]]></config>
	<channel id="11" name="Deaths Channel" active="no" enabled="yes"/>
	<event type="login" name="Deaths Channel" event="buffer"><![CDATA[
			registerCreatureEvent(cid, "PlayerDeath")
	]]></event>
	<event type="death" name="Deaths Channel" event="buffer"><![CDATA[
			domodlib('firstitems_config')

			function onDeath(cid, corpse, lastHitKiller, mostDamageKiller)
				if isPlayer(lastHitKiller) == TRUE then
					doPlayerSendChannelMessage(cid, "Auto Message", ""..getPlayerName(cid).." ["..getPlayerLevel(cid).."] just got killed by "..getPlayerName(lastHitKiller).." ["..getPlayerLevel(lastHitKiller).."] (Player)", TALKTYPE_CHANNEL_O, config.channel)
				elseif isMonster(lastHitKiller) == TRUE then
					doPlayerSendChannelMessage(cid, "Auto Message", ""..getPlayerName(cid).." ["..getPlayerLevel(cid).."] just got killed by "..getCreatureName(lastHitKiller).." (Monster)", TALKTYPE_CHANNEL_O, config.channel)
				else
					doPlayerSendChannelMessage(cid, "Auto Message", ""..getPlayerName(cid).." ["..getPlayerLevel(cid).."] just got killed by "..getCreatureName(lastHitKiller).." (?)", TALKTYPE_CHANNEL_O, config.channel)
				end
				_result = true
			end
	]]></event>
</mod>

And my script for naruto server :D.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Control Training" version="1.0" author="Renusek" contact="localhost" enabled="yes">
	<info>
		This mod will enable training chakra control by walking on water.
	</info>
	<config name="control_config"/><![CDATA[
		pPos = getPlayerPosition(cid)
	]]></config>
	<movement type="StepIn" itemid="4820-4825" event="buffer"><![CDATA[
		domodlib(control_config)
		function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
				doSendMagicEffect(pPos, 1)
				doPlayerAddSkillTry(cid, 1, 1)
			_result = true
		end
	]]></movement>
</mod>

What's wrong here?
In first script no errors.
In second one error in line 9 ;/.
 
try this:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Control Training" version="1.0" author="Renusek" contact="localhost" enabled="yes">
	<info>
		This mod will enable training chakra control by walking on water.
	</info>
	<config name="control_config"/><![CDATA[
		pPos = getPlayerPosition(cid)
	]]></config>
	<movement type="StepIn" itemid="4820-4825" [b]event="script"[/b]><![CDATA[
		domodlib(control_config)
		function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
				doSendMagicEffect(pPos, 1)
				doPlayerAddSkillTry(cid, 1, 1)
			[b]return true[/b]
		end
	]]></movement>
</mod>
 
no.. you use CDATA for script and event, the CDATA just includes the "Lua Part" Heres a small tutorial I wrote for another thread.

well i know little about "buffer" but here is my rundown of it.

If you use "script" you include function with it and use return true/false
If you use "buffer" you dont need to include function and use _result = false/true

You probably didn't get it cause I barely did. So heres examples:

Code:
	[COLOR="Blue"]<action[/COLOR] [COLOR="Red"]itemid[/COLOR]=[COLOR="DarkOrchid"]"1981"[/COLOR] [COLOR="Red"]event[/COLOR]=[COLOR="DarkOrchid"]"buffer"[/COLOR][COLOR="Blue"]>[/COLOR][COLOR="Orange"]<![CDATA[
		if(item.actionid >= 150 and item.actionid <= 158) then
			doShowTextDialog(cid, item.itemid, getHighscoreString((item.actionid - 150)))
		else
			_result = false
		end
]]>[/COLOR][COLOR="Blue"]</action>[/COLOR]

You noticed how it didn't need to call the function OnUse? and it did not use return false, it used _result

Now a script: (Which I prefer, which is basically copy and paste from Lua to mod.)

Code:
	[COLOR="Blue"]<event [/COLOR][COLOR="Red"]type[/COLOR]=[COLOR="DarkOrchid"]"login"[/COLOR] [COLOR="Red"]name[/COLOR]=[COLOR="DarkOrchid"]"FirstItems"[/COLOR] [COLOR="Red"]event[/COLOR]=[COLOR="DarkOrchid"]"script"[/COLOR][COLOR="Blue"]>[/COLOR][COLOR="Orange"]<![CDATA[
		domodlib('firstitems_config')

		function onLogin(cid)
			if(getPlayerStorageValue(cid, config.storage) > 0) then
				return true
			end

			for _, id in ipairs(config.items) do
				doPlayerAddItem(cid, id, 1)
			end

			if(getPlayerSex(cid) == PLAYERSEX_FEMALE) then
				doPlayerAddItem(cid, 2651, 1)
			else
				doPlayerAddItem(cid, 2650, 1)
			end

			doAddContainerItem(doPlayerAddItem(cid, 1987, 1), 2674, 1)
			setPlayerStorageValue(cid, config.storage, 1)
			return true
		end
]]>[/COLOR][COLOR="Blue"]</event>[/COLOR]

You can see that it used the function line, and returns. Much easier to convert, and buffers sometimes don't work, mainly because I don't know much about them.

So this script for example should be.

Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Control Training" version="1.0" author="Renusek" contact="localhost" enabled="yes">
	<info>
		This mod will enable training chakra control by walking on water.
	</info>
	<config name="control_config"/><![CDATA[
		pPos = getPlayerPosition(cid)
	]]></config>
	<movement type="StepIn" itemid="4820-4825" event="script"><![CDATA[
		domodlib(control_config)
		function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
				doSendMagicEffect(pPos, 1)
				doPlayerAddSkillTry(cid, 1, 1)
			return true
		end
	]]></movement>
</mod>
 
no.. you use CDATA for script and event, the CDATA just includes the "Lua Part" Heres a small tutorial I wrote for another thread.

well i know little about "buffer" but here is my rundown of it.

If you use "script" you include function with it and use return true/false
If you use "buffer" you dont need to include function and use _result = false/true

You probably didn't get it cause I barely did. So heres examples:

Code:
	[COLOR="Blue"]<action[/COLOR] [COLOR="Red"]itemid[/COLOR]=[COLOR="DarkOrchid"]"1981"[/COLOR] [COLOR="Red"]event[/COLOR]=[COLOR="DarkOrchid"]"buffer"[/COLOR][COLOR="Blue"]>[/COLOR][COLOR="Orange"]<![CDATA[
		if(item.actionid >= 150 and item.actionid <= 158) then
			doShowTextDialog(cid, item.itemid, getHighscoreString((item.actionid - 150)))
		else
			_result = false
		end
]]>[/COLOR][COLOR="Blue"]</action>[/COLOR]

You noticed how it didn't need to call the function OnUse? and it did not use return false, it used _result

Now a script: (Which I prefer, which is basically copy and paste from Lua to mod.)

Code:
	[COLOR="Blue"]<event [/COLOR][COLOR="Red"]type[/COLOR]=[COLOR="DarkOrchid"]"login"[/COLOR] [COLOR="Red"]name[/COLOR]=[COLOR="DarkOrchid"]"FirstItems"[/COLOR] [COLOR="Red"]event[/COLOR]=[COLOR="DarkOrchid"]"script"[/COLOR][COLOR="Blue"]>[/COLOR][COLOR="Orange"]<![CDATA[
		domodlib('firstitems_config')

		function onLogin(cid)
			if(getPlayerStorageValue(cid, config.storage) > 0) then
				return true
			end

			for _, id in ipairs(config.items) do
				doPlayerAddItem(cid, id, 1)
			end

			if(getPlayerSex(cid) == PLAYERSEX_FEMALE) then
				doPlayerAddItem(cid, 2651, 1)
			else
				doPlayerAddItem(cid, 2650, 1)
			end

			doAddContainerItem(doPlayerAddItem(cid, 1987, 1), 2674, 1)
			setPlayerStorageValue(cid, config.storage, 1)
			return true
		end
]]>[/COLOR][COLOR="Blue"]</event>[/COLOR]

You can see that it used the function line, and returns. Much easier to convert, and buffers sometimes don't work, mainly because I don't know much about them.

So this script for example should be.

Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Control Training" version="1.0" author="Renusek" contact="localhost" enabled="yes">
	<info>
		This mod will enable training chakra control by walking on water.
	</info>
	<config name="control_config"/><![CDATA[
		pPos = getPlayerPosition(cid)
	]]></config>
	<movement type="StepIn" itemid="4820-4825" event="script"><![CDATA[
		domodlib(control_config)
		function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
				doSendMagicEffect(pPos, 1)
				doPlayerAddSkillTry(cid, 1, 1)
			return true
		end
	]]></movement>
</mod>

Hm.. Still getting errors ;/. Look:
Code:
[21/08/2009 12:21:29] Loading control.xml...[Error - ScriptingManager::loadFromXml] Cannot load mod mods/control.xml
[21/08/2009 12:21:29] Line: 9, Info: Extra content at the end of the document


[21/08/2009 12:21:29]  failed!
 
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Control Training" version="1.0" author="Renusek" contact="localhost" enabled="yes">
	<description>
		This mod will enable training chakra control by walking on water.
	</description>
	<config name="control_config"><![CDATA[
		pPos = getPlayerPosition(cid)
	]]></config>
	<movement type="StepIn" itemid="4820-4825" event="script"><![CDATA[
		domodlib(control_config)
		function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
				doSendMagicEffect(pPos, 1)
				doPlayerAddSkillTry(cid, 1, 1)
			return TRUE
		end
	]]>
	</movement>
</mod>
 
Last edited:
Back
Top