First u need this function:
http://otland.net/f163/lua-function-determination-nearest-town-town-closest-us-153316/
script:
http://otland.net/f163/lua-function-determination-nearest-town-town-closest-us-153316/
script:
Lua:
function onSay(cid, words, param, channel)
if(param == '') then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
return true
end
player_x = getPlayerByName(param)
poz = getCreaturePosition(player_x)
cid_poz = getCreaturePosition(cid)
roznica_pozX = (cid_poz.x - poz.x)
if roznica_pozX < 0 then
roznica_pozX = -roznica_pozX
end
roznica_pozY = (cid_poz.y - poz.y)
if roznica_pozY < 0 then
roznica_pozY = -roznica_pozY
end
roznica_pozow = math.floor((roznica_pozX^2 + roznica_pozY^2)^(1/2))
if roznica_pozow < 0 then
roznica_pozow = -roznica_pozow
end
lol = getNajblizej(poz)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player: " .. param .. " is " .. math.ceil(lol[2]) .. " squares from city: " .. lol[1] .. ". You are from target: " .. roznica_pozow .. " squares.")
return true
end