Postado Janeiro 11, 2018 7 anos Olá pessoal, estou com batendo a cabeça com esse script, pois não consigo remover o Simbolo "%" se eu remover ou trocar por outro simbolo ele não funciona. Gostaria que alguém pudesse ajudar, a Retirar o simbolo % que tem no script. (Ps: o sistema é um slot system, ele abre um slot e adiciona um atributo no item, e fica gravado no item o atributo e a porcetagem) Creaturescripts Spoiler ---Script by mock the bear! local conditionMP,conditionHP,conditionML,conditionCLUB,conditionSHI,conditionDIST,conditionAMP = {},{},{},{},{},{},{} for i=1,100 do ---Carrega as conditions --- HP conditionHP = createConditionObject(CONDITION_ATTRIBUTES) setConditionParam(conditionHP, CONDITION_PARAM_TICKS, -1) setConditionParam(conditionHP, CONDITION_PARAM_STAT_MAXHEALTH, 0+i) setConditionParam(conditionHP, CONDITION_PARAM_BUFF, true) setConditionParam(conditionHP, CONDITION_PARAM_SUBID, 50) --MANA conditionMP = createConditionObject(CONDITION_ATTRIBUTES) setConditionParam(conditionMP, CONDITION_PARAM_TICKS, -1) setConditionParam(conditionMP, CONDITION_PARAM_STAT_MAXMANA, 0+i) setConditionParam(conditionMP, CONDITION_PARAM_BUFF, true) setConditionParam(conditionMP, CONDITION_PARAM_SUBID, 51) --Magic level conditionML = createConditionObject(CONDITION_ATTRIBUTES) setConditionParam(conditionML, CONDITION_PARAM_TICKS, -1) setConditionParam(conditionML, CONDITION_PARAM_STAT_MAGICLEVEL, 0+i) setConditionParam(conditionML, CONDITION_PARAM_BUFF, true) setConditionParam(conditionML, CONDITION_PARAM_SUBID, 52) --club axe sword conditionCLUB = createConditionObject(CONDITION_ATTRIBUTES) setConditionParam(conditionCLUB, CONDITION_PARAM_TICKS, -1) setConditionParam(conditionCLUB, CONDITION_PARAM_SKILL_CLUBP, 0+i) setConditionParam(conditionCLUB, CONDITION_PARAM_SKILL_SWORD, 0+i) setConditionParam(conditionCLUB, CONDITION_PARAM_SKILL_AXE, 0+i) setConditionParam(conditionCLUB, CONDITION_PARAM_BUFF, true) setConditionParam(conditionCLUB, CONDITION_PARAM_SUBID, 53) --- shield conditionSHI = createConditionObject(CONDITION_ATTRIBUTES) setConditionParam(conditionSHI, CONDITION_PARAM_TICKS, -1) setConditionParam(conditionSHI, CONDITION_PARAM_SKILL_SHIELD, 0+i) setConditionParam(conditionSHI, CONDITION_PARAM_BUFF, true) setConditionParam(conditionSHI, CONDITION_PARAM_SUBID, 54) --- dist conditionDIST = createConditionObject(CONDITION_ATTRIBUTES) setConditionParam(conditionDIST, CONDITION_PARAM_TICKS, -1) setConditionParam(conditionDIST, CONDITION_PARAM_SKILL_DISTANCE, 0+i) setConditionParam(conditionDIST, CONDITION_PARAM_BUFF, true) setConditionParam(conditionDIST, CONDITION_PARAM_SUBID, 55) end function getSlotType(n) --By mock the bear if not n then return false end if n:match('%[(.+)%]') then n = n:match('%[(.+)%]') if n == '?' then return 0,n else return n:match('(.-)%.([+-])(%d+)%%') end else return false end end local function loadSet(cid) local t = {} for slot=1,9 do t[slot] = '' local s = getPlayerSlotItem(cid,slot).uid if s ~= 0 then t[slot] = getItemName(s) end end return t end function isInArray2(arr,var) -- Because in some servers it return 1 and 0 and others true and false for i,b in pairs(arr) do if var == b then return true end end return false end function check2(cid,i) if i == 5 or i == 6 then if isInArray({'head','necklace','backpack','body','legs','feet','ring'},getItemValue(getPlayerSlotItem(cid,i).itemid,'slotType') or '') then return false end end return true end function chk(cid,f) if not isPlayer(cid) then return end local t = loadSet(cid) for i=1,#f do if f ~= t then equip(cid,nil,slot) break end end addEvent(chk,2000,cid,t) end items = { ---- Only to get attr: slotType because getItemName dont return it -.-' _VERSION='1.0 By mock', XML_DIR='data/items/items.xml', } do local ia = os.clock() io.write('Loading items') local i = io.open(items.XML_DIR,'r') local u = i:read(-1) i:close() local u = u:match('<items>(.+)</items>') for mi,id,mid,name,data,me in u:gmatch('<(%a-)%s*id%s*=%s*"(%d+)"%s*(.-)%s*name%s*=%s*"(.-)"%s*>(.-)</(%a*)>') do if mi == 'item' and me == 'item' then local td = {name=name,id=id,type=1} for key,value in data:gmatch('<attribute key="(.-)" value="(.-)"/>') do td[key] = value end for key,value in mid:gmatch('(.-)="(.-)"') do td[key] = value end items[tonumber(id)] = td items[name] = td end end for mi,id,mid,name,data in u:gmatch('<(%a-)%s*id%s*=%s*"(%d*)"%s*(.-)%s*name%s*=%s*"(%a+)"%s*/>') do if mi == 'item' then local td = {name=name,id=id,type=2} for key,value in mid:gmatch('(.-)="(.-)"') do td[key] = value end items[tonumber(id)] = td items[name] = td end end io.write('[done '..os.clock()-ia..']\n') end function getItemValue(item,value) return items[item] and items[item][value] end function equip(cid,item,slot) --By mock the bear local HP = getCreatureHealth(cid) local MP = getCreatureMana(cid) local t = {} if item then local mm,sinal,qto = getSlotType(getItemName(item.uid)) t[mm] = tonumber(qto) end for i=1,9 do -- Not on slot 10 > arrow if i ~= slot then if getPlayerSlotItem(cid,i).itemid ~= 0 then local aab = getPlayerSlotItem(cid,i).uid if aab and check2(cid,i) then for _ in getItemName(aab):gmatch('(%[.-%])') do local mm,sinal,qto2 = getSlotType(_) if mm then if not t[mm] then t[mm] = 0 end t[mm] = t[mm]+tonumber(qto2) t[mm] = t[mm] > 100 and 100 or t[mm] end end end end end end local fu = 0 local ca = {} local s = '' for sl,n in pairs(t) do fu = fu+1 s = s..''..n..'% more of '..sl..'\n' if sl == 'hp' then doAddCondition(cid,conditionHP[tonumber(n)]) doCreatureAddHealth(cid,HP-getCreatureHealth(cid)) ca[50] = 1 doPlayerSendTutorial(cid,19) elseif sl == 'mp' then doAddCondition(cid,conditionMP[tonumber(n)]) doCreatureAddMana(cid,HP-getCreatureMana(cid)) ca[51] = 1 doPlayerSendTutorial(cid,19) elseif sl == 'ml' then doAddCondition(cid,conditionML[tonumber(n)]) ca[52] = 1 elseif sl == 'cas' then doAddCondition(cid,conditionCLUB[tonumber(n)]) ca[53] = 1 elseif sl == 'shield' then doAddCondition(cid,conditionSHI[tonumber(n)]) ca[54] = 1 elseif sl == 'dist' then doAddCondition(cid,conditionDIST[tonumber(n)]) ca[55] = 1 end end if fu > 0 then addEvent(doPlayerSendTextMessage,100,cid,24,'You have:\n'..s) for i=50,55 do if not ca then doRemoveCondition(cid,CONDITION_ATTRIBUTES,i) end end else for i=50,55 do doRemoveCondition(cid,CONDITION_ATTRIBUTES,i) end end return true end function onLogin(cid) ---Script by mock the bear! equip(cid,nil,slot) addEvent(chk,2000,cid,loadSet(cid)) -- Here we check! return TRUE end Actions Spoiler --[[ Slot system 100% by mock \o ]] ---Config local conf = { maxSlotCount=2, ignoredIds={} } --End function choose(...) --- Function by mock. local arg = {...} return arg[math.random(1,#arg)] end if not getItemAttack then function getItemAttack(uid) return getItemAttribute(uid,'attack') end function getItemDefense(uid) return getItemAttribute(uid,'defense') end end local function isArmor(uid) -- Function by Mock the bear. if (getItemInfo(uid.itemid).armor ~= 0) and (getItemWeaponType(uid.uid) == 0) then return true end return false end local function isWeapon(uid) -- Function by Mock the bear. uid = uid or 0 local f = getItemWeaponType(uid) if f == 1 or f == 2 or f == 3 then return true end return false end local function isShield(uid) -- Function by Mock the bear. uid = uid or 0 if getItemWeaponType(uid) == 4 then return true end return false end local function isBow(uid) -- Function by Mock the bear. uid = uid or 0 if getItemWeaponType(uid) == 5 and not isItemStackable(uid) then return true end return false end function onUse(cid, item, fromPosition, itemEx, toPosition) -- Script by mock the bear (MTB) if item.uid == 0 or item.itemid == 0 then return false end toPosition.stackpos = 255 if item.uid == 0 or item.itemid == 0 then return false end toPosition.stackpos = 255 if isInArray(conf.ignoredIds, itemEx.itemid) or (not getItemWeaponType(itemEx.uid) or getItemWeaponType(itemEx.uid) > 5) or (getItemWeaponType(itemEx.uid) == 0 and not isArmor(itemEx)) or itemEx.itemid == 0 or itemEx.type > 1 or isItemStackable(itemEx.uid) then doPlayerSendTextMessage(cid, 24,"You cant open a slot on this item.") return TRUE end if isCreature(itemEx.uid) then return FALSE end local nam = getItemName(itemEx.uid) function getper() local n = 1 for i=1,10 do n = n+math.random(0,10) if n < 8*i then break end end return n end function getSlotCount(nam) local c = 0 for _ in nam:gmatch('%[(.-)%]') do c = c+1 end return c end if getSlotCount(nam) < conf.maxSlotCount then local l = choose('hp','mp','ml','cas','shield','dist') local p = getper() doSendMagicEffect(toPosition,30) nam = nam..' ['..l..'.+'..p..'%]' doSendAnimatedText(toPosition,l..' '..p..'%',120) doItemSetAttribute(itemEx.uid,'name',nam) doRemoveItem(item.uid,1) else doPlayerSendTextMessage(cid, 24,"You cant open a slot on this item.") end return true end Agradeço desde já !
Postado Janeiro 12, 2018 7 anos tenho quase ctza q eu ja fiz isso pra um membro do fórum, só não sei dizer se foi por pm ou por um tópico. Dá uma procurada q se pá vc acha. O Mock faz uns códigos muito dificeis de ler e ele complica demais coisas simples basicamente ele adiciona a % e pega o level do item baseado num pattern matching. O problema é que você tem que saber quando o % representa '%' e quando ele representa um escape string, por ex: if n:match('%[(.+)%]') then o primeiro % serve para falar que queremos o caractere [, o segundo também. Nenhum desses você vai remover. Agora nesse caso aqui debaixo n:match('(.-)%.([+-])(%d+)%%') vc tá tentando dar match em algo q seja do formato 'qualquercoisa'.'+ ou -''um numero''%' o primeiro porcento é pra indicar escape string, ele está ali pra falar que nós queremos usar o ponto como o caractere ponto e não como uma instrução (o ponto significa qualquer coisa), o segundo % é pra indicar que queremos um %d+, que é um ou mais digitos, ou seja, ele vai retornar o maior numero de numeros consecutivos que encontrar, e os dois ultimos: o primeiro é pra mostrar que estamos querendo usar como escape string, o segundo representa o % de fato. Então se vc quiser q só tenha até o numero é só remover esses dois ultimos % do fim. Pro restante, tenha em mente que as receitas de padrões vão sempre procurar casar com o nome do item, se a % tá no final, vc só precisa apagar os % que estão no fim. Coloca pra ir printando os valores como eu fiz aqui https://repl.it/repls/InbornAuthenticRaven e aí vc vai ter uma ideia melhor do que ele ta retornando e oque vc pode e não pode remover. Todos os meus trabalhos importantes estão na seção "Sobre mim" no meu perfil; Dá uma passada lá! "Há três caminhos para o fracasso: não ensinar o que se sabe, não praticar o que se ensina, e não perguntar o que se ignora." - São Beda (obg ao @Beeny por fazer essa linda sign <3)
Postado Janeiro 15, 2018 7 anos Autor @xWhiteWolf não consegui de maneira alguma , será que você poderia dá uma ajudinha a mais ? kk
Postado Janeiro 15, 2018 7 anos --[[ Slot system 100% by mock \o ]] ---Config local conf = { maxSlotCount=2, ignoredIds={} } --End function choose(...) --- Function by mock. local arg = {...} return arg[math.random(1,#arg)] end if not getItemAttack then function getItemAttack(uid) return getItemAttribute(uid,'attack') end function getItemDefense(uid) return getItemAttribute(uid,'defense') end end local function isArmor(uid) -- Function by Mock the bear. if (getItemInfo(uid.itemid).armor ~= 0) and (getItemWeaponType(uid.uid) == 0) then return true end return false end local function isWeapon(uid) -- Function by Mock the bear. uid = uid or 0 local f = getItemWeaponType(uid) if f == 1 or f == 2 or f == 3 then return true end return false end local function isShield(uid) -- Function by Mock the bear. uid = uid or 0 if getItemWeaponType(uid) == 4 then return true end return false end local function isBow(uid) -- Function by Mock the bear. uid = uid or 0 if getItemWeaponType(uid) == 5 and not isItemStackable(uid) then return true end return false end function onUse(cid, item, fromPosition, itemEx, toPosition) -- Script by mock the bear (MTB) if item.uid == 0 or item.itemid == 0 then return false end toPosition.stackpos = 255 if item.uid == 0 or item.itemid == 0 then return false end toPosition.stackpos = 255 if isInArray(conf.ignoredIds, itemEx.itemid) or (not getItemWeaponType(itemEx.uid) or getItemWeaponType(itemEx.uid) > 5) or (getItemWeaponType(itemEx.uid) == 0 and not isArmor(itemEx)) or itemEx.itemid == 0 or itemEx.type > 1 or isItemStackable(itemEx.uid) then doPlayerSendTextMessage(cid, 24,"You cant open a slot on this item.") return true end if isCreature(itemEx.uid) then return false end local nam = getItemName(itemEx.uid) function getper() local n = 1 for i=1,10 do n = n+math.random(0,10) if n < 8*i then break end end return n end function getSlotCount(nam) local c = 0 for _ in nam:gmatch('%[(.-)%]') do c = c+1 end return c end if getSlotCount(nam) < conf.maxSlotCount then local l = choose('hp','mp','ml','cas','shield','dist') local p = getper() doSendMagicEffect(toPosition,30) nam = nam..' ['..l..'.+'..p..']' doSendAnimatedText(toPosition,l..' '..p..'',120) doItemSetAttribute(itemEx.uid,'name',nam) doRemoveItem(item.uid,1) else doPlayerSendTextMessage(cid, 24,"You cant open a slot on this item.") end return true end ---Script by mock the bear! local conditionMP,conditionHP,conditionML,conditionCLUB,conditionSHI,conditionDIST,conditionAMP = {},{},{},{},{},{},{} for i=1,100 do ---Carrega as conditions --- HP conditionHP = createConditionObject(CONDITION_ATTRIBUTES) setConditionParam(conditionHP, CONDITION_PARAM_TICKS, -1) setConditionParam(conditionHP, CONDITION_PARAM_STAT_MAXHEALTH, 0+i) setConditionParam(conditionHP, CONDITION_PARAM_BUFF, true) setConditionParam(conditionHP, CONDITION_PARAM_SUBID, 50) --MANA conditionMP = createConditionObject(CONDITION_ATTRIBUTES) setConditionParam(conditionMP, CONDITION_PARAM_TICKS, -1) setConditionParam(conditionMP, CONDITION_PARAM_STAT_MAXMANA, 0+i) setConditionParam(conditionMP, CONDITION_PARAM_BUFF, true) setConditionParam(conditionMP, CONDITION_PARAM_SUBID, 51) --Magic level conditionML = createConditionObject(CONDITION_ATTRIBUTES) setConditionParam(conditionML, CONDITION_PARAM_TICKS, -1) setConditionParam(conditionML, CONDITION_PARAM_STAT_MAGICLEVEL, 0+i) setConditionParam(conditionML, CONDITION_PARAM_BUFF, true) setConditionParam(conditionML, CONDITION_PARAM_SUBID, 52) --club axe sword conditionCLUB = createConditionObject(CONDITION_ATTRIBUTES) setConditionParam(conditionCLUB, CONDITION_PARAM_TICKS, -1) setConditionParam(conditionCLUB, CONDITION_PARAM_SKILL_CLUBP, 0+i) setConditionParam(conditionCLUB, CONDITION_PARAM_SKILL_SWORD, 0+i) setConditionParam(conditionCLUB, CONDITION_PARAM_SKILL_AXE, 0+i) setConditionParam(conditionCLUB, CONDITION_PARAM_BUFF, true) setConditionParam(conditionCLUB, CONDITION_PARAM_SUBID, 53) --- shield conditionSHI = createConditionObject(CONDITION_ATTRIBUTES) setConditionParam(conditionSHI, CONDITION_PARAM_TICKS, -1) setConditionParam(conditionSHI, CONDITION_PARAM_SKILL_SHIELD, 0+i) setConditionParam(conditionSHI, CONDITION_PARAM_BUFF, true) setConditionParam(conditionSHI, CONDITION_PARAM_SUBID, 54) --- dist conditionDIST = createConditionObject(CONDITION_ATTRIBUTES) setConditionParam(conditionDIST, CONDITION_PARAM_TICKS, -1) setConditionParam(conditionDIST, CONDITION_PARAM_SKILL_DISTANCE, 0+i) setConditionParam(conditionDIST, CONDITION_PARAM_BUFF, true) setConditionParam(conditionDIST, CONDITION_PARAM_SUBID, 55) end function getSlotType(n) --By mock the bear if not n then return false end if n:match('%[(.+)%]') then n = n:match('%[(.+)%]') if n == '?' then return 0,n else return n:match('(.-)%.([+-])(%d+)') end else return false end end local function loadSet(cid) local t = {} for slot=1,9 do t[slot] = '' local s = getPlayerSlotItem(cid,slot).uid if s ~= 0 then t[slot] = getItemName(s) end end return t end function isInArray2(arr,var) -- Because in some servers it return 1 and 0 and others true and false for i,b in pairs(arr) do if var == b then return true end end return false end function check2(cid,i) if i == 5 or i == 6 then if isInArray({'head','necklace','backpack','body','legs','feet','ring'},getItemValue(getPlayerSlotItem(cid,i).itemid,'slotType') or '') then return false end end return true end function chk(cid,f) if not isPlayer(cid) then return end local t = loadSet(cid) for i=1,#f do if f ~= t then equip(cid,nil,slot) break end end addEvent(chk,2000,cid,t) end items = { ---- Only to get attr: slotType because getItemName dont return it -.-' _VERSION='1.0 By mock', XML_DIR='data/items/items.xml', } do local ia = os.clock() io.write('Loading items') local i = io.open(items.XML_DIR,'r') local u = i:read(-1) i:close() local u = u:match('<items>(.+)</items>') for mi,id,mid,name,data,me in u:gmatch('<(%a-)%s*id%s*=%s*"(%d+)"%s*(.-)%s*name%s*=%s*"(.-)"%s*>(.-)</(%a*)>') do if mi == 'item' and me == 'item' then local td = {name=name,id=id,type=1} for key,value in data:gmatch('<attribute key="(.-)" value="(.-)"/>') do td[key] = value end for key,value in mid:gmatch('(.-)="(.-)"') do td[key] = value end items[tonumber(id)] = td items[name] = td end end for mi,id,mid,name,data in u:gmatch('<(%a-)%s*id%s*=%s*"(%d*)"%s*(.-)%s*name%s*=%s*"(%a+)"%s*/>') do if mi == 'item' then local td = {name=name,id=id,type=2} for key,value in mid:gmatch('(.-)="(.-)"') do td[key] = value end items[tonumber(id)] = td items[name] = td end end io.write('[done '..os.clock()-ia..']\n') end function getItemValue(item,value) return items[item] and items[item][value] end function equip(cid,item,slot) --By mock the bear local HP = getCreatureHealth(cid) local MP = getCreatureMana(cid) local t = {} if item then local mm,sinal,qto = getSlotType(getItemName(item.uid)) t[mm] = tonumber(qto) end for i=1,9 do -- Not on slot 10 > arrow if i ~= slot then if getPlayerSlotItem(cid,i).itemid ~= 0 then local aab = getPlayerSlotItem(cid,i).uid if aab and check2(cid,i) then for _ in getItemName(aab):gmatch('(%[.-%])') do local mm,sinal,qto2 = getSlotType(_) if mm then if not t[mm] then t[mm] = 0 end t[mm] = t[mm]+tonumber(qto2) t[mm] = t[mm] > 100 and 100 or t[mm] end end end end end end local fu = 0 local ca = {} local s = '' for sl,n in pairs(t) do fu = fu+1 s = s..''..n..'% more of '..sl..'\n' if sl == 'hp' then doAddCondition(cid,conditionHP[tonumber(n)]) doCreatureAddHealth(cid,HP-getCreatureHealth(cid)) ca[50] = 1 doPlayerSendTutorial(cid,19) elseif sl == 'mp' then doAddCondition(cid,conditionMP[tonumber(n)]) doCreatureAddMana(cid,HP-getCreatureMana(cid)) ca[51] = 1 doPlayerSendTutorial(cid,19) elseif sl == 'ml' then doAddCondition(cid,conditionML[tonumber(n)]) ca[52] = 1 elseif sl == 'cas' then doAddCondition(cid,conditionCLUB[tonumber(n)]) ca[53] = 1 elseif sl == 'shield' then doAddCondition(cid,conditionSHI[tonumber(n)]) ca[54] = 1 elseif sl == 'dist' then doAddCondition(cid,conditionDIST[tonumber(n)]) ca[55] = 1 end end if fu > 0 then addEvent(doPlayerSendTextMessage,100,cid,24,'You have:\n'..s) for i=50,55 do if not ca then doRemoveCondition(cid,CONDITION_ATTRIBUTES,i) end end else for i=50,55 do doRemoveCondition(cid,CONDITION_ATTRIBUTES,i) end end return true end function onLogin(cid) ---Script by mock the bear! equip(cid,nil,slot) addEvent(chk,2000,cid,loadSet(cid)) -- Here we check! return true end Aviso logo, usar scripts do mock é a pior coisa que alguém sem problemas psicológicos pode fazer na vida enquanto lida com otserver. O uso desses scripts acarreta demência com o tempo de uso. _ .-'` `} _./) / } .'o \ | } '.___.'`.\ {` /`\_/ , `. } ME DA UMA NOZ! \=' .-' _`\ { `'`;/ `, } _\ @ ; } /__`;-...'--' Cluck!
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.