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

addEvent not working

Scarlet Ayleid

Advanced OT User
Senator
Joined
Jul 7, 2007
Messages
4,049
Reaction score
238
Hey =)

I have a problem with this script I'm currently making, its a spell that should doCombat once per each weapon the player has in its backpacks, for example, if the player is equipped with a Warlock Sword and has 2 Magic Swords and a Magic Long Sword in its backpacks, it should attack once with the power of the Warlock Sword, twice with the power of Magic Sword and once with the power of Magic Long Sword

PHP:
Weapons = {--165 Total Weapons
	--56 Clubs
		2423, 7381, 7425, 7432, 2434, 7387, 7379, 7430, 2436, 7437, 7424, 3961, 2424, 7452, 2445, 7451, 7392, 7426, 7427, 2391, 7410, 7428, 7415, 7414, 7421, 2444, 2452, 7422, 7429, 2453, 2437, 7431, 2421, 8928, 8929, 8927, 7754, 7755, 7756, 7757, 7758, 7773, 7774, 7775, 7776, 7777, 7864, 7865, 7866, 7867, 7868, 7879, 7880, 7881, 7882, 7883,
	--53 Swords
		2396, 2413, 7385, 2377, 7408, 7449, 2392, 2407, 2438, 7407, 7406, 2451, 7404, 7386, 2446, 7402, 7383, 7391, 7416, 2393, 7384, 7382, 7417, 7403, 7418, 7405, 7390, 6528, 2400, 8930, 8932, 2408, 2390, 7744, 7745, 7746, 7747, 7748, 7763, 7764, 7765, 7766, 7767, 7854, 7855, 7856, 7857, 7858, 7869, 7870, 7871, 7872, 7873,
	--56 Axes
		2429, 2435, 2425, 2430, 2387, 2381, 2440, 2426, 3962, 7454, 2432, 7380, 7456, 7419, 7413, 7412, 7436, 7411, 2447, 7388, 2427, 7389, 2414, 2454, 2443, 7420, 7434, 6553, 7455, 7453, 2431, 2415, 7435, 7423, 8924, 8925, 7749, 7750, 7751, 7752, 7753, 7768, 7769, 7770, 7771, 7772, 7859, 7860, 7861, 7862, 7863, 7874, 7875, 7876, 7877, 7878
}

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, true)
setCombatParam(combat, COMBAT_PARAM_BLOCKSHIELD, true)
setCombatFormula(combat, COMBAT_FORMULA_SKILL, 1, -0, 1, -0)

function Strike(cid,combat,var,Effect)
	if getCreatureTarget(cid) ~= nil then
		doSendDistanceShoot(getCreaturePosition(cid), getCreaturePosition(getCreatureTarget(cid)), Effect)
		return doCombat(cid,combat,var)
	end
	return true
end

function onCastSpell(cid, var)
	local Time = 0
	for i=1,165 do
		local WeaponCount = getPlayerItemCount(cid, Weapons[i])
		if WeaponCount >= 1 then
			local CurWeapon = getPlayerItemById(cid, true, Weapons[i])
			local NormalWeapon = getPlayerWeapon(cid)
			local NormalWeaponItemID = NormalWeapon.itemid
			doTransformItem(NormalWeapon.uid,Weapons[i])
			for x=1,WeaponCount do
				local Effect = getWeaponDistanceEffect(CurWeapon.uid)
				addEvent(Strike,Time,cid,combat,var,Effect)
				Time = Time + 100
			end
			doTransformItem(getPlayerWeapon(cid).uid,NormalWeaponItemID)
		end
	end
	return true
end


function getWeaponDistanceEffect(uid)
	local WeaponType = getItemWeaponType(uid)
	if WeaponType == SKILL_CLUB then
		return CONST_ANI_WHIRLWINDCLUB
	elseif WeaponType == SKILL_SWORD then
		return CONST_ANI_WHIRLWINDSWORD
	elseif WeaponType == SKILL_AXE then
		return CONST_ANI_WHIRLWINDAXE
	else
		return false
	end
end

The strategy I use is saving the player current weapon itemid and then trasforming its weapon into the weapon the player has in the backpack, launch the addEvent and then change it back into his original weapon itemid

I have already debugged the code(made tons of prints thru the code to see where it went through) and the code works as it should, the only problem is that the addEvent doesnt happen :S

I'm using TFS 0.3.5pl1 (Crying Damson)
Anything that I might be forgetting or some stupid bug I didnt saw?

Thanks in Advance =)
Quetzalma
 
Last edited:
Back
Top