drakylucas 159 Postado Março 29, 2013 Share Postado Março 29, 2013 (editado) Permito a publicação em outros fórums, contanto que coloquem meus créditos em um tamanho de fonte grande (algo como 30 basta) Créditos: Draky Lucas -- Desenvolvimento completo do sistema Xampy -- Parte de retirar Frag (copiado do Guild War System 0.3.6 e modificado por mim) LuckOake / Slicer -- Ajudas ao tirar dúvidas na seção de pedidos/duvidas de scripting Testado Com: The Forgotten Server 0.4 rev 3884 - 8.60 Usando MYSQL.. SQLite incompativel com o /install, mas você pode ler a linha e criar a query no sqlite studios manualmente. O que é? é um sistema de reinos, funciona mais ou menos como guild, com poucas diferenças. as pessoas necessitam apenas digitar !reinos e terão todas instruções de como funciona o sistema. Bugs: Está sem promover pessoas (ou seja, patentes intermediarias estão inutilizaveis por enquanto) outros? REPORTE aqui no tópico! Comandos: !reinos !reinos creditos - NAO ALTERAR !reinos criar,Nome do Reino !reinos invitar,Nome do Player !reinos recusar !reinos aceitar !reinos membros !reinos sair !reinos expulsar,Nome do Player Instalação Na pasta Mods do servidor, adicione um arquivo chamado reinos.xml contendo isso: <!--?xml version="1.0" encoding="iso-8859-1"?--> <mod name="Reinos" version="1.0" author="Draky Lucas" contact="xtibia.com" enabled="yes"> <config name="configuracao"><!--[CDATA[ ------------------- CONFIGURE AQUI --------------------- storages = { invitation = 24545, } patentes = { [1] = {nivel = "Membro"}, [2] = {nivel = "Vice lider"}, -- V1 -- AINDA INUTILIZAVEL [3] = {nivel = "Lider"}, } patenteMinima = 2 -- patente minima para poder convidar/expulsar membros ao reino reinoSeAtaca = false -- Membros do mesmo reino podem se atacar? reinoMataOutrosReinos = true ---- True = reinos podem matar pessoas de outros reinos sem ganhar frag // False = Pode até mata, mas ganha frag normal pz = true -- tem que estar sem battle pra sair/aceitar convites? true = sim, false = nao anunciarSistema = true -- anunciar o sistema? (a cada meia hora, porem é só aumentar/diminuir o interval no final do script.. PS: interval baseado no TFS 0.4 Rev 3884 (1000 = 1 segundo) ------------------- A PARTIR DAQUI, NAO MEXA EM MAIS NADA -------------------- ----- function setReino(guid,id,nivel) -- nivel 1 = member, 2 = vice leader, 3 = dono return db.executeQuery("UPDATE `players` SET reino = " .. id .. ", nivelreino = ".. nivel .." where id = ".. guid ..";") end ----- ----- function getReino(guid) -- retorna tabela com reino e nivel do reino da pessoa local qr = db.getResult("SELECT `reino`,`nivelreino` FROM `players` WHERE `id`= ".. guid ..";") reinoid = qr:getDataInt("reino") nivelreino = qr:getDataInt("nivelreino") return {reino = reinoid, nivel = nivelreino} end ----- ----- function getNameReino(id) if id == 0 then return "Sem Reino" end local qr = db.getResult("SELECT `name` FROM `reinos` WHERE `id`= ".. id ..";") name = qr:getDataString("name") return name end ----- ----- function getMembersReino(id) local result = db.getResult('SELECT `name`, `nivelreino` FROM `players` WHERE `reino`='..id..' ORDER BY `nivelreino` DESC;') local table = {} local i = 1 while TRUE do table[i] = {result:getDataString("name"), patentes[result:getDataInt("nivelreino")].nivel} if not(result:next()) then break end i = i + 1 end return table end ----- function getIdReino(name) local qr = db.getResult("SELECT `id` FROM `reinos` WHERE `name`= '".. name .."';") if qr:getID() == -1 then return -1 end return qr:getDataInt("id") end ----- function installReinos() if db.executeQuery("ALTER TABLE `players` ADD reino INT(4) NOT NULL DEFAULT 0;") and db.executeQuery("ALTER TABLE `players` ADD nivelreino INT(4) NOT NULL DEFAULT 0;") and db.executeQuery("CREATE TABLE `reinos` (`id` INT NOT NULL AUTO_INCREMENT, `name` VARCHAR(255) NOT NULL, `ownerid` INT NOT NULL, PRIMARY KEY (`id`), UNIQUE (`name`) ) ENGINE = InnoDB;") then print("O Banco de dados foi criado com sucesso! [by Draky Lucas]") print("O Sistema ja pode ser utilizado!") return TRUE end print("[Reinos - Draky Lucas] Não foi possível instalar o Sistema. Algum erro ocorreu no banco de dados") return FALSE end ----- ----- function getInvitation(cid) local invites = getPlayerStorageValue(cid,storages.invitation) if invites == -1 or invites == nil then return -1 end return {reino = string.match(invites, "{reino = (.-),"),nivel = string.match(invites, "nivel = (.-)}")} --tabela com reino e nivel end ----- ----- function invitar(cid,name,reinoid,reinonivel) if getReino(getPlayerGUID(cid)).reino <= 0 then return "Você não pertence a reino algum!" end if getReino(getPlayerGUID(cid)).nivel < patenteMinima then return "Você precisa ser ao menos ".. patentes[patenteMinima].." para poder convidar pessoas!" end if not isPlayer(getPlayerByNameWildcard(name)) then return "ERROR:\nDigite o nome do jogador corretamente!\nEle tem que estar online\n\nDigite !reinos invitar, nick do player!\nexemplo:\n!reinos invitar,Draky Lucas" end if getReino(getPlayerGUID(getPlayerByNameWildcard(name))).reino ~= 0 then return "O jogador "..name.." ja esta em outro reino! \nDesculpe" end if type(getInvitation(getPlayerByNameWildcard(name))) == "number" then setPlayerStorageValue(getPlayerByNameWildcard(name), storages.invitation, "{reino = " ..reinoid..", nivel = "..reinonivel.."}") doShowTextDialog(getPlayerByNameWildcard(name),1976,"O Reino " ..getNameReino(reinoid).." quer que voce se torne " .. patentes[reinonivel].nivel .. "\n\nDigite \"!reinos aceitar\" para entrar no reino, \"!reinos recusar\" para recusar o convite!") doPlayerSendTextMessage(getPlayerByNameWildcard(name),19,"O Reino " ..getNameReino(reinoid).." quer que voce se torne " .. patentes[reinonivel].nivel) doPlayerSendTextMessage(getPlayerByNameWildcard(name),19,"Digite \"!reinos aceitar\" para entrar no reino, \"!reinos recusar\" para recusar o convite!") return "Voce acabou de invitar o jogador "..name.." para o seu reino!" else return "O jogador "..name.." ja foi convidado para outro reino! Desculpe" end return true end ----- ----- function expulsar(cid,name) if getReino(getPlayerGUID(cid)).reino <= 0 then return "Você não pertence a reino algum!" end if not isPlayer(getPlayerByNameWildcard(name)) then return "ERROR:\nDigite o nome do jogador corretamente!\nEle tem que estar online\n\nDigite !reinos expulsar, nick do player!\nexemplo:\n!reinos expulsar,Draky Lucas" end if getReino(getPlayerGUID(cid)).nivel <= getReino(getPlayerByNameWildcard(name)).nivel then return "Você precisa ser ao menos uma patente maior que a pessoa na qual voce deseja expulsar do reino!" end if getReino(getPlayerGUID(getPlayerByNameWildcard(name))).reino ~= 0 and getReino(getPlayerGUID(getPlayerByNameWildcard(name))).reino == getReino(getPlayerGUID(cid)).reino then doShowTextDialog(getPlayerByNameWildcard(name),1976,"O Jogador " .. getCreatureName(cid) .. " lhe expulsou do reino "..getNameReino(getReino(getPlayerGUID(cid)).reino).."!") doPlayerSendTextMessage(getPlayerByNameWildcard(name),19,"O Jogador " .. getCreatureName(cid) .. " lhe expulsou do reino "..getNameReino(getReino(getPlayerGUID(cid)).reino).."!") setReino(getPlayerGUIDByName(name),0,0) return "Voce acabou de expulsar o jogador "..name.." do seu reino!" else return "O jogador "..name.." não é do seu reino!" end return true end ----- ----- function recuseInvitation(cid) local invites = getInvitation(cid) if getReino(getPlayerGUID(cid)).reino ~= 0 then return "Você ja pertence a algum reino!\n\nCaso queira sair, digite:\n!reinos sair" end if type(invites) == "number" then return "Nenhum reino te invitou até agora!" end setPlayerStorageValue(cid, storages.invitation, -1) return "Voce recusou o convite do reino " .. getNameReino(invites.reino) .. "! Agora você pode ser convidado para outros reinos!" end ----- ----- function acceptInvitation(cid) local invites = getInvitation(cid) if type(invites) == "number" then return "Nenhum reino te invitou até agora!" end if pz == true and getCreatureCondition(cid, CONDITION_INFIGHT) == true then return "Voce nao pode aceitar convites em quanto estiver em battle!" end setReino(getPlayerGUID(cid),tonumber(invites.reino),tonumber(invites.nivel)) setPlayerStorageValue(cid, storages.invitation, -1) return "Voce entrou no reino " .. getNameReino(tonumber(invites.reino)) .. "!" end ----- ----- function sairReino(cid) if getReino(getPlayerGUID(cid)).reino <= 0 then return "Voce nao esta em nenhum reino!" end if pz == true and getCreatureCondition(cid, CONDITION_INFIGHT) == true then return "Voce nao pode aceitar convites em quanto estiver em battle!" end setReino(getPlayerGUID(cid),0,0) return "Voce acaba de deixar o reino!" end ----- ----- function criarReino(ownerName, nomeReino) if getReino(getPlayerGUIDByName(ownerName)).reino --> 0 then return "Voce ja esta em um reino. Deixe-o para criar o seu!" end if pz == true and getCreatureCondition(getPlayerByNameWildcard(ownerName), CONDITION_INFIGHT) == true then return "Voce nao pode aceitar convites em quanto estiver em battle!" end if getIdReino(nomeReino) > 0 then return "Um reino com esse nome ja existe!\n\nTente outro nome!" end db.executeQuery("INSERT INTO reinos(name,ownerid) VALUES ('"..nomeReino.."',".. getPlayerGUIDByName(ownerName)..");") setReino(getPlayerGUIDByName(ownerName),getIdReino(nomeReino),#patentes) -- #pattentes vai retornar quantas patentes tem, logo a ultima, se for 1 por 1, será a maior doPlayerSendTextMessage(getPlayerByNameWildcard(ownerName),22,"Voce criou o reino ".. nomeReino.. "!") doPlayerSendTextMessage(getPlayerByNameWildcard(ownerName),22,"Digite \"!reinos invitar,NOME\" para convidar o NOME para o seu reino!") return "Voce criou o reino ".. nomeReino.. "!\n\nDigite \"!reinos invitar,NOME\" para convidar o NOME para o seu reino!" end ----- ----- function excluirReino(ID) db.executeQuery("UPDATE `players` SET reino = 0, nivelreino = 0 where reino = ".. ID ..";") db.executeQuery("DELETE from `reinos` where id = ".. ID ..";") db.executeQuery("DELETE from `player_storage` where value like '{reino = ".. ID ..",%';") return true end ----- ]]></config> <event type="login" name="registerEvents" event="buffer"><!--[CDATA[ domodlib('configuracao') -- function onLogin(cid) if reinoSeAtaca == false then registerCreatureEvent(cid,"naoAtacarProprioReino") end if reinoMataOutrosReinos == true then registerCreatureEvent(cid,"reinoMataOutrosReinos") end registerCreatureEvent(cid,"lookReino") -- return true -- end ]]--></event> <talkaction words="!reinos" event="buffer"><!--[CDATA[ -- cid,word,param domodlib('configuracao') --------------------------------- if param == "instalar" and getPlayerGroupId(cid) --> 4 then doPlayerSendTextMessage(cid,19,"Veja no console se o sistema foi instalado!") return installReinos() end --------------------------------- local reinos = getReino(getPlayerGUID(cid)) local invites = getInvitation(cid) local string = "" --------------------------------- -- if param == "creditos" then doShowTextDialog(cid, 1976,"Draky Lucas - XTibia\n\nEnjoy it!") return true end --]] if param == "" or param == nil or param == false then if type(invites) == "number" and reinos.reino == 0 then string = "Voce nao pertence a nenhum reino e ainda nao foi convidado para pertencer a algum!\n\nDigite \"!reinos criar,NOME\" para criar um reino!" end if type(invites) == "table" then string = string .. "Voce foi invitado para ser " .. patentes[tonumber(invites.nivel)].nivel .. " do reino " .. getNameReino(tonumber(invites.reino)) .."!\n" string = string .. "Digite uma das opções:\n" string = string .. "!reinos aceitar\n" string = string .. "!reinos recusar\n" end if reinos.reino > 0 then string = string .. "Voce é ".. patentes[reinos.nivel].nivel .." do reino " .. getNameReino(reinos.reino) .."!\n" string = string .. "Digite uma das opções:\n" string = string .. "!reinos membros\n" string = string .. "!reinos sair\n" end if reinos.reino > 0 and reinos.nivel >= patenteMinima then string = string .. "!reinos invitar,NOME\n" string = string .. "!reinos expulsar,NOME\n" end if reinos.nivel == #patentes then string = string .. "\n----\nAtenção: Sendo a mais alta patente, ao sair do reino, ele será desfeito!\n----" end return doShowTextDialog(cid, 1976, string) end --------------------------------- --------------------------------------------- if param == "membros" then if reinos.reino == 0 then string = string .. "Você não pertence a reino algum!" else local table = getMembersReino(reinos.reino) string = string .. "Membros do reino " .. getNameReino(reinos.reino) ..":\n" for i = 1,#table do string = string .. table[i][1] .. " - " .. table[i][2] .. "\n" end end return doShowTextDialog(cid, 1976, string) end ---------------------------------------------- --------------------------------------------- if param == "sair" then if reinos.nivel == #patentes then -- se tiver patente maxima excluirReino(reinos.reino) doShowTextDialog(cid, 1976, "Seu reino foi desfeito!") return true end string = sairReino(cid) return doShowTextDialog(cid, 1976, string) end--------------------------------------------- --------------------------------------------- if param == "recusar" then string = recuseInvitation(cid) return doShowTextDialog(cid, 1976, string) end--------------------------------------------- if param == "aceitar" then string = acceptInvitation(cid) return doShowTextDialog(cid, 1976, string) end--------------------------------------------- local t = string.explode(param, ",") if t[1] == "invitar" then if not t[2] then return doShowTextDialog(cid, 1976, "Digite !reinos invitar, nick do player!\nexemplo:\n!reinos invitar,Draky Lucas") end string = invitar(cid,t[2],reinos.reino,1) return doShowTextDialog(cid, 1976,string) end if t[1] == "criar" then if not t[2] then return doShowTextDialog(cid, 1976, "Digite !reinos criar, Nome do Reino!\nexemplo:\n!reinos criar,Imperio Draky") end recuseInvitation(cid) string = criarReino(getCreatureName(cid), tostring(t[2])) return doShowTextDialog(cid, 1976,string) end if t[1] == "expulsar" then if not t[2] then return doShowTextDialog(cid, 1976, "Digite !reinos expulsar,NOME!\nexemplo:\n!reinos expulsar,Draky Lucas") end string = expulsar(cid,t[2]) return doShowTextDialog(cid, 1976,string) end ---------------------------------------------- ------------------------ CONTEM PARTES EM CREATURESCRIPTS -------------------- ]]></talkaction> <globalevent name="anunciarReinos" interval="1800000" event="script"><!--[CDATA[ domodlib('configuracao') if anunciarSistema == true then return doBroadcastMessage("O Servidor conta com um sistema de reinos! digite !reinos e saiba a respeito!") end return true ]]--></globalevent> </mod> Agora, na pasta data/creaturescripts/scripts crie uma pasta chamada reinos e nela crie três arquivos: look.lua naoAtacarProprioReino.lua reinoMataOutrosReinos.lua no look.lua coloque isso: ----- function getReino(guid) -- retorna tabela com reino e nivel do reino da pessoa local qr = db.getResult("SELECT `reino`,`nivelreino` FROM `players` WHERE `id`= ".. guid ..";") reinoid = qr:getDataInt("reino") nivelreino = qr:getDataInt("nivelreino") return {reino = reinoid, nivel = nivelreino} end ----- ----- function getNameReino(id) if id == 0 then return "Sem Reino" end local qr = db.getResult("SELECT `name` FROM `reinos` WHERE `id`= ".. id ..";") name = qr:getDataString("name") return name end ----- function onLook(cid, thing, position, lookDistance) if isPlayer(thing.uid) and thing.uid ~= cid then doPlayerSetSpecialDescription(thing.uid,' [Reino: '..getNameReino(getReino(getPlayerGUID(thing.uid)).reino)..']') return true elseif thing.uid == cid then doPlayerSetSpecialDescription(cid,' [Reino: '..getNameReino(getReino(getPlayerGUID(cid)).reino)..']') local string = 'You see yourself.' 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 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) ..'], 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 string = string..getPlayerSpecialDescription(cid)..'' doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, string) return false end return true end no naoAtacarProprioReino.lua coloque isso: function getReino(guid) -- retorna tabela com reino e nivel do reino da pessoa local qr = db.getResult("SELECT `reino`,`nivelreino` FROM `players` WHERE `id`= ".. guid ..";") reinoid = qr:getDataInt("reino") nivelreino = qr:getDataInt("nivelreino") return {reino = reinoid, nivel = nivelreino} end function onCombat(cid, target) if not isPlayer(target) then return true end if (getReino(getPlayerGUID(cid)).reino == getReino(getPlayerGUID(target)).reino) and getReino(getPlayerGUID(cid)).reino > 0 then doPlayerSendCancel(cid, "Voce nao pode atacar players da mesma guild.") return FALSE end return true end No reinoMataOutrosReinos.lua (creditos 90% Xampy)coloque isso: function getReino(guid) -- retorna tabela com reino e nivel do reino da pessoa local qr = db.getResult("SELECT `reino`,`nivelreino` FROM `players` WHERE `id`= ".. guid ..";") reinoid = qr:getDataInt("reino") nivelreino = qr:getDataInt("nivelreino") return {reino = reinoid, nivel = nivelreino} end function onKill(cid, target, lastHit) local PZ = createConditionObject(CONDITION_INFIGHT) setConditionParam(PZ, CONDITION_PARAM_TICKS, getConfigInfo('whiteSkullTime')) if isPlayer(cid) == TRUE and isPlayer(target) == TRUE then local GUID = getPlayerGUID(cid) local namec = getPlayerName(cid) local namet = getPlayerName(target) local skull = getCreatureSkullType(cid) local skullend = getPlayerSkullEnd(cid) local playerPos = getPlayerPosition(cid) local targetPos = getPlayerPosition(target) local cidd = cid local timeA = os.time() local timesA = {today = (timeA - 86400), week = (timeA - (7 * 86400))} local contentsA, resultA = {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` >= " .. (timeA - (30 * 86400)) .. " ORDER BY `pd`.`date` DESC") if(resultA:getID() ~= -1) then repeat local contentA = { name = resultA:getDataString("name"), level = resultA:getDataInt("level"), date = resultA:getDataInt("date") } if(contentA.date > timesA.today) then table.insert(contentsA.day, contentA) elseif(contentA.date > timesA.week) then table.insert(contentsA.week, contentA) else table.insert(contentsA.month, contentA) end until not resultA:next() resultA:free() end local sizeA = { day = table.maxn(contentsA.day), week = table.maxn(contentsA.week), month = table.maxn(contentsA.month) } local function removeFrag(cid) local timeB = os.time() local timesB = {today = (timeB - 86400), week = (timeB - (7 * 86400))} local contentsB, resultB = {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` = " .. GUID .. " AND `k`.`unjustified` = 1 AND `pd`.`date` >= " .. (timeB - (30 * 86400)) .. " ORDER BY `pd`.`date` DESC") if(resultB:getID() ~= -1) then repeat local contentB = { name = resultB:getDataString("name"), level = resultB:getDataInt("level"), date = resultB:getDataInt("date") } if(contentB.date > timesB.today) then table.insert(contentsB.day, contentB) elseif(contentB.date > timesB.week) then table.insert(contentsB.week, contentB) else table.insert(contentsB.month, contentB) end until not resultB:next() resultB:free() end local sizeB = { day = table.maxn(contentsB.day), week = table.maxn(contentsB.week), month = table.maxn(contentsB.month) } if sizeB.day > sizeA.day or sizeB.week > sizeA.week or sizeB.month > sizeA.month then db.executeQuery("UPDATE `killers` SET `unjustified` = 0 WHERE `id` IN (SELECT `kill_id` FROM `player_killers` WHERE `player_id` = "..GUID..") ORDER BY `death_id` DESC LIMIT 1;") doPlayerSendTextMessage(cidd, 21, "O Frag do player "..namet.." não foi contado!") end if skull == SKULL_RED then if getCreatureSkullType(cidd) == SKULL_BLACK then doPlayerSetSkullEnd(cidd, skullend, SKULL_RED) doCreatureSetSkullType(cidd, SKULL_RED) end elseif skull == SKULL_WHITE then if getCreatureSkullType(cidd) == SKULL_RED then doPlayerSetSkullEnd(cidd, timeB, SKULL_RED) doCreatureSetSkullType(cidd, SKULL_WHITE) end end end -- removefrag local myReino = getReino(getPlayerGUID(cid)).reino local enemyReino = getReino(getPlayerGUID(target)).reino if myReino ~= 0 and enemyReino ~= 0 then doAddCondition(cid, PZ) addEvent(removeFrag, 150) -- pra comparar o posterior com o anterior end end -- if isPlayer... return TRUE end Agora em data/creaturescripts abra o creaturescripts.xml e adicione: <event type="look" name="lookReino" event="script" value="reinos/look.lua"> <event type="kill" name="reinoMataOutrosReinos" event="script" value="reinos/ReinoMataOutrosReinos.lua"> <event type="combat" name="naoAtacarProprioReino" event="script" value="reinos/naoAtacarProprioReino.lua"> Agora, abra o servidor (reload não funcionará), entre com um char de groupId acima de 5 e digite !reinos instalar APENAS UMA VEZ! PS: Os creaturescripts estão fora do MOD pois estive tendo problemas com return false no MOD. Confirme no console se o sistema instalou-se corretamente! Enjoy it! SCREENSHOTS: http://img716.images...7/imagem1ta.jpg http://img96.imagesh...1/imagem2te.jpg http://img593.images...6/imagem3dx.jpg http://img833.images...6/imagem4md.jpg http://img705.images...7/imagem5fu.jpg http://img823.images...9/imagem6dc.jpg http://img705.images...76/imagem7z.jpg http://img703.images...23/imagem8p.jpg http://img199.images...434/imagem9.JPG http://img195.images...9/imagem10r.jpg http://img96.imagesh.../imagem11fu.jpg http://img28.imagesh.../imagem12fk.jpg http://img844.images...0/imagem13w.jpg Gostou? REP+ e comente! EDIT 30/03/2013 - Adicionado Spoilers no tópico</event></event></event> EDIT 09/04/2013 - Adicionado Imagens Editado Abril 11, 2013 por DrakyLucas Link para o comentário Compartilhar em outros sites More sharing options...
PsyMcKenzie 150 Postado Março 29, 2013 Share Postado Março 29, 2013 (editado) Ramelagem postar o sistema em mano Pelo menos agora eu aprendi, se quer algo, faça você mesmo! @Topic Parece funcional, vou testar aqui! @Edit Cadê meus créditos pela brilhante ideia? u.u Mano, qual id coloca nos tiles pra apenas os membros do reino passar ali? Editado Março 29, 2013 por PsyMcKenzie Link para o comentário Compartilhar em outros sites More sharing options...
drakylucas 159 Postado Março 29, 2013 Autor Share Postado Março 29, 2013 (editado) @Edit Cadê meus créditos pela brilhante ideia? u.u Mano, qual id coloca nos tiles pra apenas os membros do reino passar ali? na verdade sua ideia foi só um impulso pra mim criar, eu ja vi o sistema no jogo Wyd ^^ na V 1.0 ainda nãp tem limitação para apenas membros de tal reino passar pelo piso.. mas vou fazer um rapidinho aqui, teste ai que nao vou testar: (do jeito que vc quer é pra um reino especifico passar por um tile especifico neh? ) data/movements/scripts crie reino1.lua e coloque isso: function getReino(guid) -- retorna tabela com reino e nivel do reino da pessoa local qr = db.getResult("SELECT `reino`,`nivelreino` FROM `players` WHERE `id`= ".. guid ..";") reinoid = qr:getDataInt("reino") nivelreino = qr:getDataInt("nivelreino") return {reino = reinoid, nivel = nivelreino} end function getNameReino(id) if id == 0 then return "Sem Reino" end local qr = db.getResult("SELECT `name` FROM `reinos` WHERE `id`= ".. id ..";") name = qr:getDataString("name") return name end function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor) local reinoEspecifico = 1 if not isPlayer(cid) then return true end if getReino(getPlayerGUID(cid)).reino ~= reinoEspecifico then doTeleportThing(cid,fromPosition,false) doPlayerSendCancel(cid,"Voce precisa estar no reino "..getNameReino(reinoeEspecifico).. " para passar aqui!") return false end return true end agora no movements.xml coloque isso <movevent type="StepIn" actionid="2454" event="script" value="reino1.lua"/> Cria um script pra cada reino @topic: Esse script é especifico pro pedido dele, que tem reinos especificos, na v2.0 eu faço algo do genero mais elaborado! No lugar que só o reino 1 (no caso) for passar, coloque a AID 2454.... faça varios scripts mudando a AID para diferentes reinos.. (fiz meio rapido, como pode ver kk foi meio gambiarra pois o script original nao tem que ter isso, mas daqui uns dias eu faço um evento tipo meu castle war de guild, só q pra reino, dae até coloco isso kk) Editado Março 29, 2013 por DrakyLucas Link para o comentário Compartilhar em outros sites More sharing options...
PsyMcKenzie 150 Postado Abril 9, 2013 Share Postado Abril 9, 2013 Sistema ta dando muito erros, se eu for tirar print vou ficar um ano aqui Link para o comentário Compartilhar em outros sites More sharing options...
drakylucas 159 Postado Abril 9, 2013 Autor Share Postado Abril 9, 2013 Aqui nao deu nenhum erro oO.. uso o tfs 0.4 rev 3884 sem modificações.. testei tudo com varios MC's abertos, nao deu nenhum errinho oO Link para o comentário Compartilhar em outros sites More sharing options...
ThiagoBji 146 Postado Abril 9, 2013 Share Postado Abril 9, 2013 Se está funcionando, esse sistema é espetacular! Ótima ideia, parabéns mesmo! (Que show, aehuaeh) Link para o comentário Compartilhar em outros sites More sharing options...
PsyMcKenzie 150 Postado Abril 9, 2013 Share Postado Abril 9, 2013 Aqui nem funcionou da um monte de erro sobre isso -- [[ ]] E quando falo !reinos instalar nao acontece nada. Link para o comentário Compartilhar em outros sites More sharing options...
drakylucas 159 Postado Abril 9, 2013 Autor Share Postado Abril 9, 2013 use com MYSQL.. talvez esteja dando erro pois você deve estar utiizando com sqlite.. os erros provavelmente são de banco de dados, certo? eu nao faço nada em sqlite.. nenhum servidor famoso vai usar sqlite ¬¬.. na teoria o db.executeQuery deveria funcionar com sqlite mas na pratica eu nao sei... digite !reinos instalar e tire a ss do erro. Link para o comentário Compartilhar em outros sites More sharing options...
PsyMcKenzie 150 Postado Abril 9, 2013 Share Postado Abril 9, 2013 Antes, quando tu postou, eu testei e funfou mais ou menos, mas agora fui testar de novo e nem funfa Ainda tinha uns negócios pra colocar em talkactions.xml, mas parece que tu retirou do topico '-' Erros ao ligar o server: Quando eu digo !reinos instalar não da erro. Link para o comentário Compartilhar em outros sites More sharing options...
drakylucas 159 Postado Abril 9, 2013 Autor Share Postado Abril 9, 2013 Aqui ja nao da nenhum erro oO sua distro não está lendo comentarios feitos nos mods... PS: nunca teve nada em talkactions.xml... só creaturescripts que foram feitos fora do mods. No seu caso especifico, tente tirar todos os comentarios do script (tudo que estiver -- você deleta.. vc entende um pouco de scripting).... olha algumas screenshots (vou atualizar o topico com elas.. pra provar q funciona) http://img716.imageshack.us/img716/7127/imagem1ta.jpg http://img96.imageshack.us/img96/6951/imagem2te.jpg http://img593.imageshack.us/img593/5536/imagem3dx.jpg http://img833.imageshack.us/img833/376/imagem4md.jpg http://img705.imageshack.us/img705/1297/imagem5fu.jpg http://img823.imageshack.us/img823/5379/imagem6dc.jpg http://img705.imageshack.us/img705/6476/imagem7z.jpg http://img703.imageshack.us/img703/223/imagem8p.jpg http://img199.imageshack.us/img199/4434/imagem9.JPG http://img195.imageshack.us/img195/4889/imagem10r.jpg http://img96.imageshack.us/img96/6255/imagem11fu.jpg http://img28.imageshack.us/img28/2418/imagem12fk.jpg http://img844.imageshack.us/img844/7480/imagem13w.jpg PS: sem erros no console. Link para o comentário Compartilhar em outros sites More sharing options...
fabianobn 0 Postado Abril 9, 2013 Share Postado Abril 9, 2013 Muito show o sistema! teria como por para apenas premium user poder criar o reino? e quando ele deixar de ser premium o reino fica inativo tipo guild? Link para o comentário Compartilhar em outros sites More sharing options...
drakylucas 159 Postado Abril 10, 2013 Autor Share Postado Abril 10, 2013 ter tem, mas nao vou fazer isso agora... quando eu tiver paciencia eu monto uma v2 e arrumo os erros (tipo patentes funcionarem..) etc Link para o comentário Compartilhar em outros sites More sharing options...
PsyMcKenzie 150 Postado Abril 10, 2013 Share Postado Abril 10, 2013 Mano, não to conseguindo de jeito nenhum, da pra remover pra mim? Ainda sou noob em algumas coisas e não sei nada de mods ;s Link para o comentário Compartilhar em outros sites More sharing options...
drakylucas 159 Postado Abril 10, 2013 Autor Share Postado Abril 10, 2013 mods são scripts comuns... é só remover tudo onde tem -- ¬¬ vou remover aqui e posto.. CASO ALGUEM MAIS TENHA ERRO, COLOQUE ESSE SCRIPT: (testa ai psy) <?xml version="1.0" encoding="iso-8859-1"?> <mod name="Reinos" version="1.0" author="Draky Lucas" contact="xtibia.com" enabled="yes"> <config name="configuracao"><![CDATA[ storages = { invitation = 24545, } patentes = { [1] = {nivel = "Membro"}, [2] = {nivel = "Vice lider"}, [3] = {nivel = "Lider"}, } patenteMinima = 2 reinoSeAtaca = false reinoMataOutrosReinos = true pz = true anunciarSistema = true function setReino(guid,id,nivel) return db.executeQuery("UPDATE `players` SET reino = " .. id .. ", nivelreino = ".. nivel .." where id = ".. guid ..";") end function getReino(guid) local qr = db.getResult("SELECT `reino`,`nivelreino` FROM `players` WHERE `id`= ".. guid ..";") reinoid = qr:getDataInt("reino") nivelreino = qr:getDataInt("nivelreino") return {reino = reinoid, nivel = nivelreino} end function getNameReino(id) if id == 0 then return "Sem Reino" end local qr = db.getResult("SELECT `name` FROM `reinos` WHERE `id`= ".. id ..";") name = qr:getDataString("name") return name end function getMembersReino(id) local result = db.getResult('SELECT `name`, `nivelreino` FROM `players` WHERE `reino`='..id..' ORDER BY `nivelreino` DESC;') local table = {} local i = 1 while TRUE do table[i] = {result:getDataString("name"), patentes[result:getDataInt("nivelreino")].nivel} if not(result:next()) then break end i = i + 1 end return table end function getIdReino(name) local qr = db.getResult("SELECT `id` FROM `reinos` WHERE `name`= '".. name .."';") if qr:getID() == -1 then return -1 end return qr:getDataInt("id") end function installReinos() if db.executeQuery("ALTER TABLE `players` ADD reino INT(4) NOT NULL DEFAULT 0;") and db.executeQuery("ALTER TABLE `players` ADD nivelreino INT(4) NOT NULL DEFAULT 0;") and db.executeQuery("CREATE TABLE `reinos` (`id` INT NOT NULL AUTO_INCREMENT, `name` VARCHAR(255) NOT NULL, `ownerid` INT NOT NULL, PRIMARY KEY (`id`), UNIQUE (`name`) ) ENGINE = InnoDB;") then print("O Banco de dados foi criado com sucesso! [by Draky Lucas]") print("O Sistema ja pode ser utilizado!") return TRUE end print("[Reinos - Draky Lucas] Não foi possível instalar o Sistema. Algum erro ocorreu no banco de dados") return FALSE end function getInvitation(cid) local invites = getPlayerStorageValue(cid,storages.invitation) if invites == -1 or invites == nil then return -1 end return {reino = string.match(invites, "{reino = (.-),"),nivel = string.match(invites, "nivel = (.-)}")} end function invitar(cid,name,reinoid,reinonivel) if getReino(getPlayerGUID(cid)).reino <= 0 then return "Você não pertence a reino algum!" end if getReino(getPlayerGUID(cid)).nivel < patenteMinima then return "Você precisa ser ao menos ".. patentes[patenteMinima].." para poder convidar pessoas!" end if not isPlayer(getPlayerByNameWildcard(name)) then return "ERROR:\nDigite o nome do jogador corretamente!\nEle tem que estar online\n\nDigite !reinos invitar, nick do player!\nexemplo:\n!reinos invitar,Draky Lucas" end if getReino(getPlayerGUID(getPlayerByNameWildcard(name))).reino ~= 0 then return "O jogador "..name.." ja esta em outro reino! \nDesculpe" end if type(getInvitation(getPlayerByNameWildcard(name))) == "number" then setPlayerStorageValue(getPlayerByNameWildcard(name), storages.invitation, "{reino = " ..reinoid..", nivel = "..reinonivel.."}") doShowTextDialog(getPlayerByNameWildcard(name),1976,"O Reino " ..getNameReino(reinoid).." quer que voce se torne " .. patentes[reinonivel].nivel .. "\n\nDigite \"!reinos aceitar\" para entrar no reino, \"!reinos recusar\" para recusar o convite!") doPlayerSendTextMessage(getPlayerByNameWildcard(name),19,"O Reino " ..getNameReino(reinoid).." quer que voce se torne " .. patentes[reinonivel].nivel) doPlayerSendTextMessage(getPlayerByNameWildcard(name),19,"Digite \"!reinos aceitar\" para entrar no reino, \"!reinos recusar\" para recusar o convite!") return "Voce acabou de invitar o jogador "..name.." para o seu reino!" else return "O jogador "..name.." ja foi convidado para outro reino! Desculpe" end return true end function expulsar(cid,name) if getReino(getPlayerGUID(cid)).reino <= 0 then return "Você não pertence a reino algum!" end if not isPlayer(getPlayerByNameWildcard(name)) then return "ERROR:\nDigite o nome do jogador corretamente!\nEle tem que estar online\n\nDigite !reinos expulsar, nick do player!\nexemplo:\n!reinos expulsar,Draky Lucas" end if getReino(getPlayerGUID(cid)).nivel <= getReino(getPlayerByNameWildcard(name)).nivel then return "Você precisa ser ao menos uma patente maior que a pessoa na qual voce deseja expulsar do reino!" end if getReino(getPlayerGUID(getPlayerByNameWildcard(name))).reino ~= 0 and getReino(getPlayerGUID(getPlayerByNameWildcard(name))).reino == getReino(getPlayerGUID(cid)).reino then doShowTextDialog(getPlayerByNameWildcard(name),1976,"O Jogador " .. getCreatureName(cid) .. " lhe expulsou do reino "..getNameReino(getReino(getPlayerGUID(cid)).reino).."!") doPlayerSendTextMessage(getPlayerByNameWildcard(name),19,"O Jogador " .. getCreatureName(cid) .. " lhe expulsou do reino "..getNameReino(getReino(getPlayerGUID(cid)).reino).."!") setReino(getPlayerGUIDByName(name),0,0) return "Voce acabou de expulsar o jogador "..name.." do seu reino!" else return "O jogador "..name.." não é do seu reino!" end return true end function recuseInvitation(cid) local invites = getInvitation(cid) if getReino(getPlayerGUID(cid)).reino ~= 0 then return "Você ja pertence a algum reino!\n\nCaso queira sair, digite:\n!reinos sair" end if type(invites) == "number" then return "Nenhum reino te invitou até agora!" end setPlayerStorageValue(cid, storages.invitation, -1) return "Voce recusou o convite do reino " .. getNameReino(invites.reino) .. "! Agora você pode ser convidado para outros reinos!" end function acceptInvitation(cid) local invites = getInvitation(cid) if type(invites) == "number" then return "Nenhum reino te invitou até agora!" end if pz == true and getCreatureCondition(cid, CONDITION_INFIGHT) == true then return "Voce nao pode aceitar convites em quanto estiver em battle!" end setReino(getPlayerGUID(cid),tonumber(invites.reino),tonumber(invites.nivel)) setPlayerStorageValue(cid, storages.invitation, -1) return "Voce entrou no reino " .. getNameReino(tonumber(invites.reino)) .. "!" end function sairReino(cid) if getReino(getPlayerGUID(cid)).reino <= 0 then return "Voce nao esta em nenhum reino!" end if pz == true and getCreatureCondition(cid, CONDITION_INFIGHT) == true then return "Voce nao pode aceitar convites em quanto estiver em battle!" end setReino(getPlayerGUID(cid),0,0) return "Voce acaba de deixar o reino!" end function criarReino(ownerName, nomeReino) if getReino(getPlayerGUIDByName(ownerName)).reino > 0 then return "Voce ja esta em um reino. Deixe-o para criar o seu!" end if pz == true and getCreatureCondition(getPlayerByNameWildcard(ownerName), CONDITION_INFIGHT) == true then return "Voce nao pode aceitar convites em quanto estiver em battle!" end if getIdReino(nomeReino) > 0 then return "Um reino com esse nome ja existe!\n\nTente outro nome!" end db.executeQuery("INSERT INTO reinos(name,ownerid) VALUES ('"..nomeReino.."',".. getPlayerGUIDByName(ownerName)..");") setReino(getPlayerGUIDByName(ownerName),getIdReino(nomeReino),#patentes) doPlayerSendTextMessage(getPlayerByNameWildcard(ownerName),22,"Voce criou o reino ".. nomeReino.. "!") doPlayerSendTextMessage(getPlayerByNameWildcard(ownerName),22,"Digite \"!reinos invitar,NOME\" para convidar o NOME para o seu reino!") return "Voce criou o reino ".. nomeReino.. "!\n\nDigite \"!reinos invitar,NOME\" para convidar o NOME para o seu reino!" end function excluirReino(ID) db.executeQuery("UPDATE `players` SET reino = 0, nivelreino = 0 where reino = ".. ID ..";") db.executeQuery("DELETE from `reinos` where id = ".. ID ..";") db.executeQuery("DELETE from `player_storage` where value like '{reino = ".. ID ..",%';") return true end ]]></config> <event type="login" name="registerEvents" event="buffer"><![CDATA[ domodlib('configuracao') if reinoSeAtaca == false then registerCreatureEvent(cid,"naoAtacarProprioReino") end if reinoMataOutrosReinos == true then registerCreatureEvent(cid,"reinoMataOutrosReinos") end registerCreatureEvent(cid,"lookReino") ]]></event> <talkaction words="!reinos" event="buffer"><![CDATA[ domodlib('configuracao') if param == "instalar" and getPlayerGroupId(cid) > 4 then doPlayerSendTextMessage(cid,19,"Veja no console se o sistema foi instalado!") return installReinos() end local reinos = getReino(getPlayerGUID(cid)) local invites = getInvitation(cid) local string = "" if param == "creditos" then doShowTextDialog(cid, 1976,"Draky Lucas - XTibia\n\nEnjoy it!") return true end if param == "" or param == nil or param == false then if type(invites) == "number" and reinos.reino == 0 then string = "Voce nao pertence a nenhum reino e ainda nao foi convidado para pertencer a algum!\n\nDigite \"!reinos criar,NOME\" para criar um reino!" end if type(invites) == "table" then string = string .. "Voce foi invitado para ser " .. patentes[tonumber(invites.nivel)].nivel .. " do reino " .. getNameReino(tonumber(invites.reino)) .."!\n" string = string .. "Digite uma das opções:\n" string = string .. "!reinos aceitar\n" string = string .. "!reinos recusar\n" end if reinos.reino > 0 then string = string .. "Voce é ".. patentes[reinos.nivel].nivel .." do reino " .. getNameReino(reinos.reino) .."!\n" string = string .. "Digite uma das opções:\n" string = string .. "!reinos membros\n" string = string .. "!reinos sair\n" end if reinos.reino > 0 and reinos.nivel >= patenteMinima then string = string .. "!reinos invitar,NOME\n" string = string .. "!reinos expulsar,NOME\n" end if reinos.nivel == #patentes then string = string .. "\n----\nAtenção: Sendo a mais alta patente, ao sair do reino, ele será desfeito!\n----" end return doShowTextDialog(cid, 1976, string) end if param == "membros" then if reinos.reino == 0 then string = string .. "Você não pertence a reino algum!" else local table = getMembersReino(reinos.reino) string = string .. "Membros do reino " .. getNameReino(reinos.reino) ..":\n" for i = 1,#table do string = string .. table[i][1] .. " - " .. table[i][2] .. "\n" end end return doShowTextDialog(cid, 1976, string) end if param == "sair" then if reinos.nivel == #patentes then excluirReino(reinos.reino) doShowTextDialog(cid, 1976, "Seu reino foi desfeito!") return true end string = sairReino(cid) return doShowTextDialog(cid, 1976, string) end if param == "recusar" then string = recuseInvitation(cid) return doShowTextDialog(cid, 1976, string) end if param == "aceitar" then string = acceptInvitation(cid) return doShowTextDialog(cid, 1976, string) end local t = string.explode(param, ",") if t[1] == "invitar" then if not t[2] then return doShowTextDialog(cid, 1976, "Digite !reinos invitar, nick do player!\nexemplo:\n!reinos invitar,Draky Lucas") end string = invitar(cid,t[2],reinos.reino,1) return doShowTextDialog(cid, 1976,string) end if t[1] == "criar" then if not t[2] then return doShowTextDialog(cid, 1976, "Digite !reinos criar, Nome do Reino!\nexemplo:\n!reinos criar,Imperio Draky") end recuseInvitation(cid) string = criarReino(getCreatureName(cid), tostring(t[2])) return doShowTextDialog(cid, 1976,string) end if t[1] == "expulsar" then if not t[2] then return doShowTextDialog(cid, 1976, "Digite !reinos expulsar,NOME!\nexemplo:\n!reinos expulsar,Draky Lucas") end string = expulsar(cid,t[2]) return doShowTextDialog(cid, 1976,string) end ]]></talkaction> <globalevent name="anunciarReinos" interval="1800000" event="script"><![CDATA[ domodlib('configuracao') if anunciarSistema == true then return doBroadcastMessage("O Servidor conta com um sistema de reinos! digite !reinos e saiba a respeito!") end return true ]]></globalevent> </mod> Link para o comentário Compartilhar em outros sites More sharing options...
PsyMcKenzie 150 Postado Abril 10, 2013 Share Postado Abril 10, 2013 --' Link para o comentário Compartilhar em outros sites More sharing options...
Posts Recomendados