Poccnn 385 Postado Junho 23, 2016 Share Postado Junho 23, 2016 (editado) Existe em outros fóruns esse sistema de simular as funções do tfs em poo lua para versões anteriores do 1.0. Então resolvi fazer um sistema desse para disponibiliza-lo ao Xtibia. É uma livraria, então você terá que por na pasta lib do seu servidor. Crie um arquivo com extensão .lua e nomeie para 050 functions_poo e ponha ela na pasta lib. Agora dentro do arquivo, insira esse código. Spoiler --[=[ ####################################################################################################### ## SISTEMA CRIADO PARA SER USADO COMO ORIENTAÇÃO A OBJETO; COMO NA VERSAO 1.0 OU MAIOR. ## ## DESENVOLVIDO POR: Marcryzius FEITO PARA A VERSAO: TFS 0.3.6 CLIENTE: 8.54 ## ## DATA DA ULTIMA ATUALIZAÇÃO: SEXTA-FEIRA, 24 DE JUNHO DE 2016 ## ## FALTA ADICIONAR AS DEMAIS CLASSES RESTANTES ## ## ## ## OBS: CHAMADA DE CLASSE, NÃO FAZ UMA VERIFICAÇÃO SE É A CRIATURA CORRESPONDENTE AO NOME DA ## ## CLASSE OU NÃO, APENAS PEGA/CRIA O OBJETO DA CLASSE. ## ######################################################################################################## ]=] -- Classes Creature = {} Player = {} Monster = {} Item = {} function newClasse(class,pai) return setmetatable(class, { __index = pai or class, __call = function(self,cid) if not(cid)then return setmetatable(self, {__index = class}) elseif(tonumber(cid))then self = getmetatable(self) if not self[cid] then self[cid] = {__index = class, cid = cid} return setmetatable(self[cid], self[cid]) end return self[cid] elseif(type(cid) == 'table')then if getmetatable (cid) then return cid end cid.__index = cid return setmetatable (cid, {__index = class}) end end }) end -- Cria as classes newClasse(Creature) newClasse(Player,Creature) newClasse(Monster,Creature) newClasse(Item) -- item não pode receber herança de outras classes --[[ Exemplo de chamada do objeto local self = Player(cid) -- Está usando os metametodos da classe Player independente de que seja um player ou não. if(self:isPlayer() and self:getLevel() > 100)then self:sendTextMessage(MESSAGE_INFO_DESCR,'Tu: '..self:getName():lower()..', teins '..self:getLevel()..' leveis!') self:teleportThing({algum lugar}, true) else self:sendCancelMessage('Tu: '..self:getName():lower()..', so teins '..self:getLevel()..' leveis!') end ]] -- Creature *get function Creature:getCid() return self.cid end function Creature:getName() return getCreatureName(self.cid) end function Creature:getHealth() return getCreatureHealth(self.cid) end function Creature:getMaxHealth() return getCreatureMaxHealth(self.cid) end function Creature:getMana() return getCreatureMana(self.cid) end function Creature:getMaxMana() return getCreatureMaxMana(self.cid) end function Creature:getStorageValue(id) return getCreatureStorageValue(self.cid, id) end function Creature:getHiddenHealth() return getCreatureHideHealth(self.cid) end function Creature:getSpeakType() return getCreatureSpeakType(self.cid) end function Creature:getLookDirection() return getCreatureLookDirection(self.cid) end function Creature:getMaster() return getCreatureMaster(self.cid) end function Creature:getSummons() return getCreatureSummons(self.cid) end function Creature:getOutfit() return getCreatureOutfit(self.cid) end function Creature:getPosition() return getCreaturePosition(self.cid) end function Creature:getLookDir() return getCreatureLookDirection(self.cid) end function Creature:getSpeed() return getCreatureSpeed(self.cid) end function Creature:getBaseSpeed() return getCreatureBaseSpeed(self.cid) end function Creature:getTarget() return getCreatureTarget(self.cid) end function Creature:getCreatureByName() return getCreatureByName(self:getName()) end function Creature:getSkullType() return getCreatureSkullType(self.cid) end function Creature:getCondition(condition) return getCreatureCondition(self.cid, condition) end function Creature:getNoMove() return getCreatureNoMove(self.cid) end function Creature:getLookPosition() return getCreatureLookPosition(self.cid) end -- Monster *get function Monster:getInfo() return getMonsterInfo(self:getName()) end function Monster:getHealingSpells() return getMonsterHealingSpells(self:getName()) end function Monster:getAttackSpells() return getMonsterAttackSpells(self:getName()) end function Monster:getLootList() return getMonsterLootList(self:getName()) end function Monster:getSummonList() return getMonsterSummonList(self:getName()) end function Monster:getTargetList() return getMonsterTargetList(self.cid) end function Monster:getFriendList() return getMonsterFriendList(self.cid) end -- Player *get function Player:getByNameWildcard() return getPlayerByNameWildcard(self:getName()) end function Player:getLossSkill() return getPlayerLossSkill(self.cid) end function Player:getLossPercent(lossType) return getPlayerLossPercent(self.cid, lossType) end function Player:getGUIDByName() return getPlayerGUIDByName(self:getName()) end function Player:getFood() return getPlayerFood(self.cid) end function Player:getLevel() return getPlayerLevel(self.cid) end function Player:getExperience() return getPlayerExperience(self.cid) end function Player:getMagLevel() return getPlayerMagLevel(self.cid) end function Player:getSpentMana() return getPlayerSpentMana(self.cid) end function Player:getAccess() return getPlayerAccess(self.cid) end function Player:getGhostAccess() return getPlayerGhostAccess(self.cid) end function Player:getPlayerSkillLevel(skillId) return getPlayerSkillLevel(self.cid, skillId) end function Player:getSkillTries(skillId) return getPlayerSkillTries(self.cid, skillId) end function Player:getTown() return getPlayerTown(self.cid) end function Player:getVocation() return getPlayerVocation(self.cid) end function Player:getRequiredMana(magicLevel) return getPlayerRequiredMana(self.cid, magicLevel) end function Player:getRequiredSkillTries(skillId,skillLevel) return getPlayerRequiredSkillTries(self.cid, skillId, skillLevel) end function Player:getItemCount(itemid) return getPlayerItemCount(self.cid, itemid) end function Player:getSoul() return getPlayerSoul(self.cid) end function Player:getAccountId() return getPlayerAccountId(self.cid) end function Player:getAccount() return getPlayerAccount(self.cid) end function Player:getIp() return getPlayerIp(self.cid) end function Player:getFreeCap() return getPlayerFreeCap(self.cid) end function Player:getLight() return getPlayerLight(self.id) end function Player:getSlotItem(slot) return getPlayerSlotItem(self.cid, slot) end function Player:getWeapon(ammo) return getPlayerWeapon(self.cid,ammo) end function Player:getItemById(deepSearch,itemId,subType) return getPlayerItemById(self.cid, deepSearch, itemId,subType) end function Player:getDepotItems(depotid) return getPlayerDepotItems(self.cid, depotid) end function Player:getGuildId() return getPlayerGuildId(self.cid) end function Player:getGuildName() return getPlayerGuildName(self.cid) end function Player:getGuildRank() return getPlayerGuildRank(self.cid) end function Player:getGuildNick() return getPlayerGuildNick(self.cid) end function Player:getGuildLevel() return getPlayerGuildLevel(self.cid) end function Player:getSex() return getPlayerSex(self.cid) end function Player:getStorageValue(key) return getPlayerStorageValue(cid, key) end function Player:getGUID() return getPlayerGUID(self.cid) end function Player:getFlagValue(flag) return getPlayerFlagValue(self.cid, flag) end function Player:getCustomFlagValue(flag) return getPlayerCustomFlagValue(self.cid, flag) end function Player:getPromotionLevel() return getPlayerPromotionLevel(self.cid) end function Player:getGroupId() return getPlayerGroupId(self.cid) end function Player:getLearnedInstantSpell(name) return getPlayerLearnedInstantSpell(self.cid, name) end function Player:getInstantSpellCount() return getPlayerInstantSpellCount(self.cid) end function Player:getInstantSpellInfo(name) return getInstantSpellInfo(self.cid, name) end function Player:getBlessing(blessing) return getPlayerBlessing(self.cid, blessing) end function Player:getStamina() return getPlayerStamina(self.cid) end function Player:getExtraExpRate() return getPlayerExtraExpRate(self.cid) end function Player:getPartner() return getPlayerPartner(self.cid) end function Player:getParty() return getPlayerParty(self.cid) end function Player:getPremiumDays() return getPlayerPremiumDays(self.cid) end function Player:getBalance() return getPlayerBalance(self.cid) end function Player:getMoney() return getPlayerMoney(self.cid) end function Player:getSkullTicks(tipo) return getPlayerSkullTicks(self.cid, tipo) end function Player:getRates() return getPlayerRates(self.cid) end function Player:getLastLogin() return getPlayerLastLogin(self.cid) end function Player:getLastLoginSaved() return getPlayerLastLoginSaved(self.cid) end function Player:getAccountManager() return getPlayerAccountManager(self.cid) end function Player:getByName() return getPlayerByName(self:getName()) end function Player:getFrags() return getPlayerFrags(self.cid) end function Player:getPartyLeader() return getPartyLeader(self.cid) end function Player:getGroupName() return getPlayerGroupName(self.cid end function Player:getVocationName() return getPlayerVocationName(self.cid) end function Player:getPromotedVocation() return getPromotedVocation(self:getVocation()) end function Player:getMasterPos() return getPlayerMasterPos(self.cid) end -- Item *get -- pega diretamente da tabela 'item' fornecida pelo sistema. function Item:getAid() return self.actionid end function Item:getUid() return self.uid end function Item:getItemId() return self.itemid end function Item:getType() return self.type end function Item:getName() return getItemName(self.uid) end function Item:getNameById() return getItemNameById(self:getItemId()) end function Item:getItemPluralNameById() return getItemPluralNameById(self:getItemId()) end function Item:getItemArticleById() return getItemArticleById(self:getItemId()) end function Item:getPluralName() return getItemPluralName(self.uid) end function Item:getText() return getItemText(self.uid) end function Item:getSpecialDescription() return getItemSpecialDescription(self.uid) end function Item:getWriter() return getItemWriter(self.uid) end function Item:getDate() return getItemDate(self.uid) end function Item:getRWInfo() return getItemRWInfo(self.uid) end function Item:getProtection() return getItemProtection(self.uid) end function Item:getDescriptionsById() return getItemDescriptionsById(self:getItemId()) end function Item:getWeightById(count,precise) return getItemWeightById(self:getItemId(), count, precise) end function Item:getDescriptions() return getItemDescriptions(self.uid) end function Item:getWeight(precise) return getItemWeight(self.uid, precise) end function Item:getAttack() return getItemAttack(self.uid) end function Item:getExtraAttack() return getItemExtraAttack(self.uid) end function Item:getDefense() return getItemDefense(self.uid) end function Item:getExtraDefense() return getItemExtraDefense(self.uid) end function Item:getArmor() return getItemArmor(self.uid) end function Item:getAttackSpeed() return getItemAttackSpeed(self.uid) end function Item:getHitChance() return getItemHitChance(self.uid) end function Item:getShootRange() return getItemShootRange(self.uid) end function Item:getLevelDoor() return getItemLevelDoor(self:getItemId()) end function Item:getWeaponType() return getItemWeaponType(self.uid) end function Item:getContainerSize() return getContainerSize(self.uid) end function Item:getContainerCap() return getContainerCap(self.uid) end function Item:getContainerCapById() return getContainerCapById(self:getItemId()) end function Item:getContainerItem(slot) return getContainerItem(self.uid, slot) end function Item:getDepotId() return getDepotId(self.uid) end function Item:getArticle() return getItemArticle(self.uid) end -- Creature *set function Creature:setMaxHealth(health) return setCreatureMaxHealth(self.cid, health) end function Creature:setMaxMana(mana) return setCreatureMaxMana(self.cid, mana) end function Creature:setStorageValue(storage, value) return setCreatureStorageValue(self.cid, storage, value) end function Creature:setHiddenHealth(hide) doCreatureSetHideHealth(self.cid, hide) end function Creature:setSpeakType(tipo) doCreatureSetSpeakType(self.cid, tipo) end --Creature *do function Creature:teleportThing(newpos, pushmove) doTeleportThing(self.cid, newpos, pushmove or false) end function Creature:addHealth(health, force) doCreatureAddHealth(self.cid, health, force) end function Creature:addMana(mana) doCreatureAddMana(self.cid, mana) end function Creature:say(text, tipo, ghost, cid, pos) doCreatureSay(self.cid, text, tipo or SPEAK_SAY, ghost or false, cid or 0, pos) end function Creature:ddCondition(condition) doAddCondition(self.cid, condition) end function Creature:removeCondition(onlyPersistent) doRemoveConditions(self.cid, onlyPersistent) end function Creature:moveCreature(direction) doMoveCreature(self.cid, direction) end function Creature:removeCreature(forceLogout) doRemoveCreature(self.cid, forceLogout or true) end function Creature:setDropLoot(doDrop) doCreatureSetDropLoot(self.cid, doDrop) end function Creature:setSkullType(skull) doCreatureSetSkullType(self.cid, skull) end function Creature:setSpeakType(tipo) doCreatureSetSpeakType(self.cid,tipo) end function Creature:setLookDirection(dir) doCreatureSetLookDirection(self.cid, dir) end function Creature:setMaxCapacity(cap) doPlayerSetMaxCapacity(self.cid, cap) end function Creature:changeOutfit(outfit) doCreatureChangeOutfit(self.cid, outfit) end function Creature:setNoMove(cannotMove) doCreatureSetNoMove(self.cid, cannotMove) end function Creature:setLight(lightLevel,lightColor,tempo) doSetCreatureLight(self.cid, lightLevel, lightColor, tempo) end function Creature:setOutfit(outfit,tempo) doSetCreatureOutfit(self.cid, outfit, tempo) end function Creature:convinceCreature(target) doConvinceCreature(self.cid, target) end function Creature:challengeCreature(target) doChallengeCreature(self.cid, target) end function Creature:changeSpeed(delta) doChangeSpeed(self.cid, delta) end -- Monster *do function Monster:changeTarget() doMonsterChangeTarget(self.cid) end function Monster:setTarget(target) doMonsterSetTarget(self.cid, target) end -- Player *do function Player:broadcastMessage(message,tipo) doPlayerBroadcastMessage(self.cid, message, tipo) end function Player:setSex(newSex) doPlayerSetSex(self.cid, newSex) end function Player:setTown(towcid) doPlayerSetTown(self.cid, towcid) end function Player:setVocation(voc) doPlayerSetVocation(self.cid, voc) end function Player:setStorageValue(key,newValue) doPlayerSetStorageValue(self.cid, key, newValue) end function Player:setGroupId(newGroupId) doPlayerSetGroupId(self.cid, newGroupId) end function Player:setPromotionLevel(level) doPlayerSetPromotionLevel(self.cid, level) end function Player:setStamina(minutes) doPlayerSetStamina(self.cid, minutes) end function Player:setBalance(balance) doPlayerSetBalance(self.cid, balance) end function Player:setExtraExpRate(value) doPlayerSetExtraExpRate(self.cid, value) end function Player:setPartner(guid) doPlayerSetPartner(self.cid, guid) end function Player:removeItem(itemId,count,subtype) doPlayerRemoveItem(self.cid, itemid, count, subtype) end function Player:addExperience(amount) doPlayerAddExperience(self.cid, amount) end function Player:setGuildId(id) doPlayerSetGuildId(self.cid, id) end function Player:setGuildRank(rank) doPlayerSetGuildRank(self.cid, rank) end function Player:setGuildNick(nick) doPlayerSetGuildNick(self.cid, nick) end function Player:addOutfit(looktype,addons) doPlayerAddOutfit(self.cid,looktype, addons) end function Player:removeOutfit(looktype,addons) doPlayerRemoveOutfit(self.cid,looktype, addons) end function Player:setRedSkullTicks(amount) doPlayerSetRedSkullTicks(self.cid, amount) end function Player:setLossPercent(lossType,newPercent) doPlayerSetLossPercent(self.cid, lossType, newPercent) end function Player:setLossSkill(doLose) doPlayerSetLossSkill(self.cid, doLose) end function Player:addSkillTry(skillId, n) doPlayerAddSkillTry(self.cid, skillid, n) end function Player:addSpentMana(amount) doPlayerAddSpentMana(self.cid, amount) end function Player:addSoul(soul) doPlayerAddSoul(self.cid, soul) end function Player:addItem(itemid,count,canDropOnMap) doPlayerAddItem(self.cid, itemid, count, canDropOnMap) end function Player:addItemEx(uid,canDropOnMap) doPlayerAddItemEx(self.cid, uid, canDropOnMap) end function Player:sendTextMessage(messageClasses,message) doPlayerSendTextMessage(self.cid, messageClasses or 1, message or '') end function Player:sendChannelMessage(author,message,speak,channel) doPlayerSendChannelMessage(self.cid, author, message, speak, channel) end function Player:sendToChannel(targetId,speak,message,channel,tempo) doPlayerSendToChannel(self.cid, targetId, speak, message, channel,tempo) end function Player:addMoney(money) doPlayerAddMoney(self.cid, money) end function Player:removeMoney(money) doPlayerRemoveMoney(self.cid, money) end function Player:transferMoneyTo(target,money) doPlayerTransferMoneyTo(self.cid, target, money) end function Player:popupFYI(message) doPlayerPopupFYI(self.cid, message) end function Player:sendTutorial(id) doPlayerSendTutorial(self.cid, id) end function Player:addMapMark(pos,tipo,description) doPlayerAddMapMark(self.cid, pos, tipo, description) end function Player:addPremiumDays(days) doPlayerAddPremiumDays(self.cid, days) end function Player:addBlessing(blessing) doPlayerAddBlessing(self.cid, blessing) end function Player:addStamina(minutes) doPlayerAddStamina(self.cid, minutes) end function Player:resetIdleTime() doPlayerResetIdleTime(self.cid) end function Player:learnInstantSpell(name) doPlayerLearnInstantSpell(self.cid, name) end function Player:unlearnInstantSpell(name) doPlayerUnlearnInstantSpell(self.cid, name) end function Player:setRate(tipo,value) doPlayerSetRate(self.cid, tipo, value) end function Player:joinParty(cid,lid) doPlayerJoinParty(self.cid, lid) end function Player:sendOutfitWindow() doPlayerSendOutfitWindow(self.cid) end function Player:save(shallow) doPlayerSave(cid, shallow) end function Player:feed(food) doPlayerFeed(self.cid, food) end function Player:sendCancelMessage(text) doPlayerSendCancel(self.cid, text) end function Player:sendDefaultCancelMessage(ReturnValue) doPlayerSendDefaultCancel(self.cid, ReturnValue) end function Player:showTextDialog(itemid,text) doShowTextDialog(self.cid, itemid, text) end function Player:giveItem(itemid,amount,subType) doPlayerGiveItem(self.cid, itemid, amount, subType) end function Player:takeItem(itemid,amount) doPlayerTakeItem(self.cid, itemid, amount) end function Player:buyItem(itemid,count,cost,charges) doPlayerBuyItem(self.cid, itemid, count, cost, charges) end function Player:buyItemContainer(containerid,itemid,count,cost,charges) doPlayerBuyItemContainer(self.cid, containerid, itemid, count, cost, charges) end function Player:sellItem(itemid,count,cost) doPlayerSellItem(self.cid, itemid, count, cost) end function Player:withdrawMoney(money) doPlayerWithdrawMoney(self.cid, money) end function Player:depositMoney(money) doPlayerDepositMoney(self.cid, money) end function Player:withdrawAllMoney() doPlayerWithdrawAllMoney(self.cid) end function Player:addIpBanishment(length,comment,admin) doAddIpBanishment(self:getIp(), length, comment, admin) end function Player:addNamelock(reason,action,comment,admin) doAddNamelock(self:getName(), reason, action, comment, admin) end function Player:addBanishment(length,reason,action,comment,admin) doAddBanishment(self:getAccountId(), length, reason, action, comment, admin) end function Player:addDeletion(reason,action,comment,admin) doAddDeletion(self:getAccountId(), reason, action, comment, admin) end function Player:addNotation(reason,action,comment,admin) doAddNotation(self:getAccountId(), reason, action, comment, admin) end function Player:removeIpBanishment(mask) doRemoveIpBanishment(self:getIp(), mask) end function Player:removeNamelock() doRemoveNamelock(self:getName()) end function Player:removeBanisment() doRemoveBanisment(self:getAccountId()) end function Player:removeDeletion() doRemoveDeletion(self:getAccountId()) end function Player:removeNotations() doRemoveNotations(self:getAccountId()) end function Player:depositAllMoney() doPlayerDepositAllMoney(self.cid) end function Player:transferAllMoneyTo(target) doPlayerTransferAllMoneyTo(self.cid, target) end function Player:addLevel(amount,round) doPlayerAddLevel(self.cid, amount, round) end function Player:addMagLevel(amount) doPlayerAddMagLevel(self.cid, amount) end function Player:addSkill(amount) doPlayerAddSkill(self.cid, amount) end function Player:muted(tempo) doMutePlayer(self.cid, tempo) end function Player:removePremiumDays(days) doPlayerRemovePremiumDays(self.cid, days) end function Player:addAddons(addon) doPlayerAddAddons(self.cid, addon) end -- Item *do function Item:addContainerItemEx(virtuid) doAddContainerItemEx(self.uid, virtuid) end function Item:addContainerItem(itemid,count) doAddContainerItem(self.uid, itemid, count) end function Item:changeTypeItem(new_type) doChangeTypeItem(self.uid, new_type) end function Item:decayItem() doDecayItem(self.uid) end function Item:removeItem(count) doRemoveItem(self.uid, count) end function Item:transformItem(toitemid,count) doTransformItem(self.uid, toitemid, count) end function Item:setItemActionid(actionid) doSetItemActionid(self.uid, actionid) end function Item:setItemText(text,writer,data) doSetItemText(self.uid, text, writer, data) end function Item:setItemSpecialDescription(desc) doSetItemSpecialDescription(self.uid, desc) end function Item:setItemOutfit(item,tempo) doSetItemOutfit(self.uid, item, tempo) end function Item:setItemProtection(value) doSetItemProtection(self.uid, value) end function Item:copyItem(attributes) return doCopyItem({uid=sef.uid,actionid=self:getAid(),itemid=self:getItemId(),type=self:getType()}, attributes) end -- Creature *is function Creature:isCreature() return isCreature(self.cid) end function Creature:isPlayer() return isPlayer(self.cid) end function Creature:isMonster() return isMonster(self.cid) end function Creature:isNpc() return isNpc(self.cid) end -- Player *is function Player:nameLocked() return isPlayerNamelocked(self:getName()) end function Player:pzLocked() return isPlayerPzLocked(self.cid) end function Player:isPremium() return isPremium(self.cid) end function Player:nameLocked() return isPlayerNamelocked(self:getName()) end function Player:ghost() return isPlayerGhost(self.cid) end function Player:isSorcerer() return isSorcerer(self.cid) end function Player:isDruid() return isDruid(self.cid) end function Player:isPaladin() return isPaladin(self.cid) end function Player:isKnight() return isKnight(self.cid) end function Player:isRookie() return isRookie(self.cid) end function Player:accountBanished() return isAccountBanished(self:getAccountId()) end function Player:accounDeleted() return isAccountDeleted(self:getAccountId()) end function Player:ipBanished(mask) return isIpBanished(self:getIp(), mask) end function Player:isInParty() return isInParty(self.cid) end -- Item *is function Item:isStackable() return isItemStackable(self:getItemId()) end function Item:isRune() return isItemRune(self:getItemId()) end function Item:isMovable() return isItemMovable(self:getItemId()) end function Item:isDoor() return isItemDoor(self:getItemId()) end function Item:isContainer() return isItemContainer(self:getItemId()) end function Item:isFluidContainer() return isItemFluidContainer(self:getItemId()) end function Item:isContainer() return isContainer(self.uid) end function Item:isCorpse() return isCorpse(self.uid) end function Item:isMovable() return isMovable(self.uid) end -- Creature *others function Creature:registerEvent(eventName) registerCreatureEvent(self.cid, eventName) end -- Player *others function Player:canWearOutfit(lookType,addons) canPlayerWearOutfit(self.cid, lookType, addons) end Lembrando que não está terminado, ainda falta algumas funções e classes. atualizado funções e sistema. script está codificado em utf8, converta-o para ansi antes de usa-lo. Editado Junho 29, 2016 por Poccnn Inserção de informações/modificações no sistema Link para o comentário Compartilhar em outros sites More sharing options...
Gabrielziho 0 Postado Maio 29, 2017 Share Postado Maio 29, 2017 Mto bom ajudou demais vlw Link para o comentário Compartilhar em outros sites More sharing options...
Posts Recomendados