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

Solved isNpc(uid) - how to check?

  • Thread starter Thread starter Xikini
  • Start date Start date
X

Xikini

Guest
Server version 0.3.7

I'm trying to determine if an Npc is on a tile or not.

I've tried multiple variations of finding the Npc on a tile however they either come back as
"attempt to index a number value" or Player not Found, or simply no error at all.

Going with a simple movement script, how do I check if it's an Npc, a creature, or a player without declaring the specific location of the tile?

Code:
function onStepIn(cid, item, fromPos, item2, toPos)
   if isNpc(cid) then
     doTeleportThing(cid, fromPos)
   end
   return true
end
 
The isNpc(cid) is correct, at least how it's added by default in data/lib/050-function.lua.
Code:
function onStepIn(cid, item, fromPos, item2, toPos)
These parameters are for action scripts.
Code:
function onStepIn(cid, item, position, fromPosition)
The third parameter in function onStepIn is the position you walk on, the fourth parameter is the last position.
So with the script you have now it teleports to the position it walks on, which means it looks like nothing happens.
 
The isNpc(cid) is correct, at least how it's added by default in data/lib/050-function.lua.
Code:
function onStepIn(cid, item, fromPos, item2, toPos)
These parameters are for action scripts.
Code:
function onStepIn(cid, item, position, fromPosition)
The third parameter in function onStepIn is the position you walk on, the fourth parameter is the last position.
So with the script you have now it teleports to the position it walks on, which means it looks like nothing happens.
Derp. Gotta keep reminding myself to stop using / get rid of old scripts created/modified by that imbecile.
I tend to just open a random movement script and delete everything then save new file with only the function, then start going.
@Limos always to the rescue. <3
Code:
function onStepIn(cid, item, position, fromPosition)
   if isNpc(cid) then
     doTeleportThing(cid, fromPosition)
   end
   return true
end
Weirdly enough it looks pretty terrible when the npc get's teleported back to it's fromPosition.

It looks like the creature is teleported onto the square then walks back to it's fromPosition.

Only a minor curiosity, but is there a better way to move the creature/npc to prevent that?
 
Last edited by a moderator:
Back
Top