• 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 Metin Stones repair script

Bufo

-.-'
Joined
Jul 30, 2010
Messages
134
Reaction score
12
Location
P(R)OLAND
Hello I need some help.

Metin stones every x hours in map create monster look like stone and this monster don't attack and doing everything:
This is example Earth Stone:
PHP:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Earth Stone" nameDescription="a Earth Stone" race="blood" experience="5000000" speed="0" manacost="33000">
	<health now="1000000" max="1000000"/>
	<look typeex="1353" corpse="0"/>
	<targetchange interval="2000" chance="0"/>
	<strategy attack="0" defense="0"/>
	<flags>
<flag summonable="0"/>
<flag attackable="1"/>
<flag hostile="1"/>
<flag illusionable="0"/>
<flag convinceable="0"/>
<flag pushable="0"/>
<flag canpushitems="1"/>
<flag canpushcreatures="0"/>
<flag targetdistance="0"/>
<flag staticattack="0"/>
<flag runonhealth="550"/>
	</flags>
    <defenses name="healing" interval="4000" chance="11" min="580" max="1100">
      <attribute key="areaEffect" value="greenshimmer"/>
    </defenses>
	<elements>
     <element deathPercent="30"/>
     <element physicalPercent="30"/>
     <element holyPercent="40"/>
     <element firePercent="-15"/>
	</elements>
</monster>

There are 4 different stones and every x hours in map create 1 random stone:
Globalevents.xml:
PHP:
<globalevent name="stone" interval="x" event="script" value="stone.lua"/>

Stone.lua:
PHP:
config = {
		[1] = {x=1100, y=1012, z=6},
		[2] = {x=1100, y=1012, z=6},
		[3] = {x=1100, y=1012, z=6},
		[4] = {x=1100, y=1012, z=6},
		
		1 = "Earth Stone",
 		2 = "Icy Stone",
		3 = "Fire Stone",
		4 = "Wind Stone"
    }

function onThink(interval)
	rand = math.random(4)
		if rand == 1 then
			doCreateMonster(config.1,config[1])
			doBroadcastMessage('[Event Stones]\n '.. config.1 ..' have been spawn. Find and defeat it!', 22)
		end
		if rand == 2 then
			doCreateMonster(config.2,config[2])
			doBroadcastMessage("[Event Stones]\n ".. config.2 .." have been spawn. Find and defeat it!", 22)
		end
		if rand == 3 then
			doCreateMonster(config.3,config[3])
			doBroadcastMessage("[Event Stones]\n ".. config.3 .." have been spawn. Find and defeat it!", 22)
		end
		if rand == 4 then
			doCreateMonster(config.4,config[4])
			doBroadcastMessage("[Event Stones]\n ".. config.4 .." have been spawn. Find and defeat it!", 22)
		end
end

Can you repair globaleventscript becouse don't work ; /

Code:
[29/06/2011 10:39:45] [Error - LuaScriptInterface::loadFile] data/globalevents/scripts/stone.lua:7: '}' expected (to close '{' at line 1) near '='
[29/06/2011 10:39:45] [Warning - Event::loadScript] Cannot load script (data/globalevents/scripts/stone.lua)
[29/06/2011 10:39:45] data/globalevents/scripts/stone.lua:7: '}' expected (to close '{' at line 1) near '='

And if you have a time can you add function if player attack stone around stone create monster:
Code:
90% - 3x Hydra, 5x Bog Raider, 3x Plaguesmith.
70% - 3x Defiler, 2x Hellhound, 3x Plaguesmith, 4x Medusa.
50% - 3x Hellhound, 1x Azerus, 1x Defiler, 3x Plaguesmith, 2x Phantasm.
40% - 3x Massacre, 1x Azerus.
20% - 3x Juggernaut, 2x Azerus, 2x Defiler, 1x Hellhound.
5% - 3x Juggernaut, 2x Azerus, 2x Defiler, 4x Hellhound, 3x Plaguesmith, 2x Phantasm.

And player who set the most damage on the stone win random reward.

I am thanking in advance.
 
Last edited:
Code:
onStatsChange(cid, attacker, type, combat, value)
	local stones = {
				["Blue Stone"] = {
					[1] = { from = 100, to = 70, monsters = {{"Demon", 2}, {"Lion", 3}, {"Wyrm", 2}}},
					[2] = { from = 69, to = 31, monsters = {{"Demon", 2}, {"Hydra", 3}, {"Dragon", 2}}},
					[3] = { from = 30, to = 11, monsters = {{"Demon", 2}, {"Warlock", 3}, {"Medusa", 2}}},
					[4] = { from = 10, to = 1, monsters = {{"Demon", 2}, {"Juggernaut", 3}, {"Dragon Lord", 2}}}
					},
					
				["Red Stone"] = {
					[1] = { from = 100, to = 70, monsters = {{"Demon", 2}, {"Lion", 3}, {"Wyrm", 2}}},
					[2] = { from = 69, to = 31, monsters = {{"Demon", 2}, {"Hydra", 3}, {"Dragon", 2}}},
					[3] = { from = 30, to = 11, monsters = {{"Demon", 2}, {"Warlock", 3}, {"Medusa", 2}}},
					[4] = { from = 10, to = 1, monsters = {{"Demon", 2}, {"Juggernaut", 3}, {"Dragon Lord", 2}}}
					},
				
				["Green Stone"] = {
					[1] = { from = 100, to = 70, monsters = {{"Demon", 2}, {"Lion", 3}, {"Wyrm", 2}}},
					[2] = { from = 69, to = 31, monsters = {{"Demon", 2}, {"Hydra", 3}, {"Dragon", 2}}},
					[3] = { from = 30, to = 11, monsters = {{"Demon", 2}, {"Warlock", 3}, {"Medusa", 2}}},
					[4] = { from = 10, to = 1, monsters = {{"Demon", 2}, {"Juggernaut", 3}, {"Dragon Lord", 2}}}
					}
				}
	--[[ End Config ]]--
	local stone = stones[getCreatureName(cid)]

	if ( stone and type == "STATSCHANGE_HEALTHLOSS") then
		local a = {
					max_health = getCreatureMaxHealth(cid),
					now_health = getCreatureHealth(cid),
					percent_health = math.floor((100 * now_health) / max_health)
				}
				
		for k, v in ipairs(summon) do
			if (percent_health < v.from and percent_health > v.to) then
				for c, w in ipairs (v.monsters) do
					local area = getArea(getCreaturePosition(cid), 2, 2)
					i = 0
					while i < c[2] do
						doCreateMonster(c[1], area[math.random(#area)])
					end
				end
			end
		end
	end
	
return true
end
 
Code:
onStatsChange(cid, attacker, type, combat, value)
	local stones = {
				["Blue Stone"] = {
					[1] = { from = 100, to = 70, monsters = {{"Demon", 2}, {"Lion", 3}, {"Wyrm", 2}}},
					[2] = { from = 69, to = 31, monsters = {{"Demon", 2}, {"Hydra", 3}, {"Dragon", 2}}},
					[3] = { from = 30, to = 11, monsters = {{"Demon", 2}, {"Warlock", 3}, {"Medusa", 2}}},
					[4] = { from = 10, to = 1, monsters = {{"Demon", 2}, {"Juggernaut", 3}, {"Dragon Lord", 2}}}
					},
					
				["Red Stone"] = {
					[1] = { from = 100, to = 70, monsters = {{"Demon", 2}, {"Lion", 3}, {"Wyrm", 2}}},
					[2] = { from = 69, to = 31, monsters = {{"Demon", 2}, {"Hydra", 3}, {"Dragon", 2}}},
					[3] = { from = 30, to = 11, monsters = {{"Demon", 2}, {"Warlock", 3}, {"Medusa", 2}}},
					[4] = { from = 10, to = 1, monsters = {{"Demon", 2}, {"Juggernaut", 3}, {"Dragon Lord", 2}}}
					},
				
				["Green Stone"] = {
					[1] = { from = 100, to = 70, monsters = {{"Demon", 2}, {"Lion", 3}, {"Wyrm", 2}}},
					[2] = { from = 69, to = 31, monsters = {{"Demon", 2}, {"Hydra", 3}, {"Dragon", 2}}},
					[3] = { from = 30, to = 11, monsters = {{"Demon", 2}, {"Warlock", 3}, {"Medusa", 2}}},
					[4] = { from = 10, to = 1, monsters = {{"Demon", 2}, {"Juggernaut", 3}, {"Dragon Lord", 2}}}
					}
				}
	--[[ End Config ]]--
	local stone = stones[getCreatureName(cid)]

	if ( stone and type == "STATSCHANGE_HEALTHLOSS") then
		local a = {
					max_health = getCreatureMaxHealth(cid),
					now_health = getCreatureHealth(cid),
					percent_health = math.floor((100 * now_health) / max_health)
				}
				
		for k, v in ipairs(summon) do
			if (percent_health < v.from and percent_health > v.to) then
				for c, w in ipairs (v.monsters) do
					local area = getArea(getCreaturePosition(cid), 2, 2)
					i = 0
					while i < c[2] do
						doCreateMonster(c[1], area[math.random(#area)])
					end
				end
			end
		end
	end
	
return true
end

Please, add function*

Lua:
function onStatsChange(cid, attacker, type, combat, value)
	local stones = {
				["Blue Stone"] = {
					[1] = { from = 100, to = 70, monsters = {{"Demon", 2}, {"Lion", 3}, {"Wyrm", 2}}},
					[2] = { from = 69, to = 31, monsters = {{"Demon", 2}, {"Hydra", 3}, {"Dragon", 2}}},
					[3] = { from = 30, to = 11, monsters = {{"Demon", 2}, {"Warlock", 3}, {"Medusa", 2}}},
					[4] = { from = 10, to = 1, monsters = {{"Demon", 2}, {"Juggernaut", 3}, {"Dragon Lord", 2}}}
					},
					
				["Red Stone"] = {
					[1] = { from = 100, to = 70, monsters = {{"Demon", 2}, {"Lion", 3}, {"Wyrm", 2}}},
					[2] = { from = 69, to = 31, monsters = {{"Demon", 2}, {"Hydra", 3}, {"Dragon", 2}}},
					[3] = { from = 30, to = 11, monsters = {{"Demon", 2}, {"Warlock", 3}, {"Medusa", 2}}},
					[4] = { from = 10, to = 1, monsters = {{"Demon", 2}, {"Juggernaut", 3}, {"Dragon Lord", 2}}}
					},
				
				["Green Stone"] = {
					[1] = { from = 100, to = 70, monsters = {{"Demon", 2}, {"Lion", 3}, {"Wyrm", 2}}},
					[2] = { from = 69, to = 31, monsters = {{"Demon", 2}, {"Hydra", 3}, {"Dragon", 2}}},
					[3] = { from = 30, to = 11, monsters = {{"Demon", 2}, {"Warlock", 3}, {"Medusa", 2}}},
					[4] = { from = 10, to = 1, monsters = {{"Demon", 2}, {"Juggernaut", 3}, {"Dragon Lord", 2}}}
					}
				}
	--[[ End Config ]]--
	local stone = stones[getCreatureName(cid)]

	if ( stone and type == "STATSCHANGE_HEALTHLOSS") then
		local a = {
					max_health = getCreatureMaxHealth(cid),
					now_health = getCreatureHealth(cid),
					percent_health = math.floor((100 * now_health) / max_health)
				}
				
		for k, v in ipairs(summon) do
			if (percent_health < v.from and percent_health > v.to) then
				for c, w in ipairs (v.monsters) do
					local area = getArea(getCreaturePosition(cid), 2, 2)
					i = 0
					while i < c[2] do
						doCreateMonster(c[1], area[math.random(#area)])
					end
				end
			end
		end
	end
	
return true
end

I love this code, anyway! <3.
 
Eh... don't working for me;/
IDK why... I change:
Lua:
["Blue Stone"]
to:
Lua:
["Earth Stone"]
Add all lines to login.lua and creaturescripts.xml and I put into Earth Stone:
Lua:
		<script>
			<event name="monster_summoning"/>
		</script>
And it don't working...

Sorry for my English ;)
 
Try this one, the upper had some bugs coz i've made it fast.
Code:
function onStatsChange(cid, attacker, type, combat, value)
	local stones = {
				["Blue Stone"] = {
					[1] = { from = 100, to = 70, monsters = {{"Demon", 2}, {"Lion", 3}, {"Wyrm", 2}}},
					[2] = { from = 69, to = 31, monsters = {{"Demon", 2}, {"Hydra", 3}, {"Dragon", 2}}},
					[3] = { from = 30, to = 11, monsters = {{"Demon", 2}, {"Warlock", 3}, {"Medusa", 2}}},
					[4] = { from = 10, to = 1, monsters = {{"Demon", 2}, {"Juggernaut", 3}, {"Dragon Lord", 2}}}
					},
					
				["Red Stone"] = {
					[1] = { from = 100, to = 70, monsters = {{"Demon", 2}, {"Lion", 3}, {"Wyrm", 2}}},
					[2] = { from = 69, to = 31, monsters = {{"Demon", 2}, {"Hydra", 3}, {"Dragon", 2}}},
					[3] = { from = 30, to = 11, monsters = {{"Demon", 2}, {"Warlock", 3}, {"Medusa", 2}}},
					[4] = { from = 10, to = 1, monsters = {{"Demon", 2}, {"Juggernaut", 3}, {"Dragon Lord", 2}}}
					},
				
				["Green Stone"] = {
					[1] = { from = 100, to = 70, monsters = {{"Demon", 2}, {"Lion", 3}, {"Wyrm", 2}}},
					[2] = { from = 69, to = 31, monsters = {{"Demon", 2}, {"Hydra", 3}, {"Dragon", 2}}},
					[3] = { from = 30, to = 11, monsters = {{"Demon", 2}, {"Warlock", 3}, {"Medusa", 2}}},
					[4] = { from = 10, to = 1, monsters = {{"Demon", 2}, {"Juggernaut", 3}, {"Dragon Lord", 2}}}
					}
				}
	--[[ End Config ]]--
	local stone = stones[getCreatureName(cid)]

	if ( stone and type == STATSCHANGE_HEALTHLOSS) then
		local a = {
					max_health = getCreatureMaxHealth(cid),
					now_health = getCreatureHealth(cid),
					percent_health = math.floor((100 * now_health) / max_health)
				}
				
		for k, v in ipairs(stone) do
			if (percent_health < v.from and percent_health > v.to) then
				for c, w in ipairs (v.monsters) do
					local area = getArea(getCreaturePosition(cid), 2, 2)
					for i = 0, w[2] do
						doCreateMonster(w[1], area[math.random(#area)])
					end
				end
			end
		end
	end
	
return true
end

creaturescripts.xml
Code:
<event type="statschange" name="metinstones" event="script" value="metinstones.lua"/>

Login.lua
Code:
registerCreatureEvent(cid, "metinstones")

Not tested but should work.
 
have u changed this
Code:
<script>
			<event name="monster_summoning"/>
		</script>

to

Code:
<script>
			<event name="metinstones"/>
		</script>

in monster file?
What rev are u using?
 
My friend send me link to thread and error from console.
Fixed & optimized version (but not checked):
Lua:
local stones = {
		["Blue Stone"] = {
			[1] = { from = 100, to = 70, monsters = {{"Demon", 2}, {"Lion", 3}, {"Wyrm", 2}}},
			[2] = { from = 69, to = 31, monsters = {{"Demon", 2}, {"Hydra", 3}, {"Dragon", 2}}},
			[3] = { from = 30, to = 11, monsters = {{"Demon", 2}, {"Warlock", 3}, {"Medusa", 2}}},
			[4] = { from = 10, to = 1, monsters = {{"Demon", 2}, {"Juggernaut", 3}, {"Dragon Lord", 2}}}
			},
			
		["Red Stone"] = {
			[1] = { from = 100, to = 70, monsters = {{"Demon", 2}, {"Lion", 3}, {"Wyrm", 2}}},
			[2] = { from = 69, to = 31, monsters = {{"Demon", 2}, {"Hydra", 3}, {"Dragon", 2}}},
			[3] = { from = 30, to = 11, monsters = {{"Demon", 2}, {"Warlock", 3}, {"Medusa", 2}}},
			[4] = { from = 10, to = 1, monsters = {{"Demon", 2}, {"Juggernaut", 3}, {"Dragon Lord", 2}}}
			},
		
		["Green Stone"] = {
			[1] = { from = 100, to = 70, monsters = {{"Demon", 2}, {"Lion", 3}, {"Wyrm", 2}}},
			[2] = { from = 69, to = 31, monsters = {{"Demon", 2}, {"Hydra", 3}, {"Dragon", 2}}},
			[3] = { from = 30, to = 11, monsters = {{"Demon", 2}, {"Warlock", 3}, {"Medusa", 2}}},
			[4] = { from = 10, to = 1, monsters = {{"Demon", 2}, {"Juggernaut", 3}, {"Dragon Lord", 2}}}
			}
		}
--[[ End Config ]]--

function onStatsChange(cid, attacker, type, combat, value)
	local stone = stones[getCreatureName(cid)]

	if(type == STATSCHANGE_HEALTHLOSS) then
		if(stone) then
			percent_health = math.floor((100 * getCreatureHealth(cid)) / getCreatureMaxHealth(cid))

			for k, v in ipairs(stone) do
				if (percent_health < v.from and percent_health > v.to) then
					for c, w in ipairs (v.monsters) do
						local area = getArea(getCreaturePosition(cid), 2, 2)
						for i = 0, w[2] do
							doCreateMonster(w[1], area[math.random(#area)])
						end
					end
				end
			end
		end
	end

	return true
end

REPORT BUGS
 
Back
Top