Oneshot 732 Postado Março 15, 2014 Share Postado Março 15, 2014 ;x sempre ue logo não seta a outfit alguém ae pode me ajudar , exemplo to classe mago vou para sei lá sacerdote ai continua com a outfit mago de vez setar para de sacerdote ^^ local outfits_male = { [1] = {lookType = 128, lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet, lookAddons = 0}, [2] = {lookType = 134, lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet, lookAddons = 0}, [3] = {lookType = 129, lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet, lookAddons = 0}, [4] = {lookType = 130, lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet, lookAddons = 0}, [5] = {lookType = 133, lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet, lookAddons = 0}, [6] = {lookType = 131, lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet, lookAddons = 0}, [7] = {lookType = 143, lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet, lookAddons = 0}, [8] = {lookType = 145, lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet, lookAddons = 0}, [9] = {lookType = 153, lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet, lookAddons = 0}, [10] = {lookType = 289, lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet, lookAddons = 0}, [11] = {lookType = 273, lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet, lookAddons = 0}, [12] = {lookType = 146, lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet, lookAddons = 0}, [13] = {lookType = 154, lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet, lookAddons = 0} } } local outfits_female = { [1] = {lookType = 136 lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet, lookAddons = 0}, [2] = {lookType = 142 lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet, lookAddons = 0}, [3] = {lookType = 139 lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet, lookAddons = 0}, [4] = {lookType = 138 lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet, lookAddons = 0}, [5] = {lookType = 141 lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet, lookAddons = 0}, [6] = {lookType = 139 lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet, lookAddons = 0}, [7] = {lookType = 147 lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet, lookAddons = 0}, [8] = {lookType = 157 lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet, lookAddons = 0}, [9] = {lookType = 149 lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet, lookAddons = 0}, [10] = {lookType = 288 lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet, lookAddons = 0}, [11] = {lookType = 270 lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet, lookAddons = 0}, [12] = {lookType = 150 lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet, lookAddons = 0}, [13] = {lookType = 158 lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet, lookAddons = 0} } function onLogin(cid) local voc_id = getPlayerVocation(cid) local myOutfit = getCreatureOutfit(cid) if voc_id > 0 then if getPlayerSex(cid) == 0 then myOutfit.lookType = outfits_female[voc_id] else myOutfit.lookType = outfits_male[voc_id] end doCreatureChangeOutfit(cid, myOutfit) end return true end Desisto, você só pode ser lesado. Tchau. Link para o comentário https://xtibia.com/forum/topic/228906-projeto-tutores-de-scripting/page/4/#findComment-1623467 Compartilhar em outros sites More sharing options...
kavaskiva 14 Postado Março 15, 2014 Share Postado Março 15, 2014 (editado) hsduasuhasudhasudhuasdsad era sono mesmo ^^, obrigado pela ajuda garou essa parte me ajudou muito . Seu erro foi utilizar getCreatureOutfit(cid) fora do escopo da função onLogin(cid), de modo que o parâmetro cid na tabela vai retornar nulo. dalvor tbm obrigado . @GAROU esse script seu local VOCATION_OUTFITS = { [1] = { [0] = 128, [1] = 136, }, } function onLogin(cid) local tmp = VOCATION_OUTFITS[getPlayerVocation(cid)][getPlayerSex(cid)] if tmp then local outfit = getCreatureOutfit(cid) outfit.lookType = tmp doCreatureChangeOutfit(cid, outfit) end return true end ta com o sexo invertido então deixei local outfits = { [1] = {lookType = 128} [2] = {lookType = 134} } function onLogin(cid) local tmp = outfits[getPlayerVocation(cid)][getPlayerSex(cid)] if tmp then local outfit = getCreatureOutfit(cid) outfit.lookType = tmp doCreatureChangeOutfit(cid, outfit) end return true end Editado Março 15, 2014 por kavaskiva Link para o comentário https://xtibia.com/forum/topic/228906-projeto-tutores-de-scripting/page/4/#findComment-1623471 Compartilhar em outros sites More sharing options...
dalvorsn 268 Postado Março 16, 2014 Share Postado Março 16, 2014 (editado) Que eu saiba os jogadores só retornam 0 e 1, inclusive jogadores com acesso de gamemaster. O PLAYERSEX_GAMEMASTER não é usado sequer nas sources. Eu sou meio chato com isso, então não edite meus scripts fazendo POGs neles. HEIHEIHE Que bom que tu fez a replica, eu jurava que era retornado normal, dai fui conferir nas sources, pelo visto parece que só retorna o sexo do gamemaster se usar o parametro opcional full //getPlayerSex(cid[, full = false]) player.h uint16_t getSex(bool full) const {return full ? sex : sex % 2;} Mas como tu nao usa ele, nunca vai retornar 2 *.* 0 % 2 >> 0 -- female 1 % 2 >> 1 -- male 2 % 2 >> 0 -- female logo se full é false todo gm é moçinha huehue Obs.: postei pra implicar mesmo HEIHEIH' eu sei que seu balão enche rápido ;D hsduasuhasudhasudhuasdsad era sono mesmo ^^, obrigado pela ajuda garou essa parte me ajudou muito . Seu erro foi utilizar getCreatureOutfit(cid) fora do escopo da função onLogin(cid), de modo que o parâmetro cid na tabela vai retornar nulo. dalvor tbm obrigado . @GAROU esse script seu local VOCATION_OUTFITS = { [1] = { [0] = 128, [1] = 136, }, } function onLogin(cid) local tmp = VOCATION_OUTFITS[getPlayerVocation(cid)][getPlayerSex(cid)] if tmp then local outfit = getCreatureOutfit(cid) outfit.lookType = tmp doCreatureChangeOutfit(cid, outfit) end return true end ta com o sexo invertido então deixei local outfits = { [1] = {lookType = 128} [2] = {lookType = 134} } function onLogin(cid) local tmp = outfits[getPlayerVocation(cid)][getPlayerSex(cid)] if tmp then local outfit = getCreatureOutfit(cid) outfit.lookType = tmp doCreatureChangeOutfit(cid, outfit) end return true end Cara pra que tu troca o que ta certo vei? Não entendo, tu meche aonde não tem necessidade, a função getPlayerSex retorna 0 e 1, tu bota index 1 e 2 porque diabos? voce que inverteu na configuração se ta vindo trocado local VOCATION_OUTFITS = { [1] = { [0] = 136, [1] = 128, }, } function onLogin(cid) local tmp = VOCATION_OUTFITS[getPlayerVocation(cid)][getPlayerSex(cid)] if tmp then local outfit = getCreatureOutfit(cid) outfit.lookType = tmp doCreatureChangeOutfit(cid, outfit) end return true end Killua, estou tentando fazer alguns scripts mais não sei nem por onde começar, vou dizer dois sobre itens o primeiro é um axe que deixa o player com stun e a chance é de 25% o outro é uma amor que solta um dano em sua volta com a change de 15% de fazer esse dano a cada hit recebido espero que me ajude !!! O primeiro tu faz por weapons mesmo: #data/weapons/scripts/stunner_axe.lua local chance = 25 -- porcentagem(int) local cooldown = 20 -- segundos local cooldown_storage = 3600 local stun_effect = 34 local duration = 5 -- tempo que vai ficar stunnado em segundos function onUseWeapon(cid, var) if chance >= math.random(100) and exhaustion.make(cid, cooldown_storage, cooldown) then stun(var.number, duration) end return true end function stun(target, seconds) if not isCreature(target) then return false end doChangeSpeed(target, -getCreatureSpeed(target)) doSendMagicEffect(getCreaturePosition(target), stun_effect) addEvent(function(target) if isCreature(target) then doChangeSpeed(target, -getCreatureSpeed(target)+getCreatureBaseSpeed(target)) end end, seconds * 1000, target) return true end #data/weapons/weapons.xml: <melee id="2429" level="20" event="script" value="stunner_axe.lua"/> O outro to com preguiça de fazer, mas e basicamente usar uma creaturescripts onStatsChange(cid, attacker, type, combat, value) onde o cid e attacker sao players, e o type é STATSCHANGE_HEALTHLOSS, dai tu faz o combate normal com a condicional da chance, que nem a da magia de cima ai, sendo que quando true, executa a magia em area que tu quer, basicamente isso Editado Março 16, 2014 por dalvorsn Link para o comentário https://xtibia.com/forum/topic/228906-projeto-tutores-de-scripting/page/4/#findComment-1623501 Compartilhar em outros sites More sharing options...
HeltonMuniz2 10 Postado Março 16, 2014 Share Postado Março 16, 2014 function onUse(cid, item, fromPos, item2, toPos) local info = "Request Board\n\n" doShowTextDialog(cid, 1950, info) end To com muita dificuldade, aqui era pra abrir um caixa de dialogo, mais com um Rank de 1 a 10, contando o Storage "15236", quem tiver mais fica no rank de [1] a [10] Link para o comentário https://xtibia.com/forum/topic/228906-projeto-tutores-de-scripting/page/4/#findComment-1623909 Compartilhar em outros sites More sharing options...
dalvorsn 268 Postado Março 16, 2014 Share Postado Março 16, 2014 (editado) function onUse(cid, item, fromPos, item2, toPos) local info = "Request Board\n\n" doShowTextDialog(cid, 1950, info) end To com muita dificuldade, aqui era pra abrir um caixa de dialogo, mais com um Rank de 1 a 10, contando o Storage "15236", quem tiver mais fica no rank de [1] a [10] Nesse caso é melhor fazer por query, tu vai fazer a query ordenando da maior para menor, Caso não saiba executar queries, use esse site para estudo: http://www.w3schools.com/sql/default.asp As funções de database são: local result = db.getResult(query) result.getDataInt(resId, s) result.getDataLong(resId, s) result.getDataString(resId, s) result.getDataStream(resId, s, length) result.next(resId) result.free(resId) Porem o uso constante de database é um pouco perigoso, faça um sistema de cache, que só executa a query de tempos em tempos, independente de quem requisita o rank(ou seja, salvando numa global storage) Editado Março 16, 2014 por dalvorsn Link para o comentário https://xtibia.com/forum/topic/228906-projeto-tutores-de-scripting/page/4/#findComment-1623914 Compartilhar em outros sites More sharing options...
vagnho 0 Postado Março 16, 2014 Share Postado Março 16, 2014 Alguém pode me ajudar com um erro ? meu script é esse : local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE) setCombatFormula(combat, COMBAT_FORMULA_SKILL, 2, -50, 1, -80) -- não sei fazer formula local chance = 20 local condition1 = createConditionObject(CONDITION_DRUNK) setConditionParam(condition1, CONDITION_PARAM_DRUNK, 0) setCombatParam(combat, COMBAT_PARAM_EFFECT, 31) -- Efeito setCombatCondition(combat, condition1) function onUseWeapon(cid, var) local target = getCreatureTarget(cid) if math.random(100) >= chance then if doTargetCombatCondition(1, CONDITION_DRUNK, CONST_ME_STUN) then end end return doCombat(cid, combat, var) end o erro é em if doTargetCombatCondition diz que não existe creature, e também colocar o efeito apenas quando a chance for < que 20 ali ta maior so para test Link para o comentário https://xtibia.com/forum/topic/228906-projeto-tutores-de-scripting/page/4/#findComment-1623974 Compartilhar em outros sites More sharing options...
HeltonMuniz2 10 Postado Março 16, 2014 Share Postado Março 16, 2014 function onUse(cid, item, fromPos, item2, toPos) local info = "Request Board\n\n" doShowTextDialog(cid, 1950, info) end To com muita dificuldade, aqui era pra abrir um caixa de dialogo, mais com um Rank de 1 a 10, contando o Storage "15236", quem tiver mais fica no rank de [1] a [10] Nesse caso é melhor fazer por query, tu vai fazer a query ordenando da maior para menor, Caso não saiba executar queries, use esse site para estudo: http://www.w3schools.com/sql/default.asp As funções de database são: local result = db.getResult(query) result.getDataInt(resId, s) result.getDataLong(resId, s) result.getDataString(resId, s) result.getDataStream(resId, s, length) result.next(resId) result.free(resId) Porem o uso constante de database é um pouco perigoso, faça um sistema de cache, que só executa a query de tempos em tempos, independente de quem requisita o rank(ou seja, salvando numa global storage) Não ha um modo mais fácil ? Link para o comentário https://xtibia.com/forum/topic/228906-projeto-tutores-de-scripting/page/4/#findComment-1624253 Compartilhar em outros sites More sharing options...
dalvorsn 268 Postado Março 17, 2014 Share Postado Março 17, 2014 Alguém pode me ajudar com um erro ? meu script é esse : local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE) setCombatFormula(combat, COMBAT_FORMULA_SKILL, 2, -50, 1, -80) -- não sei fazer formula local chance = 20 local condition1 = createConditionObject(CONDITION_DRUNK) setConditionParam(condition1, CONDITION_PARAM_DRUNK, 0) setCombatParam(combat, COMBAT_PARAM_EFFECT, 31) -- Efeito setCombatCondition(combat, condition1) function onUseWeapon(cid, var) local target = getCreatureTarget(cid) if math.random(100) >= chance then if doTargetCombatCondition(1, CONDITION_DRUNK, CONST_ME_STUN) then end end return doCombat(cid, combat, var) end o erro é em if doTargetCombatCondition diz que não existe creature, e também colocar o efeito apenas quando a chance for < que 20 ali ta maior so para test esse 1 no doTargetCombatCondition ta errado pow, ,tu tem que colocar ai o valor do creature id de quem vai receber a condition, no caso a variavel target Link para o comentário https://xtibia.com/forum/topic/228906-projeto-tutores-de-scripting/page/4/#findComment-1624508 Compartilhar em outros sites More sharing options...
kttallan 319 Postado Março 17, 2014 Share Postado Março 17, 2014 Ola eu tenho uma experiencia basica em scripter, porem nunca consigo fazer um codigo(completo) sem bugs mesmo ele sendo simples, gostaria de saber o erro que tem nesse scripter e como poderia funcionar sem bug, obrigado. function onUse(cid, item, frompos, item2, topos)local monster ={[12597] = {"Troll", 1, 50, vida = 500, vezes = 5, go = 00, gack = 00},[12598] = {"Amazon", 50, 100, vida = 1000, vezes = 10, go = 00, back = 00},[12599] = {"Demon", 100, 150, vida = 1500, vezes = 15, go = 00, back = 00}}local summom = getCreatureSummons(cid)local mst = monster[item.actionid]local hea = monster.vidafunction backMonster(cid, monster)if #getCreatureSummons(cid) thenmonster = getCreatureSummons(cid)doRemoveCreature(monster)doPlayerSendTextMessage(cid, 13, "Não precio de sua ajuda"..mst[1].."por enquanto")doSendMagicEffect(getThingPos(monster), mst.back)endif getPlayerStorageValue(cid, 18800) >= mst.vezesreturn doPlayerSendCancel(cid, "Seu Summon estar cansado só poderar usar amanhan")endif getPlayerLevel(cid) > mst[2] and mst[3] < getPlayerLevel(cid) thendoSummonCreature(mst[1], getThingPos(cid))doPlayerSendTextMessage(cid, 14, "Venha me ajudar"..mst[1].."nessa batalha")setCreatureMaxHealth(summom[1], hea)doPlayerSetStorageValue(cid, 18800, mst.vezes)doSendMagicEffect(getThingPos(monster), mst.go)elsebackMonster(cid, mst[1])return trueendend Link para o comentário https://xtibia.com/forum/topic/228906-projeto-tutores-de-scripting/page/4/#findComment-1624514 Compartilhar em outros sites More sharing options...
dalvorsn 268 Postado Março 17, 2014 Share Postado Março 17, 2014 (editado) function onUse(cid, item, fromPos, item2, toPos) local info = "Request Board\n\n" doShowTextDialog(cid, 1950, info) end To com muita dificuldade, aqui era pra abrir um caixa de dialogo, mais com um Rank de 1 a 10, contando o Storage "15236", quem tiver mais fica no rank de [1] a [10] Nesse caso é melhor fazer por query, tu vai fazer a query ordenando da maior para menor, Caso não saiba executar queries, use esse site para estudo: http://www.w3schools.com/sql/default.asp As funções de database são: local result = db.getResult(query) result.getDataInt(resId, s) result.getDataLong(resId, s) result.getDataString(resId, s) result.getDataStream(resId, s, length) result.next(resId) result.free(resId) Porem o uso constante de database é um pouco perigoso, faça um sistema de cache, que só executa a query de tempos em tempos, independente de quem requisita o rank(ou seja, salvando numa global storage) Não ha um modo mais fácil ? Não que eu conheça, porque não tem como tu fazer a seleção de todos os storages de certa key por funções lua, se tiver provavelmente vai ser muito mais trabalhoso, ou feito pelas sources, ai tambem daria. Eu fiz ai, porque é um pouco mais complicado esse, entao se tiver duvidas em algum ponto me diga que eu tento esclarecer --#config# local global_storage = 5666 -- global storage do cache local rank_storage = 3600 -- storage do rank local limit = 10 -- limite de players aparecendo no rank local cache_time = 10 -- segundos local function getStorages(key, limit) local ret = {} local query = db.getResult("SELECT player_id, value FROM player_storage WHERE key = "..key.." ORDER BY value DESC LIMIT 10") repeat local player_id, value = query:getDataInt("player_id"), query:getDataInt("value") table.insert(ret, {pid = player_id, value = value}) until not query:next() query:free() return ret end local function getRankStr(key, limit, cache, cache_time) -- getRankStr(key, limit[,cache,[cache_time]]) local ret_str = "Request Board\n\n" if cache then local str = getStorage(global_storage) if str ~= -1 then local last_update = str:match("Last Update: (%d+)") if os.time() <= (tonumber(last_update) + cache_time) then return str:gsub("Last Update: %d+$", "Last Update: ".. os.date("%c", last_update)) end end end local rank_data = getStorages(key, limit) for it, data in pairs(rank_data) do ret_str = ret_str .. string.format("%d \- %s \n", it, getPlayerNameByGUID(data.pid)) end ret_str = ret_str .. "\nLast Update: "..os.time() doSetStorage(global_storage, ret_str) ret_str = ret_str:gsub("Last Update: %d+$", "Last Update: ".. os.date("%c", os.time())) return ret_str end function onUse(cid, item, fromPosition, itemEx, toPosition) return doShowTextDialog(cid, 1950, tostring(getRankStr(rank_storage, limit, true, cache_time))) end Ola eu tenho uma experiencia basica em scripter, porem nunca consigo fazer um codigo(completo) sem bugs mesmo ele sendo simples, gostaria de saber o erro que tem nesse scripter e como poderia funcionar sem bug, obrigado. function onUse(cid, item, frompos, item2, topos) local monster ={ [12597] = {"Troll", 1, 50, vida = 500, vezes = 5, go = 00, gack = 00}, [12598] = {"Amazon", 50, 100, vida = 1000, vezes = 10, go = 00, back = 00}, [12599] = {"Demon", 100, 150, vida = 1500, vezes = 15, go = 00, back = 00} } local summom = getCreatureSummons(cid) local mst = monster[item.actionid] local hea = monster.vida function backMonster(cid, monster) if #getCreatureSummons(cid) then monster = getCreatureSummons(cid) doRemoveCreature(monster) doPlayerSendTextMessage(cid, 13, "Não precio de sua ajuda"..mst[1].."por enquanto") doSendMagicEffect(getThingPos(monster), mst.back) end if getPlayerStorageValue(cid, 18800) >= mst.vezes return doPlayerSendCancel(cid, "Seu Summon estar cansado só poderar usar amanhan") end if getPlayerLevel(cid) > mst[2] and mst[3] < getPlayerLevel(cid) then doSummonCreature(mst[1], getThingPos(cid)) doPlayerSendTextMessage(cid, 14, "Venha me ajudar"..mst[1].."nessa batalha") setCreatureMaxHealth(summom[1], hea) doPlayerSetStorageValue(cid, 18800, mst.vezes) doSendMagicEffect(getThingPos(monster), mst.go) else backMonster(cid, mst[1]) return true end end Primeiro erro: A função getCreatureSummons retorna uma table, logo quando você faz isso: if #getCreatureSummons(cid) then Está retornando o tamanho da tabela, mas é o mesmo que fazer "if 1 then"(numero de summons do player) porem em lua, quase tudo é true em uma condicional, se bota entao uma função que retorna um numero num if, esse if nao faz sentido pois sempre vai ser true, compare ele com algum numero if #getCreatureSummons(cid) >= 1 then -- exemplo Segundo erro: monster = getCreatureSummons(cid) Voce está salvando na variavel monster o endereço da tabela que a função retorna, esse endereço nao é uma creatureId, use getCreatureSummons(cid)[numero], getCreatureSummons(cid)[1] e etc Terceiro erro: Voce usou o mesmo nome de variavel (monster) tanto para configuração como pra salvar o creatureid, no seu script não está errado, porem cuidado ao fazer isso, só não te deu problemas porque voce nao utilizou os dados da tabela inicial monster depois de alterará-la Editado Março 17, 2014 por dalvorsn Link para o comentário https://xtibia.com/forum/topic/228906-projeto-tutores-de-scripting/page/4/#findComment-1624526 Compartilhar em outros sites More sharing options...
kttallan 319 Postado Março 17, 2014 Share Postado Março 17, 2014 Nossa obrigado pela ajuda, este topico ainda espera muitas duvidas minhas Link para o comentário https://xtibia.com/forum/topic/228906-projeto-tutores-de-scripting/page/4/#findComment-1624540 Compartilhar em outros sites More sharing options...
vagnho 0 Postado Março 17, 2014 Share Postado Março 17, 2014 Obrigado Dalvorsn, consegui fazer o script agora estou fazendo aquele da amor mais ele da um erro na tag do creaturescript. Link para o comentário https://xtibia.com/forum/topic/228906-projeto-tutores-de-scripting/page/4/#findComment-1624626 Compartilhar em outros sites More sharing options...
dalvorsn 268 Postado Março 17, 2014 Share Postado Março 17, 2014 Obrigado Dalvorsn, consegui fazer o script agora estou fazendo aquele da amor mais ele da um erro na tag do creaturescript. joga na roda pra gente ver Link para o comentário https://xtibia.com/forum/topic/228906-projeto-tutores-de-scripting/page/4/#findComment-1624629 Compartilhar em outros sites More sharing options...
kttallan 319 Postado Março 17, 2014 Share Postado Março 17, 2014 dalvson poderia me explicar o looping, for e while e tabem como criar funções essa e minha duvida.. Link para o comentário https://xtibia.com/forum/topic/228906-projeto-tutores-de-scripting/page/4/#findComment-1624656 Compartilhar em outros sites More sharing options...
dalvorsn 268 Postado Março 17, 2014 Share Postado Março 17, 2014 dalvson poderia me explicar o looping, for e while e tabem como criar funções essa e minha duvida.. Loop siginifica sequencia, você pode tê-la em lua basicamente de 4 modos for, while, reapeat e atraves de funções por meio de recursão #for Existem dois tipos de for, o for numerico, que e bem simples for i= init, final, increment do -- bloco end i é a variavel de controle, ela serve apenas para receber os valores do contador, ela só existe dentro do laço do for(bloco) init é um valor numerico que voce atribui, ele é o valor onde o loop ira iniciar final é o valor numerico onde ele termina increment é de quanto em quanto ele vai iterar, por padrão esse valor é 1 Ex.: for i=10, 0, -1 do print(i) end for i=50, 100, 10 do print(i) end E existe também dentro do for, o for genérico, que é o que é usado com funções iteradoras por exemplo: for i,v in pairs(table) do print(i,v) end A estrutura dele e assim: for variavel1, [...], variaveln in iterator_function(params) do end Essa funções chamadas de iteradoras existem nativamente, e podem também ser criadas (http://www.xtibia.com/forum/topic/227983-funcoes-iteradoras-em-lua/) o while e repeat são quase iguais, porem tem uma pequena diferença entre eles while (condição for verdadeira) do -- repete enquanto a condição for verdadeira --bloco end --" 'enquanto' tal coisa for verdadeira repita" repeat -- bloco until (condição seja falsa) -- para quando é verdadeira -- 'repetir' 'ate' que condição seja verdadeira Ambas podem ser paradas a qualquer momento com o uso de um 'break' local time = os.time() while true do if time + 5 < os.time() then break end end Particularmente nao gosto de usar break, quase sempre e possivel faze-lo diretamente nas condicionais, mas se quiser usar esta disponivel E por fim existem as funções recursivas, que sao basicamente funções que que chamam elas mesma function it(init, final) print(init) if init + 1 <= final then it(init+1, final) end end Link para o comentário https://xtibia.com/forum/topic/228906-projeto-tutores-de-scripting/page/4/#findComment-1624694 Compartilhar em outros sites More sharing options...
Posts Recomendados