• 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 Max distance between a summon and player (pokemon)

zirra

Member
Joined
Jun 11, 2009
Messages
343
Solutions
1
Reaction score
7
Location
Arizona, Usa
SOLVED!!

Problem:
Hey so I'm in the works of developing an English pokemon server as part of my live portfolio, and I cannot find any advice on this problem. The only relevant script I have found in my files is this one, this is not my script it came with the server I downloaded but it simply doesn't work. I've tried editing the local max, edited the false to true and vice versa. nothing changes.. any ideas?

Code:
local effect = 1 -- put 0 to remove the effect when the Pokemon teleport
local max = 5 -- max distance between Pokemon and the player
local function doIncreaseSpeed(cid)
if not isCreature(cid) then return true end
doChangeSpeed(cid, -getCreatureSpeed(cid))
doChangeSpeed(cid, 2.5*(getCreatureBaseSpeed(cid) + getSpeed(cid)))
end

function onThink(cid, interval)

if true then --not isCreature(cid) then
return true
end


if getPlayerStorageValue(cid, 17000) >= 1 or getPlayerStorageValue(cid, 17001) >= 1 or getPlayerStorageValue(cid, 63215) >= 1 then
return true
end

if #getCreatureSummons(cid) >= 1 and not isCreature(getCreatureTarget(cid)) then

    if getDistanceBetween(getThingPos(cid), getThingPos(getCreatureSummons(cid)[1])) > max then
    doTeleportThing(getCreatureSummons(cid)[1], getThingPos(cid), false)
    doSendMagicEffect(getThingPos(cid), 21)
    end
end

return true
end

Solution:
here is what I had to do

first i had to replace
Code:
if true then --not isCreature(cid) then
with
Code:
if not isCreature(cid) then

Then add this
Code:
registerCreatureEvent(cid, "PokemonIdle")
right underneath function onlogin so it looks like this.
Code:
function onLogin(cid)
registerCreatureEvent(cid, "PokemonIdle")

thank you guys for the help, and thank you @MatheusMkalo for the solution.
 
Last edited:
this is your problem
Code:
if true then
That first statement? line 11 counting blank lines, If true then --not iscreature~? do i change that to if false?

Edit: changing it to false doesn't change anything lol. So maybe i need to delete it?
Edit2: Deleting does nothing as well haha.
 
Last edited:
That first statement? line 11 counting blank lines, If true then --not iscreature~? do i change that to if false?

Edit: changing it to false doesn't change anything lol. So maybe i need to delete it?
Edit2: Deleting does nothing as well haha.

This script is weird, it defines effect not used anywhere, and a local function not used anywhere also. It won't work with players with storages 17000, 17001, 63215, no idea why, since I don't know what they are used in your server. Try this:

Code:
local max = 5 -- max distance between Pokemon and the player

function onThink(cid, interval)

   if not isCreature(cid) then
     return true
   end

   if #getCreatureSummons(cid) >= 1 and not isCreature(getCreatureTarget(cid)) then
     if getDistanceBetween(getThingPos(cid), getThingPos(getCreatureSummons(cid)[1])) > max then
       doTeleportThing(getCreatureSummons(cid)[1], getThingPos(cid), false)
       doSendMagicEffect(getThingPos(cid), 21)
     end
   end

   return true
end
 
yeah i have no idea either haha, like i said this was just one of those scripts that came with it. I will try it out for sure and let you know if it worked. Is there rep+ anymore? i cant seem to find it.

Edit: That code did not help lol. it still doesnt teleport to player >.<
 
Last edited:
Is there rep+ anymore?
GqdQ8.jpg
 
Back
Top