• 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 Function error in zombie event.

Shadowman321

Member
Joined
Mar 27, 2010
Messages
205
Reaction score
22
PHP:
 [Error - CreatureScript Interface]
data/creaturescripts/scripts/zombie/onattack.luanStatsChange
Description:
data/lib/032-position.lua:2: attempt to index global 'position' (a nil value)
stack traceback:
data/lib/032-position.lua:2: in function 'isInRange'
data/creaturescripts/scripts/zombie/onattack.lua:36: in function <data/creaturescripts/scripts/zombie/onattack.lua:35>
Event works fine, but monsters can't attack players. They attack and deal 0 dmg.

Topic: http://otland.net/f82/zombie-event-new-version-bug-free-updated-128664/

- - - Updated - - -

Its something wrong with it?
PHP:
function isInRange(pos, fromPosition, toPosition)
        return (position.x >= fromPosition.x and position.y >= fromPosition.y and position.z >= fromPosition.z and position.x <= toPosition.x and position.y <= toPosition.y and position.z <= toPosition.z)
end
Whats the correct positions to use in this function?

isInRange(getThingPosition(target), ZE_spawnFromPosition, ZE_spawnToPosition)
Where
ZE_spawnFromPosition = {x = 745, y = 1085, z = 7}
ZE_spawnToPosition = {x = 781, y = 1108, z = 7}
Does not work.
I think i need to change pos near function isInRange, but i dont know how it have to looks like. Someone help?

@EDIT
Ok my error is solved. I have change method. Changed isInRange to getPlayerStorageValue. Changing on enter and on attack(when exit). And it works.

I still dont know how to use isInRange, so can anyone help?
 
Last edited:
Code:
function isInRange(pos, fromPosition, toPosition)
        return (position.x >= fromPosition.x and position.y >= fromPosition.y and position.z >= fromPosition.z and position.x <= toPosition.x and position.y <= toPosition.y and position.z <= toPosition.z)
end
change "pos" to "position" if you're not sure, here it is how it's done (see the highlighted part):
Code:
function isInRange([b][color="red"]position[/color][/b], fromPosition, toPosition)
        return (position.x >= fromPosition.x and position.y >= fromPosition.y and position.z >= fromPosition.z and position.x <= toPosition.x and position.y <= toPosition.y and position.z <= toPosition.z)
end
 
Back
Top