Object Search & Validation¶
gObjFind(name)¶
Finds a connected player by character name. Returns GameObject or nil.
local target = gObjFind("SomePlayer")
if target then
LogAdd(LOG_BLUE, "Found " .. target.Name .. " at map " .. target.Map)
end
gObjCalcDistance(lpObj, lpTarget) / gObjCalcDistance(x, y, tx, ty)¶
Calculates the distance between two objects or two coordinate pairs.
- Returns:
number(-1 if invalid pointers)
local dist = gObjCalcDistance(player, target)
if dist <= 3 then
LogAdd(LOG_GREEN, "Target is within melee range.")
end
-- Coordinate version
local dist2 = gObjCalcDistance(100, 100, 105, 105)
FindMonsterClassInVP(lpObj, class, distance)¶
Checks if a monster of the given class exists in the object's viewport within the given distance.
- Returns:
boolean
FindMonsterCharacterInVP(lpObj, bIndex)¶
Checks if a specific object index exists in the object's viewport.
- Returns:
boolean
if FindMonsterCharacterInVP(monster, player.Index) then
LogAdd(LOG_RED, "Player is visible to the monster.")
end
gObjIsConnected(aIndex) / gObjIsConnected(aIndex, dbNumber)¶
Returns true if the object at the given index is connected. The two-parameter version also checks the database number.
gObjIsConnectedGP(aIndex)¶
Returns true if the object is connected at the GamePlay state.
gObjIsConnectedGS(aIndex)¶
Returns true if the object is connected at the GameServer state.
gObjIsNameValid(aIndex, name)¶
Validates that the object at aIndex has the given character name.
- Returns:
boolean
gObjIsAccountValid(aIndex, account, accountIndex, [login])¶
Validates the account name and index for the given object.
- Returns:
boolean
gObjSearchDuplicateItem(lpObj) / gObjSearchDuplicateItem(lpObj, serial)¶
Searches for duplicate items in the player's inventory. The single-parameter version checks all items; the two-parameter version checks a specific serial.
- Returns:
boolean
Help