igordutra47 0 #1 Postado 27 Agosto, 2017 Estou com um problema em um script não entendo muito sobre. Error: http://prntscr.com/gdmvbe Peguei esse script: Script: data/globalevents/scripts/war/onstartup.lua function onStartup() resetaStorageWarEvent() return true end data/lib/102-war.lua WAR_GLOBAL_STORAGE_STATUS = 88800 WAR_GLOBAL_STORAGE_LIMITE_PARTICIPANTES = 88801 WAR_STORAGE_STATUS_PLAYER = 88800 WAR_STORAGE_TIME_VERMELHO = 88801 WAR_STORAGE_TIME_AZUL = 88802 WAR_TOTAL_PARTICIPANTES = 2 WAR_TEMPO_FORCAR_EVENTO = 1*60*1000 WAR_LEVEL_MINIMO_PARTICIPANTES = 100 WAR_ID_TELEPORTE = 1387 WAR_LOCAL_TELEPORTE = {x=167, y=53, z=8} WAR_LOCAL_SALA_ESPERA = {x=835, y=1328, z=7} WAR_LOCAL_SAIDA = {x=160, y=51, z=7} WAR_LOCAL_TIME_VERMELHO = { {x=806, y=1298, z=7}, {x=803, y=1297, z=7} } WAR_LOCAL_TIME_AZUL = { {x=863, y=1266, z=7}, {x=855, y=1264, z=7} } WAR_LOCAL_ARENA_BATALHA = { {x = 461, y = 426, z = 7}, {x = 544, y = 488, z = 7} } local WAR_PREMIOS = { trofeu = 10127, itens = {2520,2487,2498,2488}, dinheiro = {2160, 10, true} } local outfitJogadorTimeAzul = createConditionObject(CONDITION_OUTFIT) setConditionParam(outfitJogadorTimeAzul, CONDITION_PARAM_TICKS, -1) addOutfitCondition(outfitJogadorTimeAzul, {lookType = 131, lookHead = 114, lookBody = 88, lookLegs = 114, lookFeet = 114, lookTypeEx = 0, lookAddons = 3}) local outfitJogadoraTimeAzul = createConditionObject(CONDITION_OUTFIT) setConditionParam(outfitJogadoraTimeAzul, CONDITION_PARAM_TICKS, -1) addOutfitCondition(outfitJogadoraTimeAzul, {lookType = 139, lookHead = 114, lookBody = 88, lookLegs = 114, lookFeet = 114, lookTypeEx = 0, lookAddons = 3}) local outfitJogadorTimeVermelho = createConditionObject(CONDITION_OUTFIT) setConditionParam(outfitJogadorTimeVermelho, CONDITION_PARAM_TICKS, -1) addOutfitCondition(outfitJogadorTimeVermelho, {lookType = 134, lookHead = 0, lookBody = 94, lookLegs = 0, lookFeet = 0, lookTypeEx = 0, lookAddons = 3}) local outfitJogadoraTimeVermelho = createConditionObject(CONDITION_OUTFIT) setConditionParam(outfitJogadoraTimeVermelho, CONDITION_PARAM_TICKS, -1) addOutfitCondition(outfitJogadoraTimeVermelho, {lookType = 142,lookHead = 0, lookBody = 94, lookLegs = 0, lookFeet = 0, lookTypeEx = 0, lookAddons = 3}) WAR_IGNORAR_ACESSO = 3 function resetaStorageJogadorWarEvent(cid) setStatusJogadorWarEvent(cid, 0) setTimeVermelho(cid, 0) setTimeAzul(cid, 0) end function resetaStorageWarEvent() db.executeQuery("UPDATE `player_storage` SET `value` = 0 WHERE `key` = " .. WAR_STORAGE_STATUS_PLAYER .. ";") db.executeQuery("UPDATE `player_storage` SET `value` = 0 WHERE `key` = " .. WAR_STORAGE_TIME_VERMELHO .. ";") db.executeQuery("UPDATE `player_storage` SET `value` = 0 WHERE `key` = " .. WAR_STORAGE_TIME_AZUL .. ";") setStatusWarEvent(0) setLimiteParticipantesWarEvent(WAR_TOTAL_PARTICIPANTES) end function setStatusWarEvent(estagio) setGlobalStorageValue(WAR_GLOBAL_STORAGE_STATUS, estagio) end function getStatusWarEvent() return getGlobalStorageValue(WAR_GLOBAL_STORAGE_STATUS) end function setLimiteParticipantesWarEvent(total) setGlobalStorageValue(WAR_GLOBAL_STORAGE_LIMITE_PARTICIPANTES, total) end function getLimiteParticipantesWarEvent() return getGlobalStorageValue(WAR_GLOBAL_STORAGE_LIMITE_PARTICIPANTES) end function getStatusJogadorWarEvent(cid) return getCreatureStorage(cid, WAR_STORAGE_STATUS_PLAYER) end function setStatusJogadorWarEvent(cid, status) doCreatureSetStorage(cid, WAR_STORAGE_STATUS_PLAYER, status) end function getTimeJogador(cid) if isTimeAzul(cid)then return "Time Azul" elseif isTimeVermelho(cid)then return "Time Vermelho" else return "Nao Definido" end end function getJogadoresSalaEsperaWarEvent() local jogadoresSalaEspera = {} for i, cid in pairs(getPlayersOnline()) do if(getStatusJogadorWarEvent(cid) == 1) then table.insert(jogadoresSalaEspera, cid) end end return jogadoresSalaEspera end function abreTeleporteWarEvent() if(getTileItemById(WAR_LOCAL_TELEPORTE, WAR_ID_TELEPORTE).uid == 0) then local teleporte = doCreateTeleport(WAR_ID_TELEPORTE, WAR_LOCAL_SALA_ESPERA, WAR_LOCAL_TELEPORTE) doItemSetAttribute(teleporte, "name", "teleporte evento war") doItemSetAttribute(teleporte, "aid", "8880") end end function fechaTeleporteWarEvent() local item = getTileItemById(WAR_LOCAL_TELEPORTE, WAR_ID_TELEPORTE) if(item.uid ~= 0) then doRemoveItem(item.uid) end end function teleportaJogadorCidadePadrao(jogador) local idCidadeNatal = getPlayerTown(jogador) local posicaoTemploCidadeNatal = getTownTemplePosition(idCidadeNatal) doTeleportThing(jogador, posicaoTemploCidadeNatal, true) doSendMagicEffect(posicaoTemploCidadeNatal, CONST_ME_TELEPORT) end function teleportaJogadorSalaEspera(cid) local acessoJogador = getPlayerAccess(cid) if(acessoJogador < WAR_IGNORAR_ACESSO) then setStatusJogadorWarEvent(cid, 1) local totalJogadoresSalaEspera = #getJogadoresSalaEsperaWarEvent() local limiteJogadoresWarEvent = getLimiteParticipantesWarEvent() local vagasDisponivel = limiteJogadoresWarEvent - totalJogadoresSalaEspera if(vagasDisponivel > 0) then doBroadcastMessage(getCreatureName(cid) .. " esta participando do Evento War. Ainda resta " .. vagasDisponivel .. " vaga(s) para o evento.") end end doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT) doTeleportThing(cid, WAR_LOCAL_SALA_ESPERA, true) doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT) end function setTimeVermelho(cid, status) doCreatureSetStorage(cid, WAR_STORAGE_TIME_VERMELHO, status) end function isTimeVermelho(cid) if(getCreatureStorage(cid, WAR_STORAGE_TIME_VERMELHO) == 1)then return true else return false end end function setTimeAzul(cid, status) doCreatureSetStorage(cid, WAR_STORAGE_TIME_AZUL, status) end function isTimeAzul(cid) if(getCreatureStorage(cid, WAR_STORAGE_TIME_AZUL) == 1)then return true else return false end end function getJogadoresTimeVermelho() local jogadoresTimeVermelho = {} for i, cid in pairs(getPlayersOnline()) do if(getStatusJogadorWarEvent(cid) == 2 and isTimeVermelho(cid)) then table.insert(jogadoresTimeVermelho, cid) end end return jogadoresTimeVermelho end function getJogadoresTimeAzul() local jogadoresTimeAzul = {} for i, cid in pairs(getPlayersOnline()) do if(getStatusJogadorWarEvent(cid) == 2 and isTimeAzul(cid)) then table.insert(jogadoresTimeAzul, cid) end end return jogadoresTimeAzul end function isWalkable(pos) if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false elseif getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 4620 then return false elseif getTopCreature(pos).uid > 0 then return false elseif isCreature(getTopCreature(pos).uid) then return false elseif getTileInfo(pos).protection then return false elseif hasProperty(getThingFromPos(pos).uid, 3) or hasProperty(getThingFromPos(pos).uid, 7) then return false end return true end function getLocalArenaWar(cid) local pos local ehPosicaoValida = false while(ehPosicaoValida == false)do local posx = {} local posy = {} local posz = {} local pir = {} for i=1, 5 do local posx_tmp, posy_tmp, posz_tmp if(isTimeAzul(cid))then posx_tmp = math.random(WAR_LOCAL_TIME_AZUL[1].x, WAR_LOCAL_TIME_AZUL[2].x) posy_tmp = math.random(WAR_LOCAL_TIME_AZUL[1].y, WAR_LOCAL_TIME_AZUL[2].y) posz_tmp = math.random(WAR_LOCAL_TIME_AZUL[1].z, WAR_LOCAL_TIME_AZUL[2].z) elseif(isTimeVermelho(cid))then posx_tmp = math.random(WAR_LOCAL_TIME_VERMELHO[1].x, WAR_LOCAL_TIME_VERMELHO[2].x) posy_tmp = math.random(WAR_LOCAL_TIME_VERMELHO[1].y, WAR_LOCAL_TIME_VERMELHO[2].y) posz_tmp = math.random(WAR_LOCAL_TIME_VERMELHO[1].z, WAR_LOCAL_TIME_VERMELHO[2].z) end local pir_tmp = 0 local spec = getSpectators({x=posx_tmp, y=posy_tmp, z=posz_tmp}, 3, 3, false) if(spec and #spec > 0) then for z, pid in pairs(spec) do if(isPlayer(pid)) then pir_tmp = pir_tmp + 1 end end end posx = posx_tmp posy = posy_tmp posz = posz_tmp pir = pir_tmp end local lowest_i = 1 for i=2, 5 do if(pir < pir[lowest_i]) then lowest_i = i end end pos = {x=posx[lowest_i], y=posy[lowest_i], z=posz[lowest_i]} if(isWalkable(pos))then ehPosicaoValida = true end end return pos end function teleportaJogadoresArenaWar() local tempoIniciarEvento = 10 for i, cid in pairs(getJogadoresSalaEsperaWarEvent()) do setStatusJogadorWarEvent(cid, 2) local jogadoresTimeVermelho = getJogadoresTimeVermelho() local jogadoresTimeAzul = getJogadoresTimeAzul() if(#jogadoresTimeVermelho == #jogadoresTimeAzul or #jogadoresTimeVermelho < #jogadoresTimeAzul)then setTimeVermelho(cid, 1) doAddCondition(cid, (getPlayerSex(cid) == 1) and outfitJogadorTimeVermelho or outfitJogadoraTimeVermelho) else setTimeAzul(cid, 1) doAddCondition(cid, (getPlayerSex(cid) == 1) and outfitJogadorTimeAzul or outfitJogadoraTimeAzul) end local localArenaWar = getLocalArenaWar(cid) doTeleportThing(cid, localArenaWar, true) doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT) doCreatureSetNoMove(cid,true) addEvent(doCreatureSetNoMove,(tempoIniciarEvento+1)*1000, cid,false) addEvent(doPlayerSendTextMessage,(tempoIniciarEvento+1)*1000,cid,MESSAGE_TYPES["warning"],"Evento War Comecou!") for i = 0,tempoIniciarEvento do addEvent(doPlayerSendTextMessage,i*1000, cid, MESSAGE_TYPES["info"], "Evento War vai iniciar em "..tempoIniciarEvento-i.." segundos!") end end end function estaArenaWar(cid) return isInRange(getThingPos(cid),WAR_LOCAL_ARENA_BATALHA[1], WAR_LOCAL_ARENA_BATALHA[2]) end function forcarInicioWarEvent() local statusWarEvent = getStatusWarEvent() if(statusWarEvent == 1) then local estagio = statusWarEvent+1 local jogadoresSalaEspera = getJogadoresSalaEsperaWarEvent() if(#jogadoresSalaEspera > 1) then iniciarWarEvent(estagio, #jogadoresSalaEspera) else for i, jogador in pairs(jogadoresSalaEspera) do teleportaJogadorCidadePadrao(jogador) end resetaStorageWarEvent() doBroadcastMessage("Evento War foi cancelado.") end fechaTeleporteWarEvent() end end function iniciarWarEvent(estagio, totalParticipantes) setStatusWarEvent(estagio) setLimiteParticipantesWarEvent(totalParticipantes) if(estagio == 1)then abreTeleporteWarEvent() addEvent(forcarInicioWarEvent,WAR_TEMPO_FORCAR_EVENTO) doBroadcastMessage("Evento War foi iniciado. O evento esta limitado a " .. getLimiteParticipantesWarEvent() .. " jogadores, o teleporte vai fechar em ".. (WAR_TEMPO_FORCAR_EVENTO/60/1000) .." minutos ou quando atingir o limite de jogadores.") elseif(estagio == 2)then fechaTeleporteWarEvent() teleportaJogadoresArenaWar() end end function presentarJogadorWarEvent(ganhador) local nomeJogador = "["..getTimeJogador(ganhador).. "] "..getCreatureName(ganhador) local trofeu = doPlayerAddItem(ganhador, WAR_PREMIOS.trofeu, 1) doItemSetAttribute(trofeu, "name", "trofeu evento war "..os.date("%d/%m/%Y", os.time())) doItemSetAttribute(trofeu, "description", "Awarded to " .. nomeJogador .. " for winning the war event.") --for _,item in ipairs(WAR_PREMIOS.itens) do --doPlayerAddItem(ganhador, item, 1) --end local itemSortiado = math.random(#WAR_PREMIOS.itens) doPlayerAddItem(ganhador, WAR_PREMIOS.itens[itemSortiado], 1) if WAR_PREMIOS.dinheiro[3] then doPlayerAddItem(ganhador, WAR_PREMIOS.dinheiro[1], WAR_PREMIOS.dinheiro[2]) end doPlayerSave(ganhador, true) end function verificarTimeVencedor() local jogadoresTimeVermelho = getJogadoresTimeVermelho() local jogadoresTimeAzul = getJogadoresTimeAzul() local teveVencedor = false local timeVencedor = {} if(#jogadoresTimeAzul > 0 and #jogadoresTimeVermelho == 0)then teveVencedor = true timeVencedor = jogadoresTimeAzul doBroadcastMessage("Time Azul Ganhou.") elseif(#jogadoresTimeVermelho > 0 and #jogadoresTimeAzul == 0)then teveVencedor = true timeVencedor = jogadoresTimeVermelho doBroadcastMessage("Time Vermelho Ganhou.") end if(teveVencedor)then for i, ganhador in pairs(timeVencedor) do presentarJogadorWarEvent(ganhador) resetaStorageJogadorWarEvent(ganhador) doRemoveConditions(ganhador, false) doTeleportThing(ganhador, WAR_LOCAL_SAIDA, true) end resetaStorageWarEvent() end end Compartilhar este post Link para o post Compartilhar em outros sites
0 Majesty 1755 #2 Postado 27 Agosto, 2017 @igordutra47 O seu servidor provavelmente não possui a função db.executeQuery(...) e portanto, não consegue atualizar os valores na database. Verifique na database se existe a tabela "player_storage". function resetaStorageWarEvent() db.executeQuery("UPDATE `player_storage` SET `value` = 0 WHERE `key` = " .. WAR_STORAGE_STATUS_PLAYER .. ";") db.executeQuery("UPDATE `player_storage` SET `value` = 0 WHERE `key` = " .. WAR_STORAGE_TIME_VERMELHO .. ";") db.executeQuery("UPDATE `player_storage` SET `value` = 0 WHERE `key` = " .. WAR_STORAGE_TIME_AZUL .. ";") Substitua db.executeQuery por db.Query ou db.escapeString pra ver se resolve o problema. Compartilhar este post Link para o post Compartilhar em outros sites
Estou com um problema em um script não entendo muito sobre.
Error: http://prntscr.com/gdmvbe
Peguei esse script:
Script:
data/globalevents/scripts/war/onstartup.lua
data/lib/102-war.lua
Compartilhar este post
Link para o post
Compartilhar em outros sites