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

Solved [Lua] Anti-AOE Error. Any help appreciated.

Skylinx

Game Programmer
Joined
Nov 26, 2008
Messages
399
Reaction score
14
Location
TORONTO, CANADA
Hello. I'm using an Anti-AOE creatureevent script by Erexo that's supposed to only deal damage to players you are targeting using AOE spells.
(Doesn't apply to creatures)

The script:

Code:
function onStatsChange(cid, attacker, type, combat, value)
	if(attacker and isPlayer(attacker) and (type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS) and getCreatureName(getCreatureTarget(attacker)) ~= getCreatureName(cid)) then
		if combat ~= COMBAT_HEALING then
			return false
		end 
	end
return true
end
--By Erexo (hail OTLand)
function onCombat(cid, target) 
    if(target and isPlayer(target) and getCreatureName(getCreatureTarget(cid)) ~= getCreatureName(target)) then 
        return false 
    end 
return true 
end

Code:
[17/05/2013 09:29:22] [Error - CreatureScript Interface] 
[17/05/2013 09:29:22] data/creaturescripts/scripts/AntiAOE.lua:onCombat
[17/05/2013 09:29:22] Description: 
[17/05/2013 09:29:22] (luaGetCreatureName) Creature not found
I really like this feature. It's something I'd like to add in, except I get this error.

I get this error whenever I use a spell and it hits a player, OR whenever I try attacking a player. I basically cannot PVP. Whenever I try targeting a player, it says sorry not possible and sends that error.

Any help would be appreciated, I've looked at the script a few times and I can't seem to figure out why.

Thanks
 
Last edited:
Lua:
function onStatsChange(cid, attacker, type, combat, value)
	local _target = getCreatureTarget(attacker)
	if isPlayer(attacker) and isInArray({STATSCHANGE_MANALOSS, STATSCHANGE_HEALTHLOSS}, type) and _target ~= cid then
		if combat ~= COMBAT_HEALING then
			return false
		end 
	end
	return true
end


function onCombat(cid, target)
	local _target = getCreatureTarget(cid)
    if isPlayer(target) and target ~= _target then 
        return false 
    end 
	return true 
end

Try this
 
Lua:
function onStatsChange(cid, attacker, type, combat, value)
	local _target = getCreatureTarget(attacker)
	if isPlayer(attacker) and isInArray({STATSCHANGE_MANALOSS, STATSCHANGE_HEALTHLOSS}, type) and _target ~= cid then
		if combat ~= COMBAT_HEALING then
			return false
		end 
	end
	return true
end


function onCombat(cid, target)
	local _target = getCreatureTarget(cid)
    if isPlayer(target) and target ~= _target then 
        return false 
    end 
	return true 
end

Try this

Uhm lol this completely destroyed whats called PvP on my server :D I mean seriously :D I can't target a player :D "Sorry not possible" xD

Even runes do 0 dmg :D what a funny problem xD
 
Last edited:
Yeah, on 0.3.6pl1 it isn't working. I get no error in otserv's console, but still I can't attack anyone. Can someone fix that?

Regards
 
Last edited:
Back
Top