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

getNextPosFromDir

slaw

Software Developer
Joined
Aug 27, 2007
Messages
3,657
Solutions
125
Reaction score
1,103
Location
Germany
GitHub
slawkens
PHP:
function getNextPosFromDir(fromPos, dir, size)
	local newPos =
	{
		[0]={x=fromPos.x,	y=fromPos.y-size,	z=fromPos.z}, 
		[1]={x=fromPos.x+size,	y=fromPos.y,		z=fromPos.z}, 
		[2]={x=fromPos.x,	y=fromPos.y+size,	z=fromPos.z}, 
		[3]={x=fromPos.x-size,	y=fromPos.y,		z=fromPos.z}
	}
	return newPos[dir]
end

This table was made by someone else, dont rememember. :rolleyes:

If you want get position, where player is looking + 5 squares.

newPos = getNextPosFromDir(getCreaturePos(cid), getPlayerLookDir(cid), 5)

example talkaction: (teleportntiles.lua)
PHP:
function onSay(cid, words, param)
	newPos = getNextPosFromDir(getCreaturePos(cid), getPlayerLookDir(cid), param)
	doTeleportThing(cid, newPos, TRUE)
end

talkactions.xml
PHP:
<talkaction filter="word" log="no" access="3" words="/a" script="teleportntiles.lua"/>
 
Last edited:
Back
Top