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

VirrageS

←•†ĿuĀ && ©¤¤•→
Joined
May 30, 2010
Messages
984
Reaction score
63
Location
Poland
Hello!!

I have found script with catapult which is atacking players.
And everything is fine except for one detail. So when I added this script to MOD it spaming in TFS every 5 sec:


Code:
[15:59:25.765] [Error - GlobalEvent Interface]
[15:59:25.765]          local config = {
[15:59:25.765]                 catapult = {x = 95 , y = 125 , z = 7},
[15:59:25.765]                 catapultmindmg = 100,
[15:59:25.765]                 catapultmaxdmg = 300
[15:59:25.765]           }
[15:59:25.765]
[15:59:25.765]          function onThink(interval, lastExecution)
[15:59:25.765]                  local spec = getSpectators(config.catapult, 9, 9, false)
[15:59:25.765]                  local damage = math.random(config.catapultmindmg, config.catapultmaxdmg)
[15:59:25.765]                  local target = spec[i]
[15:59:25.765]                  local targetpos = getCreaturePosition(target)
[15:59:25.765]
[15:59:25.765]                  if (target ~= nil and tragetpos ~= nil) then
[15:59:25.765]                          for i = 1, table.getn(spec) do
[15:59:25.765]                                  if (isNpc(Target) == false and getCreatureStorage(cid, config.storage) == config.valuestorage and shooted == false) then
[15:59:25.765]                                          doSendDistanceShoot(config.catapult, targetpos, CONST_ANI_LARGEROCK)
[15:59:25.765]                                          doSendMagicEffect(targetpos, CONST_ME_BLOCKHIT)
[15:59:25.765]                                          doCreatureAddHealth(target, -damage)
[15:59:25.765]                                          doSendAnimatedText(targetpos, damage, TEXTCOLOR_RED)
[15:59:25.765]                                          shooted = true
[15:59:25.765]                                  return true
[15:59:25.765]                                  end
[15:59:25.765]                          end
[15:59:25.765]                  return true
[15:59:25.765]                  end
[15:59:25.765]          return true
[15:59:25.765]          end
[15:59:25.765]  :onThink
[15:59:25.765] Description:
[15:59:25.765] (luaGetThingPosition) Thing not found

Here is script:
Lua:
	<globalevent name="Castle_Catapult" interval="5000" event="script"><![CDATA[
		local config = {
				catapult = {x = 95 , y = 125 , z = 7},
				catapultmindmg = 100,
				catapultmaxdmg = 300
		}
		
		function onThink(interval, lastExecution)
			local spec = getSpectators(config.catapult, 9, 9, false)
			local damage = math.random(config.catapultmindmg, config.catapultmaxdmg)
			local target = spec[i]
			local targetpos = getCreaturePosition(target)
			
			if (target ~= nil and tragetpos ~= nil) then
				for i = 1, table.getn(spec) do
					if (isNpc(Target) == false and getCreatureStorage(cid, config.storage) == config.valuestorage and shooted == false) then
						doSendDistanceShoot(config.catapult, targetpos, CONST_ANI_LARGEROCK)
						doSendMagicEffect(targetpos, CONST_ME_BLOCKHIT)
						doCreatureAddHealth(target, -damage)
						doSendAnimatedText(TargetPos, Damage, TEXTCOLOR_RED)
						shooted = true
					return true
					end
				end
			return true
			end
		return true
		end
	]]></globalevent>

Can someone help me :huh:??

I will be very thankful :thumbup:!!
 
Hmm... So it looking for target throught this:
Lua:
getSpectators(config.catapult, 9, 9, false)
And if find them catapult shooting to them :).


P.S. Someone know how reperair this script?? :blink:
 
try this:
Code:
<globalevent name="Castle_Catapult" interval="5000" event="script"><![CDATA[
	local config = {
		catapult = {x = 95 , y = 125 , z = 7},
		catapultmindmg = 100,
		catapultmaxdmg = 300
	}
	function onThink(interval, lastExecution)
		local spec = getSpectators(config.catapult, 9, 9, false)
		local damage = math.random(config.catapultmindmg, config.catapultmaxdmg)
		for i = 1, #spec do
			local target = spec[i]
			if (target ~= nil and getCreaturePosition(target) ~= nil) then
				if (isNpc(target) == false and getCreatureStorage(target, config.storage) == config.valuestorage and shooted == false) then
					doSendDistanceShoot(config.catapult, getCreaturePosition(target), CONST_ANI_LARGEROCK)
					doSendMagicEffect(getCreaturePosition(target), CONST_ME_BLOCKHIT)
					doCreatureAddHealth(target, -damage)
					doSendAnimatedText(getCreaturePosition(target), Damage, TEXTCOLOR_RED)
					shooted = true
					return true
				end
				return true
			end
			return true
		end
		return true
	end
]]></globalevent>
 
Back
Top