Postado Abril 17, 2017 8 anos Boa noite amigos, queria um script pra mostrar o número de resets quando o player da o look. Segue meu script de reset, utilizo mysql para gerencia o db. Versão do ot: 8.6 forgotten server. --[[Script made 100% by Nogard and Night Wolf. You can feel free to edit anything you want, but don't remove the credits]] local config = { minlevel = 350, --- level inical para resetar price = 100000, --- preço inicial para resetar newlevel = 8, --- level após reset priceByReset = 100000, --- preço acrescentado por reset percent = 100, ---- porcentagem da vida/mana que você terá ao resetar (em relação à sua antiga vida total) maxresets = 1000, levelbyreset = 5 --- quanto de level vai precisar a mais no próximo reset } --- end config function getResets(uid) resets = getPlayerStorageValue(uid, 378378) if resets < 0 then resets = 0 end return resets end local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid function addReset(cid) if(npcHandler:isFocused(cid)) then npcHandler:releaseFocus(cid) end talkState[talkUser] = 0 resets = getResets(cid) setPlayerStorageValue(cid, 378378, resets+1) doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid))) local hp = getCreatureMaxHealth(cid) local resethp = hp*(config.percent/100) setCreatureMaxHealth(cid, resethp) local differencehp = (hp - resethp) doCreatureAddHealth(cid, -differencehp) local mana = getCreatureMaxMana(cid) local resetmana = mana*(config.percent/100) setCreatureMaxMana(cid, resetmana) local differencemana = (mana - resetmana) doCreatureAddMana(cid, -differencemana) doRemoveCreature(cid) local description = resets+1 db.query("UPDATE `players` SET `description` = ' [Reset: "..description.."] ' WHERE `players`.`id`= ".. playerid .."") db.query("UPDATE `players` SET `level`="..config.newlevel..",`experience`= 0 WHERE `players`.`id`= ".. playerid .."") return true end local newPrice = config.price + (getResets(cid) * config.priceByReset) local newminlevel = config.minlevel + (getResets(cid) * config.levelbyreset) if msgcontains(msg, 'reset') then if getResets(cid) < config.maxresets then selfSay('Voce quer resetar ? vai custar '..newPrice..' gp\'s!', cid) talkState[talkUser] = 1 else selfSay('You already reached the maximum reset level!', cid) end elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then if getPlayerMoney(cid) < newPrice then selfSay('É necessário ter no mínimo'..newPrice..' gp\'s pra resetar!', cid) elseif getPlayerLevel(cid) < newminlevel then selfSay('O level minimo pra resetar é '..newminlevel..'!', cid) else doPlayerRemoveMoney(cid,newPrice) playerid = getPlayerGUID(cid) addEvent(function() if isPlayer(cid) then addReset(cid) end end, 3000) local number = getResets(cid)+1 local msg ="---[Reset: "..number.."]-- Voce resetou e será desconectado em 3 segundos." doPlayerPopupFYI(cid, msg) talkState[talkUser] = 0 npcHandler:releaseFocus(cid) end talkState[talkUser] = 0 elseif(msgcontains(msg, 'no')) and isInArray({1}, talkState[talkUser]) == TRUE then talkState[talkUser] = 0 npcHandler:releaseFocus(cid) selfSay('Ok.', cid) elseif msgcontains(msg, 'quantidade') then selfSay('Voce tem um total de '..getResets(cid)..' reset(s).', cid) talkState[talkUser] = 0 end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Editado Abril 17, 2017 8 anos por Hunterii (veja o histórico de edições)
Postado Abril 17, 2017 8 anos @Hunterii o sistema já vem com uma função que retorna a quantidade de resets que o player tem, basta aplicar a função no look. Você tem algum script de look em seu server ? Posta em spolier aqui para que eu faça a alteração!
Postado Abril 17, 2017 8 anos Autor 6 horas atrás, KotZletY disse: @Hunterii o sistema já vem com uma função que retorna a quantidade de resets que o player tem, basta aplicar a função no look. Você tem algum script de look em seu server ? Posta em spolier aqui para que eu faça a alteração! Tenho sim @KotZletY, esse é o sistema de look do ot, nele tem o sistema de frags que quando você da o look no player, mostra o número de frags. function getPlayerFrags(cid) local time = os.time() local times = {today = (time - 86400), week = (time - (7 * 86400))} local contents, result = {day = {}, week = {}, month = {}}, db.getResult("SELECT `pd`.`date`, `pd`.`level`, `p`.`name` FROM `player_killers` pk LEFT JOIN `killers` k ON `pk`.`kill_id` = `k`.`id` LEFT JOIN `player_deaths` pd ON `k`.`death_id` = `pd`.`id` LEFT JOIN `players` p ON `pd`.`player_id` = `p`.`id` WHERE `pk`.`player_id` = " .. getPlayerGUID(cid) .. " AND `k`.`unjustified` = 1 AND `pd`.`date` >= " .. (time - (30 * 86400)) .. " ORDER BY `pd`.`date` DESC") if(result:getID() ~= -1) then repeat local content = {date = result:getDataInt("date")} if(content.date > times.today) then table.insert(contents.day, content) elseif(content.date > times.week) then table.insert(contents.week, content) else table.insert(contents.month, content) end until not result:next() result:free() end local size = { day = table.maxn(contents.day), week = table.maxn(contents.week), month = table.maxn(contents.month) } return size.day + size.week + size.month end function onLogin(cid) registerCreatureEvent(cid, "fraglook") return true end function onLook(cid, thing, position, lookDistance) if isPlayer(thing.uid) and thing.uid ~= cid then doPlayerSetSpecialDescription(thing.uid,' [Frags: '..getPlayerFrags(thing.uid)..']') return true elseif thing.uid == cid then doPlayerSetSpecialDescription(cid,'\n[Frags: '..getPlayerFrags(cid)..']') local string = 'You see yourself. \nHealth: ['.. getCreatureHealth(cid) ..' / '.. getCreatureMaxHealth(cid) ..']\n Mana: ['.. getCreatureMana(cid) ..' / '.. getCreatureMaxMana(cid) ..'].\n' if getPlayerFlagValue(cid, PLAYERFLAG_SHOWGROUPINSTEADOFVOCATION) then string = string..' You are '.. getPlayerGroupName(cid) ..'.' elseif getPlayerVocation(cid) ~= 0 then string = string..' You are '.. getPlayerVocationName(cid) ..'.' else string = string..' You have no vocation.' end string = string..getPlayerSpecialDescription(cid)..'' if getPlayerNameByGUID(getPlayerPartner(cid), false, false) ~= nil then string = string..' You are '.. (getPlayerSex(cid) == 0 and 'wife' or 'husband') ..' of '.. getPlayerNameByGUID(getPlayerPartner(cid)) ..'.' end if getPlayerGuildId(cid) > 0 then string = string..' You are ' .. (getPlayerGuildRank(cid) == '' and 'a member' or getPlayerGuildRank(cid)) ..' of the '.. getPlayerGuildName(cid) string = getPlayerGuildNick(cid) ~= '' and string..' ('.. getPlayerGuildNick(cid) ..').' or string..'.' end if getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEECREATUREDETAILS) then string = string..'\nHealth: ['.. getCreatureHealth(cid) ..' / '.. getCreatureMaxHealth(cid) ..']\n Mana: ['.. getCreatureMana(cid) ..' / '.. getCreatureMaxMana(cid) ..'].' string = string..'\nIP: '.. doConvertIntegerToIp(getPlayerIp(cid)) ..'.' end if getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEEPOSITION) then string = string..'\nPosition: [X:'.. position.x..'] [Y:'.. position.y..'] [Z:'.. position.z..'].' end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, string) return false end return true end
Postado Abril 17, 2017 8 anos Olá bom dia! Eu sou completamente novo nesse mundo dos OTserv, sou Webmaster e tenho experiência com MySQL e PHP, CSS e um pouco de tudo de Web, nesse caso creio que não terei grandes dificuldades em geral, porém tenho algumas dúvidas. Coloquei ontem um OTServ 8.60 rodar no meu localhost, estou fazendo o mapa no RME e vi essa postagem referente a script de Reset com Look funcional e me interessei em implementar isto no OTServ Baiak a qual fiz o Download. Vou citar algumas dúvidas minhas e se possível responder ficaria muito grato! Onde colocar novos scripts? não tenho conhecimento se OTServ's seguem padrões de pastas, o meu é o BestBaiak, eu creio que seja a pasta "BestBaiak\mods\scripts", é esta pasta mesmo? O Script acima (----[[Script made 100% by Nogard and Night Wolf...) teria que ser adicionado dentro de um arquivo .lua com algum nome específico ou qualquer nome de arquivo executará o script normalmente? Onde encontro o arquivo de script de Look do meu OTServer? creio que já existe um também pois no OT também mostra os Frags dos Players quando dá look. Obrigado pela atenção!
Postado Abril 17, 2017 8 anos Autor Bom dia @bandzenho, sobre as suas dúvidas, vou tentar responde-lo de forma mais exata possível. 1 - seuot/data é onde estão todos os scripts do seu OT, existem vários tipos e cada um você vai colocar na pasta correspondente. O nome do script vai variar de como o seu .lua vai chamar ele. 2 - Sim, ele tem que ser adicionando em um script .lua e funciona em conjunto com um script de NPC que executa a ação de dar o reset no player. 3 - Provavelmente vai estar na pasta seuot/data/creaturescipts/scripts ai é só procurar. Editado Abril 17, 2017 8 anos por Hunterii (veja o histórico de edições)
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.