--==<< CV TWorkers functions >>==-- --==<< By CV Version 2.01 >>==-- local _archivo = "workers" -- Puedes ponerle el nombre que tu quieras al archivo por defecto. / Name by default for txt file. local lugar = "/userfunctions/" -- Puedes crear una carpeta especial donde guardar el archivo y especificarla aquí. / Folder to save the txt file local _sep = " | "; local titulo = "--==<< CV TWorkers data >>==--\n--==<< By CV Version 2.01 >>==--\n"; local ignoreP = {"Playerone","Playertwo","Playerthree"} -- Personajes que no quieras guardar en la lista. / List of player to be ignored. local dbg = false local secpas = "xxxxxxxxxxx" -- Secondary password for buy charges from Itemshop local vendedores = {123021,123134} -- Merchants fusionStones = {202880,202882,202883,202885,202995,202996,202997,202998,203000,203001,203002,203003,203004,206219,206220,206227,206694,207004,202999} cintos = {228966,228996} -- Belts function file_check(file_name) local file_found=io.open(getExecutionPath()..lugar..file_name..".txt", "r") if file_found==nil then return false else return true end end function xBots(_serv) if not _serv then _serv = _archivo end if file_check(_serv) then local losBots = {} local datos = start_file(_serv) for i,linea in ipairs(datos) do ladata = myExplode(" | ",linea) table.insert(losBots,ladata[1]) end local count = 0 for lB in pairs(losBots) do count = count + 1 end if count > 0 then return losBots else return nil end else return nil end end function xData(_ser,_eld) if _eld then dbg = true end if not _ser then _ser = _archivo end if file_check(_ser) then local losBots = {} local datos = start_file(_ser) local devuelvo = nil for i,linea in ipairs(datos) do laxdata = myExplode(" | ",linea) if (player.Name == tostring(laxdata[1])) then if dbg then print(linea) end devuelvo = linea end end if devuelvo then return devuelvo else return nil end else return nil end end function myExplode(div,str) if (div=='') then return false end local pos,arr = 0,{} for st,sp in function() return string.find(str,div,pos,true) end do table.insert(arr,string.sub(str,pos,st-1)) pos = sp + 1 end table.insert(arr,string.sub(str,pos)) return arr end function start_file(_arch) if _arch then archN = _arch else archN = _archivo end local tws = {} local i = 1 if file_check(archN) then file = assert(io.open(getExecutionPath()..lugar..archN..".txt", "r")) if dbg then cprintf(cli.yellow, "\rLeemos..\n"); end for linea in file:lines() do if string.sub(linea, 1, 2) ~= '--' and string.sub(linea, 1) ~= '' then tws[i] = linea if dbg then cprintf(cli.yellow, "\r%d -> %s\n",i,linea ); end i = i + 1 end end file:close() return tws; else cprintf(cli.blue, "\nTWorkers creara el archivo : %s\n",getExecutionPath()..lugar..archN..".txt" ); f = io.open(getExecutionPath()..lugar..archN..".txt","w") f:write(titulo) f:close() return tws; end end local function worker_Data() player:update() local _datos = player.Name.._sep; local piedraP = inventory:itemTotalCount(202881); local pTokenCount = inventory:itemTotalCount(203038); local cintoT = 0 local piedraN = 0 local cargas = 0 for i, t in pairs(cintos) do cintoT = cintoT + inventory:itemTotalCount(t); yrest(150) end for i, p in pairs(fusionStones) do piedraN = piedraN + inventory:itemTotalCount(p); yrest(150) end if RoMScript("IsMagicBoxEnable()") then cargas = RoMScript('GetMagicBoxEnergy();') else cargas = 0 end return _datos..cintoT.._sep..piedraN.._sep..cargas.._sep..piedraP.._sep..pTokenCount.._sep.."0".._sep..os.date() end function compraT(_carga) printf("\nCompraremos %s cargas...\n",_carga); RoMScript('DEFAULT_CHAT_FRAME:AddMessage("|cffFF99FF'..player.Name..' comprará '.._carga..' cargas.|r")'); coincarga = FindItemShopGUID(202928,"coin") BuyFromItemShop(coincarga, secpas,_carga) yrest(1500); inventory:update() for c = 1, inventory:itemTotalCount(202928) do inventory:useItem(202928) yrest(700); end yrest(1500); cargas = RoMScript('GetMagicBoxEnergy()'); end function compraB(_belt) if (not _belt) or (tonumber(_belt) == 0 ) or (tonumber(_belt) == nil) then inventory:update() yrest(150) _belt = inventory:itemTotalCount(0) end local pCinto = nil local vendedor = nil for _ib, bm in ipairs(vendedores) do vendedor = player:findNearestNameOrId(bm) if vendedor then pCinto = cintos[_ib] break end end if pCinto then printf("\nCompraremos %s %s con %s\n",_belt,GetIdName(pCinto),vendedor.Name); player:openStore(vendedor.Id) yrest(800) store:buyItem(pCinto,_belt); yrest(500); inventory:update() else cprintf(cli.red,"\nNo se encontro ningun mercader.\n") end end function compraS(_stone) if (not _stone) or (tonumber(_stone) == 0 ) or (tonumber(_stone) == nil) then inventory:update() yrest(150) _stone = inventory:itemTotalCount(0) end local vendedor = player:findNearestNameOrId(110576) if vendedor then printf("\nCompraremos %s %s con %s\n",_stone,GetIdName(202999),vendedor.Name); player:openStore(vendedor.Id) yrest(800) store:buyItem(202999,_stone); yrest(500); inventory:update() else cprintf(cli.red,"\nNo se encontro ningun mercader.\n") end end function VaciarCaja() for c = 51,55 do inventory:update() local item = inventory.BagSlot[c] item:update() if item.Available and (not item.Empty) then if inventory:itemTotalCount(0) > 0 then item:pickup() yrest(700); item:moveTo("bag") yrest(700); inventory:update() else print("\nNo hay suficiente espacio en la mochila\n"); return true end end end end function revisoTransmu(_pi,_ci) local pi = false; local ci = false; local pc = 0 local cc = 0 for c = 51,55 do inventory:update() local item = inventory.BagSlot[c] item:update() if item.Available and (item.Id == _ci) then pi = true pc = pc + 1 end if item.Available and (item.Id == _ci) then ci = true cc = cc + 1 end end if pc > 1 or cc > 1 then print("Demasiados items en el transmutador. Vaciando...") pi = false ci = false VaciarCaja() end yrest(150) if pi and ci then return true else return false end end function fusionando(y,z) local piedra = inventory:findItem(y) local cint = inventory:findItem(z) local limite = 0 if VaciarCaja() then cprintf(cli.red,"\nSe aborta la operacion por mochila llena\n") return end if piedra and cint then cint:moveTo("magicbox") yrest(150); piedra:moveTo("magicbox") yrest(250); limite = os.time() repeat yrest(250) until revisoTransmu(y,z) or (9 > (os.time() - limite)) limite = os.time() while(revisoTransmu(y,z)) do RoMScript("MagicBoxRequest()"); inventory:update() yrest(250) if ((os.time() - limite) > 9) then cprintf(cli.red,"\rLimite de tiempo exedido...\n") break; end end VaciarCaja(); end inventory:update() end function fusionaP(_cp,_cc,_p) local ct = 0 local cargas = RoMScript('GetMagicBoxEnergy()'); if _p then fS = {202881} else fS = fusionStones end if _cp > _cc then maxF = _cc else maxF = _cp end if maxF > cargas then toBuy = math.floor((maxF - cargas)/10) + 1 if inventory:itemTotalCount(203038) > (toBuy*100) then compraT(toBuy) else toBuy = math.floor(inventory:itemTotalCount(203038)/100) compraT(toBuy) end end for i, k in pairs(cintos) do if (inventory:itemTotalCount(k) > 0) then cprintf(cli.lightgreen, "\rUsaremos %s\n",GetIdName(k) ); for n, c in pairs(fS) do local fin = false if (inventory:itemTotalCount(c) > 0) then cprintf(cli.lightgreen, "\rCombinaremos con %s\n",GetIdName(c) ); repeat inventory:update() yrest(150) if (1 > inventory:itemTotalCount(c)) then cprintf(cli.lightblue, "\rTerminamos con %s\n",GetIdName(c) ); fin = true break end if (1 > inventory:itemTotalCount(k)) then cprintf(cli.lightblue, "\rTerminamos con %s\n",GetIdName(k) ); fin = true break end cargas = RoMScript('GetMagicBoxEnergy()'); if (1 > cargas) then if inventory:itemTotalCount(203038) > 99 then compraT(1) else cprintf(cli.red, "\rNo hay mas cargas.\n"); fin = true break end end if (not fin) then fusionando(c,k) end until fin end end end end end function save_TW(_fileN,_dbg) if _dbg then local dbg = true end if _fileN then nameF = _fileN else nameF = _archivo end local count = 0 local inList = false local datos = start_file(nameF) local iP = false for m,n in pairs(ignoreP) do if (player.Name == n) then iP = true end end if iP then cprintf(cli.lightgreen, "\nTWorkers ignora al jugador %s\n",player.Name ); else for h in pairs(datos) do count = count + 1 end if dbg then cprintf(cli.lightblue, "\r El registro posee %d filas\n",count ); end if count > 0 then if dbg then cprintf(cli.lightblue, "\rPara guardar..\n"); end for i,t in ipairs(datos) do if dbg then cprintf(cli.lightblue, "\r%d -> %s\n",i,t ); end if string.find(t, player.Name) then datos[i] = worker_Data() if dbg then cprintf(cli.blue, "\rEditamos la linea : %d\t",i ); end inList = true end end if not inList then datos[(count + 1)] = worker_Data() if dbg then cprintf(cli.blue, "\rSe agregó al Personaje : %s\t",player.Name ); end end else datos[count + 1] = worker_Data() end archivo = assert(io.open(getExecutionPath()..lugar..nameF..".txt", "w")) archivo:write(titulo) archivo:close() archivo = assert(io.open(getExecutionPath()..lugar..nameF..".txt", "a+")) for i, d in ipairs(datos) do archivo:write("\n"..d) end archivo:close() cprintf(cli.lightgreen, "\nTWorkers guardo la linea : %s\n en %s\n",worker_Data(),getExecutionPath()..lugar..nameF ); end end function fusion_TW(laPuri) local cintoT = 0 local piedraN = 0 local piedraP = inventory:itemTotalCount(202881); for i, t in pairs(cintos) do cintoT = cintoT + inventory:itemTotalCount(t); yrest(150) end for i, p in pairs(fusionStones) do piedraN = piedraN + inventory:itemTotalCount(p); yrest(150) end if laPuri then piedraF = piedraP else piedraF = piedraN end if RoMScript("IsMagicBoxEnable()") then RoMScript("MagicBoxFrame:Show()") if cintoT ~= 0 and piedraF ~= 0 then VaciarCaja(); fusionaP(piedraF,cintoT,laPuri) else RoMScript('DEFAULT_CHAT_FRAME:AddMessage("|cffFF99FF'..player.Name..' no tiene suficientes elementos para fusionar.|r")'); end inventory:update(); cargas = RoMScript('GetMagicBoxEnergy()'); mana = inventory:itemTotalCount(202844); printf("\nTenemos %d %s\n",mana,GetIdName(202844)); if mana > 3 then manax = math.floor(mana/3) if manax > 3 then manaxx = math.floor(manax/3) if manaxx > 3 then fusiones = math.floor(manaxx/3) + manaxx + manax printf("\nTenemos %d fusiones por hacer.\n",fusiones); else fusiones = manaxx + manax printf("\nTenemos %d fusiones por hacer.\n",fusiones); end else fusiones = manax printf("\nTenemos %d fusiones por hacer.\n",fusiones); end else fusiones = 0 printf("\nTenemos %d fusiones por hacer.\n",fusiones); end if fusiones > 0 then if fusiones > cargas then toBuy = math.floor((fusiones - cargas)/10) + 1 if inventory:itemTotalCount(203038) > (toBuy*100) then compraT(toBuy) else toBuy = math.floor(inventory:itemTotalCount(203038)/100) compraT(toBuy) end end Fusion_MakeMaxManaStones(); yrest(0000); else RoMScript('DEFAULT_CHAT_FRAME:AddMessage("|cffFF99FF'..player.Name..' no tiene suficientes |r|cffFFFFFF'..GetIdName(202844)..'|r|cffFF99FF para fusionar.|r")'); end else printf("%s aun no activa el transmutador.\n", player.Name); RoMScript('DEFAULT_CHAT_FRAME:AddMessage("|cffFF99FF'..player.Name..' aun no activa el transmutador |r")'); end end function load_TW(_nom,deb) if deb then local dbg = true end if _nom then nameF = _nom else nameF = _archivo end cprintf(cli.lightgreen, "\nTWorkers leera datos de %s\n",getExecutionPath()..lugar..nameF ); local datos = start_file(nameF) return datos; end function elEnvio(nom,it,can,ser,_dbg) if _dbg then local dbg = true end if ser then nameF = ser else nameF = _archivo end if it == 0 then ar = 2 else ar = 3 end local count = 0 local inList = false local datos = start_file(nameF) local iP = false for m,n in pairs(ignoreP) do if (nom == n) then iP = true end end if iP then cprintf(cli.lightgreen, "\nTWorkers ignora al jugador %s\n",player.Name ); else for h in pairs(datos) do count = count + 1 end if dbg then cprintf(cli.lightblue, "\r El registro posee %d filas\n",count ); end if count > 0 then for i,t in ipairs(datos) do if string.find(t, nom) then if dbg then cprintf(cli.blue, "\rGuardando envio : %d\t",_up ); end edito = myExplode(" | ",t); edito[7] = 1; edito[ar] = tonumber(edito[ar]) + tonumber(can) datos[i] = edito[1].._sep..edito[2].._sep..edito[3].._sep..edito[4].._sep..edito[5].._sep..edito[6].._sep..edito[7]; if dbg then cprintf(cli.blue, "\rEditamos la linea : %d\t",i ); end inList = true end end if not inList then cprintf(cli.blue, "\rNo se encontro al Personaje : %s\t",nom ); else archivo = assert(io.open(getExecutionPath()..lugar..nameF..".txt", "w")) archivo:write(titulo) archivo:close() archivo = assert(io.open(getExecutionPath()..lugar..nameF..".txt", "a+")) for i, d in ipairs(datos) do archivo:write("\n"..d) end archivo:close() end end end end