• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

range talkaction

Nerevr back

Member
Joined
Nov 7, 2014
Messages
269
Reaction score
7
i have this spell and want to edite it for if u don't see player or range nore than 7 can't use this talkaction.
Code:
function onSay(cid, words, param)
if (not exhaustion.check(cid, 87924)) then
     if param == "" then
         return doPlayerSendCancel(cid, "Add a name.")
     end
     if getPlayerVocation(cid) ~= 10 then
     return doPlayerSendCancel(cid, "this spell only for epic elder druid.")
end
     local tid = getPlayerByNameWildcard(param)
     if not tid then
         return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. param .. " not found.")
     elseif tid == cid then
         return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can not use this on yourself.")
     end
     doSendDistanceShoot(getThingPosition(cid), getThingPosition(tid), CONST_ANI_ENERGYBALL)
     doCreatureSetStorage(tid, 70308, 1)
doPlayerSendTextMessage(tid, MESSAGE_STATUS_CONSOLE_BLUE, ""..getCreatureName(cid).." send you text.")
            doCreatureSay(cid, words, TALKTYPE_ORANGE_1)
            exhaustion.set(cid, 87924, 3600)
     return true
else
        doPlayerSendCancel(cid, "You will be able to use this spell again in  "..exhaustion.get(cid, 17023).." seconds.")
        return false
    end
    end
 
I'm pretty sure this is going to fail cause if I remember right its only 5 sqms on the screen vertically from the center.
Code:
function getDistanceBetween(fromPosition, toPosition)
   local x, y = math.abs(fromPosition.x - toPosition.x), math.abs(fromPosition.y - toPosition.y)
   local diff = math.max(x, y)
   if(fromPosition.z ~= toPosition.z) then
     diff = diff + 9 + 6
   end

   return diff
end
PlayerP:800,506,7
TargetP:810,512,7
X = 810-800 = 10
Y = 512-506 = 6
Since they are on same Z so it will output 10 o_O?
+
OP Request:
if u don't see player or range nore than 7 can't use this talkaction.

This would do the job i suppose

Correct me if i am mistaken.
 
Code:
function getDistanceBetween(fromPosition, toPosition)
   local x, y = math.abs(fromPosition.x - toPosition.x), math.abs(fromPosition.y - toPosition.y)
   local diff = math.max(x, y)
   if(fromPosition.z ~= toPosition.z) then
     diff = diff + 9 + 6
   end

   return diff
end
PlayerP:800,506,7
TargetP:810,512,7
X = 810-800 = 10
Y = 512-506 = 6
Since they are on same Z so it will output 10 o_O?
+
OP Request:
if u don't see player or range nore than 7 can't use this talkaction.

This would do the job i suppose

Correct me if i am mistaken.
i have this function in 032 position and i used
Code:
if getDistanceBetween(getThingPos(cid),getThingPos(tid)) <= 7 then
    return doPlayerSendCancel(cid, "creature not in range.")
    end
give me error "" attempt to index local 'toposition' <a boolean value
 
Last edited:
i have this function in 032 position and i used
Code:
if getDistanceBetween(getThingPos(cid),getThingPos(tid)) <= 7 then
    return doPlayerSendCancel(cid, "creature not in range.")
    end
give me error "" attempt to index local 'tpposition' <a boolean value
you can simply read the error and its line and fix it.. it says tpposition
 
full erro
qhRm4dE.bmp
 
and the code i asked for?
lib
Code:
function getDistanceBetween(fromPosition, toPosition)
    local x, y = math.abs(fromPosition.x - toPosition.x), math.abs(fromPosition.y - toPosition.y)
    local diff = math.max(x, y)
    if(fromPosition.z ~= toPosition.z) then
        diff = diff + 9 + 6
    end
Code:
function onSay(cid, words, param)
if getDistanceBetween(getThingPos(cid),getThingPos(tid)) <= 7 then
return doPlayerSendCancel(cid, "creature not in range.")
end
if (not exhaustion.check(cid, 87924)) then
     if param == "" then
         return doPlayerSendCancel(cid, "Add a name.")
     end
     if getPlayerVocation(cid) ~= 10 then
     return doPlayerSendCancel(cid, "this spell only for epic elder druid.")
end
     local tid = getPlayerByNameWildcard(param)
     if not tid then
         return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. param .. " not found.")
     elseif tid == cid then
         return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can not use this on yourself.")
     end
     doSendDistanceShoot(getThingPosition(cid), getThingPosition(tid), CONST_ANI_ENERGYBALL)
     doCreatureSetStorage(tid, 70308, 1)
doPlayerSendTextMessage(tid, MESSAGE_STATUS_CONSOLE_BLUE, ""..getCreatureName(cid).." send you text.")
            doCreatureSay(cid, words, TALKTYPE_ORANGE_1)
            exhaustion.set(cid, 87924, 3600)
     return true
else
        doPlayerSendCancel(cid, "You will be able to use this spell again in  "..exhaustion.get(cid, 17023).." seconds.")
        return false
    end
    end
 
Back
Top