Biblioteca de funções lua/SVN
Bom, como o nome do tópico diz, o tópico é uma biblioteca das funções SVN com explicações (só serão adicionadas funções SVN!)Nem todas as funções estão explicadas (são muitas), mas vou atualizando na medida do possível.
As funções que ainda não estão explicadas estão em um quotadas no fim do post.
Se você quizer procurar por uma função específica, aperte Ctrl+F e seja feliz
Pelo amor de deus, se for copiar, me avise por mp e dê os devidos créditos, né? '-'
Definições da biblioteca [Necessário ler!]
.: cid ~> um numero de identificação temporário do player. Irá mudar a cada vez que o server fechar ou que o player sair do server.~> Geralmente é passado pela função, mas pode também ser conseguido chamando
~> a função getThingfromPos() com a stackpos 253 (stack de criaturas)
.: GUID ~> Número de identificação do player (campo 'id' da tabela 'players' da database)~> A diferença do GUID com o cid é que o GUID é permanente. Embora os dois sirvam para identificar o player,
~> você não pode passar o GUID de um player pra uma função lua como se fosse o cid! São coisas diferentes!
.: opcional ~> um atributo opcional é aquele que você não precisa obrigatoriamente passá-lo pra função, pode ser ignorado~> Um exemplo de função com atributo opcional é a getPlayerItemCount()
~> getPlayerItemCount(cid, ID_DO_ITEM) ou getPlayerItemCount(cid, ID_DO_ITEM, TIPO_DO_ITEM)
.: itemtable ~> é uma variável que guarda informações de um item.~> Um exemplo de itemtable é o 2º argumento da onUse (item)
~> function onUse(cid, item, frompos, item2, topos)
.:. itemtable.uid ~> retorna o uid do item
.:. itemtable.itemid ~> retorna o itemid do item
.:. itemtable.type ~> retorna o tipo do item (ou o count)
.:. itemtable.actionid ~> retorna a actionid do item
.:. creaturetable ~> é uma variável que guarda informações de uma criatura.~> Um exemplo de creaturetable é o retorno de getThingfromPos()
~> quando você usa stackpos 253 (stack de creatures)
~> creaturetable = getThingfromPos({x=player_pos_x, y=player_pos_y, z=player_pos_z, stackpos=253})
.:. creaturetable.uid ~> retorna o uid da criatura (cid do player)
.:. creaturetable.itemid ~> é sempre 1 para criaturas
.:. creaturetable.type ~> 1 para player, 2 para monster, 3 para npc
.:. creaturetable.actionid ~> é sempre 0 para criaturas
.:. spelltable ~> é uma variável que guarda informações de um spell.~> Um exemplo de creaturetable é o retorno de getPlayerInstantSpellInfo(cid, index)
.:. spelltable.name ~> o nome da magia
.:. spelltable.words ~> as "palavras mágicas" da spell
.:. spelltable.level ~> o level da spell
.:. spelltable.mlevel ~> o magic level (ml) da spell
.:. spelltable.mana ~> a mana gasta pra se soltar a spell (pode variar de player pra player)
.:. spelltable.manapercent ~> a porcentagem de mana que a spell gasta (manapercent do xml)
OBS.: itemtables, creaturetables e spelltables estão marcados com um (!), GUID está marcado com um ($) e atributos opcionais estão marcados com (*)
FUNÇÕES EXPLICADAS
getPlayerFood(cid)
getPlayerMana(cid)
getPlayerMaxMana(cid)
getPlayerLevel(cid)
getPlayerMagLevel(cid)
getPlayerAccess(cid)
getPlayerSkill(cid, skillid)
exemplo: getPlayerSkill(cid, 4) irá retornar o valor do skill 4 (distance fight)
.: skillid ~> um número de 0 a 6 que representa o skill que vc quer obter
.:. 0 ~> FIST
.:. 1 ~> CLUB
.:. 2 ~> SWORD
.:. 3 ~> AXE
.:. 4 ~> DIST
.:. 5 ~> SHIELD
.:. 6 ~> FISH
getPlayerMasterPos(cid)
getPlayerTown(cid)
getPlayerVocation(cid)
retorno:
~> 0 -> NENHUM
~> 1 -> SORCERER
~> 2 -> DRUID
~> 3 -> PALADIN
~> 4 -> KNIGHT
~> 5 -> MASTER SORCERER
~> 6 -> ELDER DRUID
~> 7 -> ROYAL PALADIN
~> 8 -> ELITE KNIGHT
getPlayerItemCount(cid, itemid, subtype)
.: itemid ~> id do item a ser contado
.: subtype (*) ~> atributo opcional, o subtipo do item a ser contado (exemplo: subtipo de vials)
getPlayerSoul(cid)
getPlayerFreeCap(cid)
getCreatureLight(cid)
getCreatureLookDir(cid)
retorno:
~> 0 -> NORTH (Norte)
~> 1 -> EAST (Leste)
~> 2 -> SOUTH (Sul)
~> 3 -> WEST (Oeste)
getPlayerSlotItem(cid, slotid)
.: slotid ~> um número de 1 a 10 que representa o slot que vc quer checar
.:. 01 ~> HEAD (Cabeça)
.:. 02 ~> NECKLACE (Colar)
.:. 03 ~> BACKPACK (Slot da Bolsa)
.:. 04 ~> ARMOR (Armadura)
.:. 05 ~> RIGHT (Mão Direita)
.:. 06 ~> LEFT (Mão Dsquerda)
.:. 07 ~> LEGS (Calça)
.:. 08 ~> FEET (Sapatos)
.:. 09 ~> RING (Anel)
.:. 10 ~> AMMO (Munição)
getPlayerItemById(cid, deepSearch, itemId, subType)
.: deepSearch ~> informa se você vai pesquisar dentro da bag/bp (deepSearch=1). Caso contrário, deepSearch poderá assumir qualquer outro valor
.: itemid ~> id do item a ser retornado
.: subtype (*) ~> atributo opcional, o subtipo do item a ser retornado
getPlayerDepotItems(cid, depotid)
.: depotid ~> Id do depot
getPlayerGuildId(cid)
getPlayerGuildName(cid)
getPlayerGuildRank(cid)
getPlayerGuildNick(cid)
getPlayerSex(cid)
retorno:
~> 0 -> FEMALE (Mulher)
~> 1 -> MALE (Homem)
~> 2 -> FEMALE_GAMEMASTER (Mulher GM)
~> 3 -> MALE_GAMEMASTER (Homem GM)
~> 4 -> FEMALE_MANAGER (Mulher ComManager)
~> 5 -> MALE_MANAGER (Homem ComManager)
~> 6 -> FEMALE_GOD (Mulher GOD)
~> 7 -> MALE_GOD (Homem GOD)
getPlayerGUID(cid)
OBS.: A diferença do GUID com o cid é que o GUID é permanente (ler cid nas definições da biblioteca). Embora os dois sirvam para identificar o player, você não pode passar o GUID de um player pra uma função lua como se fosse o cid! São coisas diferentes!
getPlayerNameByGUID(guid)
getPlayerFlagValue(cid, flag)
.: flag ~> são as "PLAYERFLAG_...." encontradas no global.lua.
getPlayerLossPercent(cid, lossType)
.: lossType ~> "PLAYERLOSS_...." encontradas no global.lua
getPlayerPremiumDays(cid)
getPlayerSkullType(cid)
retorno:
~> 0 -> NONE (Nenhuma)
~> 1 -> YELLOW (Amarela)
~> 2 -> GREEN (Verde)
~> 3 -> WHITE (Branca)
~> 4 -> RED (Vermelha)
getPlayerRedSkullTicks(cid)
getPlayerAccountBalance(cid)
playerLearnInstantSpell(cid, name)
canPlayerLearnInstantSpell(cid, name)
getPlayerLearnedInstantSpell(cid, name)
getPlayerInstantSpellInfo(cid, index)
.: index ~> a posição da magia na lista do player. Começa no 0.
OBS.: a função é geralmente usada em conjunto com a getPlayerInstantSpellCount(cid) para se criar spellbook
getPlayerInstantSpellCount(cid)
getInstantSpellInfoByName(cid, name)
OBS.: se cid for igual a 0, a spelltable (!) irá retornar normal, com exceção da variável mana, que vai ser 0
getInstantSpellWords(name)
getPlayerStorageValue(cid, valueid)
setPlayerStorageValue(cid, valueid, newvalue)
isPremium(cid)
getPlayerLastLogin(cid)
OBS.: O número equivale ao número de segundos passados desde 00:00 horas, 1o de Janeiro, 1970 UTC.
getGlobalStorageValue(valueid)
OBS.: Os globalStorageValue são como se fosse um storagevalue "do server" e não do player. São salvos na tabela `global_storage` da database.
setGlobalStorageValue(valueid, newvalue)
OBS.: Os globalStorageValue são como se fosse um storagevalue "do server" e não do player. São salvos na tabela `global_storage` da database.
getTilePzInfo(pos)
FUNÇÕES A SEREM ADICIONADAS
//getTileHouseInfo(pos)//0 no house. != 0 house id//getItemRWInfo(uid)
//getItemSpecialDescription(uid)
//getThingFromPos(pos)
//getThing(uid)
//queryTileAddThing(uid, pos, <optional> flags)
//getThingPos(uid)
//getTileItemById(pos, itemId, <optional> subType)
//getTileItemByType(pos, type)
//getTileThingByPos(pos)
//getTopCreature(pos)
//getWaypointPositionByName(name)
//doRemoveItem(uid, <optional> count)
//doPlayerFeed(cid, food)
//doPlayerSendCancel(cid, text)
//doPlayerSendDefaultCancel(cid, ReturnValue)
//doPlayerSetIdleTime(cid, time, warned)
//doTeleportThing(uid, newpos)
//doTransformItem(uid, toitemid, <optional> count/subtype)
//doCreatureSay(cid, text, type)
//doSendMagicEffect(pos, type[, player])
//doSendDistanceShoot(frompos, topos, type)
//doChangeTypeItem(uid, newtype)
//doSetItemActionId(uid, actionid)
//doSetItemText(uid, text)
//doSetItemSpecialDescription(uid, desc)
//doSendAnimatedText(pos, text, color)
//doPlayerAddSkillTry(cid, skillid, n, <optional: default: 0> useMultiplier)
//doPlayerAddManaSpent(cid, mana, <optional: default: 0> useMultiplier)
//doCreatureAddHealth(cid, health)
//doPlayerAddMana(cid, mana, <optional: default: 1> filter)
//doPlayerAddSoul(cid, soul)
//doPlayerAddItem(uid, itemid, <optional> count/subtype) //Returns uid of the created item
//doPlayerAddItemEx(cid, uid, <optional: default: 0> canDropOnMap)
//doPlayerSendTextMessage(cid, MessageClasses, message)
//doPlayerRemoveMoney(cid, money)
//doPlayerAddMoney(cid, money)
//doPlayerWithdrawMoney(cid, money)
//doPlayerDepositMoney(cid, money)
//doPlayerTransferMoneyTo(cid, target, money)
//doShowTextWindow(cid, maxlen, canWrite)
//doShowTextDialog(cid, itemid, text)
//doSendTutorial(cid, tutorialid)
//doPlayerSendOutfitWindow(cid)
//doAddMapMark(cid, pos, type, <optional> description)
//getTownIdByName(townName)
//getTownNameById(townId)
//getTownTemplePosition(townId)
//doDecayItem(uid)
//doCreateItem(itemid, <optional> type/count, pos) //Returns uid of the created item, only works on tiles.
//doCreateItemEx(itemid, <optional> count/subtype)
//doTileAddItemEx(pos, uid)
//doAddContainerItemEx(uid, virtuid)
//doRelocate(pos, posTo)//Moves all moveable objects from pos to posTo
//doCreateTeleport(teleportID, positionToGo, createPosition)
//doSummonCreature(name, pos)
//doPlayerSummonCreature(cid, name, pos)
//doRemoveCreature(cid)
//doMoveCreature(cid, direction)
//doPlayerSetMasterPos(cid, pos)
//doPlayerSetTown(cid, townid)
//doPlayerSetVocation(cid, voc)
//doPlayerRemoveItem(cid, itemid, count, <optional> subtype)
//doPlayerAddExp(cid, exp, <optional: default: 0> useRate, <optional: default: 0> useMultiplier)
//getPlayerExperience(cid)
//doPlayerSetGuildRank(cid, rank)
//doPlayerSetGuildNick(cid, nick)
//doPlayerAddOutfit(cid, looktype, addons)
//doPlayerRemoveOutfit(cid, looktype, addons)
//doPlayerAddOutfitEx(cid, outfitid, addons)
//doPlayerRemoveOutfitEx(cid, outfitid, <optional> addons)
//canPlayerWearOutfit(cid, looktype, addons)
//doSetCreatureLight(cid, lightLevel, lightColor, time)
//doPlayerSetLossPercent(cid, lossType, newPercent)
//doSetCreatureDropLoot(cid, doDrop)
//isValidUID(uid)
//isCreature(cid)
//isContainer(uid)
//isCorpse(uid)
//isMoveable(uid)
//getPlayerGUIDByName(name)
//registerCreatureEvent(uid, eventName)
//getContainerSize(uid)
//getContainerCap(uid)
//getContainerItem(uid, slot)
//doAddContainerItem(uid, itemid, <optional> count/subtype)
//getDepotId(uid)
//getHouseOwner(houseid)
//getHouseName(houseid)
//getHouseEntry(houseid)
//getHouseRent(houseid)
//getHouseTown(houseid)
//getHouseAccessList(houseid, listid)
//getHouseByPlayerGUID(playerGUID)
//getHouseTilesSize(houseid)
//getHouseDoorCount(houseid)
//getHouseBedCount(houseid)
//isHouseGuildHall(houseid)
//setHouseAccessList(houseid, listid, listtext)
//setHouseOwner(houseid, ownerGUID)
//getHouseList(townid)
//cleanHouse(houseid)
//getWorldType()
//getWorldTime()
//getWorldLight()
//getWorldCreatures(type) //0 players, 1 monsters, 2 npcs, 3 all
//getWorldUpTime()
//getPlayersOnlineList()
//broadcastMessage(message, <optional> messageClass)
//doPlayerBroadcastMessage(cid, message)
//getGuildId(guild_name)
//createCombatArea( {area}, <optional> {extArea} )
//createConditionObject(type)
//setCombatArea(combat, area)
//setCombatCondition(combat, condition)
//setCombatParam(combat, key, value)
//setConditionParam(condition, key, value)
//addDamageCondition(condition, rounds, time, value)
//addOutfitCondition(condition, lookTypeEx, lookType, lookHead, lookBody, lookLegs, lookFeet)
//setCombatCallBack(combat, key, function_name)
//setCombatFormula(combat, type, mina, minb, maxa, maxb)
//setConditionFormula(combat, mina, minb, maxa, maxb)
//doCombat(cid, combat, param)
//createCombatObject()
//doAreaCombatHealth(cid, type, pos, area, min, max, effect)
//doTargetCombatHealth(cid, target, type, min, max, effect)
//doAreaCombatMana(cid, pos, area, min, max, effect)
//doTargetCombatMana(cid, target, min, max, effect)
//doAreaCombatCondition(cid, pos, area, condition, effect)
//doTargetCombatCondition(cid, target, condition, effect)
//doAreaCombatDispel(cid, pos, area, type, effect)
//doTargetCombatDispel(cid, target, type, effect)
//doChallengeCreature(cid, target)
//doConvinceCreature(cid, target)
//getMonsterTargetList(cid)
//getMonsterFriendList(cid)
//doSetMonsterTarget(cid, target)
//doMonsterChangeTarget(cid)
//doAddCondition(cid, condition)
//doRemoveCondition(cid, type)
//numberToVariant(number)
//stringToVariant(string)
//positionToVariant(pos)
//targetPositionToVariant(pos)
//variantToNumber(var)
//variantToString(var)
//variantToPosition(var)
//doChangeSpeed(cid, delta)
//doCreatureChangeOutfit(cid, outfit)
//doSetMonsterOutfit(cid, name, time)
//doSetItemOutfit(cid, item, time)
//doSetCreatureOutfit(cid, outfit, time)
//getCreatureOutfit(cid)
//getCreaturePosition(cid)
//getCreatureName(cid)
//getCreatureSpeed(cid)
//getCreatureBaseSpeed(cid)
//getCreatureTarget(cid)
//getCreatureHealth(cid)
//getCreatureMaxHealth(cid)
//getCreatureByName(name)
//getCreatureMaster(cid) //returns the creature's master or itself if the creature isn't a summon
//getCreatureSummons(cid) //returns a table with all the summons of the creature
//getSpectators(centerPos, rangex, rangey, multifloor)
//getPartyMembers(cid)
//hasCondition(cid, conditionid)
//hasProperty(uid)
//isItemStackable(itemid)
//isItemRune(itemid)
//isItemDoor(itemid)
//isItemContainer(itemid)
//isItemFluidContainer(itemid)
//isItemMoveable(itemid)
//getItemName(itemid)
//getItemDescriptions(itemid)
//getItemWeight(uid)
//getItemIdByName(name)
//isSightClear(fromPos, toPos, floorCheck)
//getFluidSourceType(type)
//isInArray(array, value)
//addEvent(callback, delay, ...)
//stopEvent(eventid)
//addPlayerBan(playerName = 0xFFFFFFFF[, length = 0[, admin = 0[, comment = "No comment"]]])
//addAccountBan(accounNumber = 0xFFFFFFFF[, length = 0[, admin = 0[, comment = "No comment"]]])
//addIPBan(ip[, mask = 0xFFFFFFFF[, length = 0[, admin = 0[, comment = "No comment"]]]])
//removePlayerBan(playerName)
//removeAccountBan(account)
//removeIPBan(ip[, mask])
//getPlayerBanList()
//getAccountBanList()
//getIPBanList()
//getPlayersByAccountNumber(account)
//getAccountNumberByPlayerName(name)
//getIPByPlayerName(name)
//getPlayersByIPNumber(ip[, mask = 0xFFFFFFFF])
//getDataDir()
//doPlayerSetRate(cid, type, value)
//isPzLocked(cid)
//doSaveServer(payHouses)
//getPlayerFrags(cid)
//debugPrint(text)
//getConfigValue(key)
//bit.bnot, bit.band, bit.bor, bit.bxor, bit.lshift, bit.rshift
//bit.ubnot, bit.uband, bit.ubor, bit.ubxor, bit.ulshift, bit.urshift