Ir para conteúdo

Salazar Slytherin

Membro
  • Registro em

  • Última visita

Tudo que Salazar Slytherin postou

  1. Olá galera do T.k Bom, estou atrás de um sistema evolutivo que vi a um tempo em uma base de Digitibia O sistema funciona da seguinte maneira, a evolução AMARELA é a única permanente porem a VERMELHA e AZUL depende uma da outra... Ex: Tem que ter uma certa quantidade de mana para evolução. A evolução VERMELHA precisa esta na amarela e para evolução AZUL precisa esta na VERMELHA porem essas outras 2 evolução tem "Time". -- estou utilizado duas evoluções como ex. No final da linha evolutiva, caso queira destransformar é necessário esperar um certo tempo... "Tentei adapta o sistema Mega Evolutivo, a um tempo atrás porem não tive êxito." Vai perdoando os erro ortográfico ? Funciona dessa forma. Imagem do antigo "DigiWO"
  2. Só agradecer , sempre ajudando geral Parabéns pelo sistema.
  3. Também não deu certo, vou utiliza assim mesmo, acho que so funciona mexendo na source. Obrigado por tudo ai , ctz não resolveu o meu mais vai resolver de muitas pessoas
  4. Apaguei e sumi a opção de marca e desmarca porem não funcionou
  5. Funcionou não funcionando... tipo, ele ta como eu falei, porem o ambiente "ambientLight" não esta ficando escuro como era para ficar. Activando ou desactivando as luzes fica da mesma forma...
  6. options.lua
  7. Esqueci de por meu código.. ele não tem essa função ///////////////////////////////////////////////////////////////////////////////////////////// local defaultOptions = { vsync = true, showFps = false, showPing = false, fullscreen = false, classicControl = true, smartWalk = false, dashWalk = false, autoChaseOverride = true, showStatusMessagesInConsole = true, showEventMessagesInConsole = true, showInfoMessagesInConsole = true, showTimestampsInConsole = true, showLevelsInConsole = true, showPrivateMessagesInConsole = false, showPrivateMessagesOnScreen = true, showLeftPanel = false, foregroundFrameRate = 61, backgroundFrameRate = 80, painterEngine = 0, enableAudio = true, enableMusicSound = true, musicSoundVolume = 100, enableAmbientSound = true, ambientSoundVolume = 30, enableEffectSound = true, effectSoundVolume = 100, enablePrivateMessageAlert = true, enableLights = true, ambientLight = 70, displayNames = true, displayHealth = true, displayText = true, displayExperience = true, dontStretchShrink = false, enableShaderEffects = true, displayEnvironmentEffects = true, displayMapGuides = true, displayGameTime = true, displaySquaredCrosshair = false, } local optionsWindow local optionsButton local optionsTabBar local options = {} local generalPanel local consolePanel local graphicsPanel local soundPanel local audioButton local function setupGraphicsEngines() local enginesRadioGroup = UIRadioGroup.create() local ogl1 = graphicsPanel:getChildById('opengl1') local ogl2 = graphicsPanel:getChildById('opengl2') local dx9 = graphicsPanel:getChildById('directx9') enginesRadioGroup:addWidget(ogl1) enginesRadioGroup:addWidget(ogl2) enginesRadioGroup:addWidget(dx9) if g_window.getPlatformType() == 'WIN32-EGL' then enginesRadioGroup:selectWidget(dx9) ogl1:setEnabled(false) ogl2:setEnabled(false) dx9:setEnabled(true) else ogl1:setEnabled(g_graphics.isPainterEngineAvailable(1)) ogl2:setEnabled(g_graphics.isPainterEngineAvailable(2)) dx9:setEnabled(false) if g_graphics.getPainterEngine() == 2 then enginesRadioGroup:selectWidget(ogl2) else enginesRadioGroup:selectWidget(ogl1) end if g_app.getOs() ~= 'windows' then dx9:hide() end end enginesRadioGroup.onSelectionChange = function(self, selected) if selected == ogl1 then setOption('painterEngine', 1) elseif selected == ogl2 then setOption('painterEngine', 2) end end if not g_graphics.canCacheBackbuffer() then graphicsPanel:getChildById('foregroundFrameRate'):disable() graphicsPanel:getChildById('foregroundFrameRateLabel'):disable() end end function onOnline() g_game.getProtocolGame():sendExtendedOpcode(ExtendedIds.DashWalking, (options['dashWalk'] and "1" or "0")) end function init() for k,v in pairs(defaultOptions) do g_settings.setDefault(k, v) options[k] = v end optionsWindow = g_ui.displayUI('options') optionsWindow:hide() optionsTabBar = optionsWindow:getChildById('optionsTabBar') optionsTabBar:setContentWidget(optionsWindow:getChildById('optionsTabContent')) g_keyboard.bindKeyDown('Ctrl+Shift+F', function() toggleOption('fullscreen') end) g_keyboard.bindKeyDown('Ctrl+N', toggleDisplays) generalPanel = g_ui.loadUI('game') optionsTabBar:addTab(tr('Game'), generalPanel, '/images/optionstab/game') consolePanel = g_ui.loadUI('console') optionsTabBar:addTab(tr('Console'), consolePanel, '/images/optionstab/console') graphicsPanel = g_ui.loadUI('graphics') optionsTabBar:addTab(tr('Graphics'), graphicsPanel, '/images/optionstab/graphics') audioPanel = g_ui.loadUI('audio') optionsTabBar:addTab(tr('Audio'), audioPanel, '/images/optionstab/audio') optionsButton = modules.client_topmenu.addLeftButton('optionsButton', tr('Options'), '/images/topbuttons/options', toggle) audioButton = modules.client_topmenu.addLeftButton('audioButton', tr('Audio'), '/images/topbuttons/audio', function() toggleOption('enableAudio') end) addEvent(function() setup() end) connect(g_game, { onGameStart = onOnline }) end function terminate() g_keyboard.unbindKeyDown('Ctrl+Shift+F') g_keyboard.unbindKeyDown('Ctrl+N') optionsWindow:destroy() optionsButton:destroy() audioButton:destroy() disconnect(g_game, { onGameStart = onOnline }) end function setup() -- load options for k,v in pairs(defaultOptions) do if type(v) == 'boolean' then setOption(k, g_settings.getBoolean(k), true) elseif type(v) == 'number' then setOption(k, g_settings.getNumber(k), true) end end setupGraphicsEngines() end function toggle() if optionsWindow:isVisible() then hide() else show() end end function show() optionsWindow:show() optionsWindow:raise() optionsWindow:focus() end function hide() optionsWindow:hide() end function toggleDisplays() if options['displayNames'] and options['displayHealth'] then setOption('displayNames', false) elseif options['displayHealth'] then setOption('displayHealth', false) else if not options['displayNames'] and not options['displayHealth'] then setOption('displayNames', true) else setOption('displayHealth', true) end end end function toggleOption(key) setOption(key, not getOption(key)) end function setOption(key, value, force) if not force and options[key] == value then return end local gameMapPanel = modules.game_interface.getMapPanel() if key == 'vsync' then g_window.setVerticalSync(value) elseif key == 'showFps' then modules.client_topmenu.setFpsVisible(value) elseif key == 'showPing' then modules.client_topmenu.setPingVisible(value) elseif key == 'fullscreen' then g_window.setFullscreen(value) elseif key == 'enableAudio' then g_sounds.setAudioEnabled(value) if value then audioButton:setIcon('/images/topbuttons/audio') else audioButton:setIcon('/images/topbuttons/audio_mute') end elseif key == 'enableMusicSound' then g_sounds.getChannel(SoundChannels.Music):setEnabled(value) elseif key == 'musicSoundVolume' then g_sounds.getChannel(SoundChannels.Music):setGain(value/100) audioPanel:getChildById('musicSoundVolumeLabel'):setText(tr('Music volume: %d', value)) elseif key == 'enableAmbientSound' then g_sounds.getChannel(SoundChannels.Ambient):setEnabled(value) elseif key == 'ambientSoundVolume' then g_sounds.getChannel(SoundChannels.Ambient):setGain(value/100) audioPanel:getChildById('ambientSoundVolumeLabel'):setText(tr('Ambient volume: %d', value)) elseif key == 'enableEffectSound' then g_sounds.getChannel(SoundChannels.Effect):setEnabled(value) elseif key == 'effectSoundVolume' then g_sounds.getChannel(SoundChannels.Effect):setGain(value/100) audioPanel:getChildById('effectSoundVolumeLabel'):setText(tr('Effect volume: %d', value)) elseif key == 'enablePrivateMessageAlert' then modules.game_console.setPrivateMessageAlert(value) elseif key == 'showLeftPanel' then modules.game_interface.getLeftPanel():setOn(value) elseif key == 'backgroundFrameRate' then local text, v = value, value if value <= 0 or value >= 201 then text = 'max' v = 0 end graphicsPanel:getChildById('backgroundFrameRateLabel'):setText(tr('Game framerate limit: %s', text)) g_app.setBackgroundPaneMaxFps(v) elseif key == 'foregroundFrameRate' then local text, v = value, value if value <= 0 or value >= 61 then text = 'max' v = 0 end graphicsPanel:getChildById('foregroundFrameRateLabel'):setText(tr('Interface framerate limit: %s', text)) g_app.setForegroundPaneMaxFps(v) elseif key == 'enableLights' then gameMapPanel:setDrawLights(value and options['ambientLight'] < 100) graphicsPanel:getChildById('ambientLight'):setEnabled(value) graphicsPanel:getChildById('ambientLightLabel'):setEnabled(value) elseif key == 'ambientLight' then graphicsPanel:getChildById('ambientLightLabel'):setText(tr('Ambient light: %s%%', value)) gameMapPanel:setMinimumAmbientLight(value/100) gameMapPanel:setDrawLights(options['enableLights'] and value < 100) elseif key == 'painterEngine' then g_graphics.selectPainterEngine(value) elseif key == 'displayNames' then gameMapPanel:setDrawNames(value) elseif key == 'displayHealth' then gameMapPanel:setDrawHealthBars(value) elseif key == 'displayText' then gameMapPanel:setDrawTexts(value) elseif key == 'displayExperience' then gameMapPanel:setDrawExperienceBars(value) elseif key == 'dontStretchShrink' then addEvent(function() modules.game_interface.updateStretchShrink() end) elseif key == 'enableShaderEffects' then g_graphics.setShouldUseShaders(value) elseif key == 'displayEnvironmentEffects' then -- modules.game_environment.setDisplay(value) elseif key == 'displayMapGuides' then modules.game_minimap.setGuidesDisplay(value) elseif key == 'displayGameTime' then modules.game_time.setDisplay(value) elseif key == 'displaySquaredCrosshair' then _G['UICREATUREBUTTON_USESQUARED'] = (value) elseif key == 'dashWalk' then if g_game.isOnline() then g_game.getProtocolGame():sendExtendedOpcode(ExtendedIds.DashWalking, (value and "1" or "0")) end end -- change value for keybind updates for _,panel in pairs(optionsTabBar:getTabsPanel()) do local widget = panel:recursiveGetChildById(key) if widget then if widget:getStyle().__class == 'UICheckBox' then widget:setChecked(value) elseif widget:getStyle().__class == 'UIScrollBar' then widget:setValue(value) end break end end g_settings.set(key, value) options[key] = value end function getOption(key) return options[key] end function addTab(name, panel, icon) optionsTabBar:addTab(name, panel, icon) end function addButton(name, func, icon) optionsTabBar:addButton(name, func, icon) end
  8. Qual o motivo deste tópico? Bom galera , eu queria saber se tem alguma maneira de trava isso aqui na Souce? isso mesmo... travar! Tipo para que [Ativar luzes] fique sempre ativo, porem o play não possa tira de 10%. já tentei trava no mod porem tem alguns que conhece e tira...
  9. #D/T/N Alguém poderia explica como adiciona esse tipo de font no Otc, eu já tentei de varias formas e não conseguir... E Sim, eu tenho a Source do Client. Agradeço de já a atenção, e caso seja complicado, Sou todo Ouvidos... Discord (>'-')> Salazarslytherin#0033
  10. Salazar Slytherin postou uma resposta no tópico em Códigos C++
    E para mudar o tamanho da fonte? tipo muda o tamanho no nick,o tamanho do dano...
  11. Os que estão conseguindo não compartilha a ajuda...
  12. .Qual servidor ou website você utiliza como base? Qual o motivo deste tópico? Tenho Duvidas em adiciona pokes nessa base. alguém ou algum tópico explicativo? Está surgindo algum erro? Se sim coloque-o aqui. Você tem o código disponível? Se tiver publique-o aqui: Você tem alguma imagem que possa auxiliar no problema? Se sim, coloque-a aqui.
  13. Agora esta dando esse outro erro [28/09/2019 11:38:10] [Error - TalkAction Interface] [28/09/2019 11:38:10] datapack/talkactions/scripts/move1.lua:onSay [28/09/2019 11:38:10] Description: [28/09/2019 11:38:10] (luaDoTeleportThing) Thing not found [28/09/2019 11:38:10] [Error - TalkAction Interface] [28/09/2019 11:38:10] datapack/talkactions/scripts/move1.lua:onSay [28/09/2019 11:38:10] Description: [28/09/2019 11:38:10] (luaDoCreatureSetLookDir) Creature not found Alguém ajuda
  14. meu Pokemon moves não tem a função min = getSpecialAttack(cid) * table.f * 0.1 --alterado v1.6
  15. acho que ele quer saber onde vai as tags
  16. .Qual servidor ou website você utiliza como base? Nao sei se é possivel porem estou tentando coloca no ZR Qual o motivo deste tópico? Adicionei tudo direitinho eu clico a Stone some e tudo, porem não aparece a evolução e da esse erro. Está surgindo algum erro? Se sim coloque-o aqui. Você tem o código disponível? Se tiver publique-o aqui: Troque o código da função getNewMoveTable(table, n) por este: function getNewMoveTable(table, n) if table == nil then return false end local moves = {table.move1, table.move2, table.move3, table.move4, table.move5, table.move6, table.move7, table.move8, table.move9, table.move10, table.move11, table.move12} local returnValue = moves if n then returnValue = moves[n] end return returnValue end No código da função doUpdateMoves(cid), troque o segundo: table.insert(ret, "n/n,") por: local mEvolve if not getCreatureName(summon):find("Mega") and getItemAttribute(getPlayerSlotItem(cid, 8).uid, "megaStone") then if not isInArray(ret, "Mega Evolution,") then table.insert(ret, "Mega Evolution,") mEvolve = true end end if not mEvolve then table.insert(ret, "n/n,") end Depois, em pokemon moves.lua: Troque: min = getSpecialAttack(cid) * table.f * 0.1 --alterado v1.6 por: min = getSpecialAttack(cid) * (table and table.f or 0) * 0.1 --alterado v1.6 Código da spell: elseif spell == "Mega Evolution" then local effect = xxx --Efeito de mega evolução. if isSummon(cid) then local pid = getCreatureMaster(cid) if isPlayer(pid) then local ball = getPlayerSlotItem(pid, 8).uid if ball > 0 then local attr = getItemAttribute(ball, "megaStone") if attr and megaEvolutions[attr] then local oldPosition, oldLookdir = getThingPos(cid), getCreatureLookDir(cid) doItemSetAttribute(ball, "poke", megaEvolutions[attr][2]) doSendMagicEffect(getThingPos(cid), effect) doRemoveCreature(cid) doSummonMonster(pid, megaEvolutions[attr][2]) local newPoke = getCreatureSummons(pid)[1] doTeleportThing(newPoke, oldPosition, false) doCreatureSetLookDir(newPoke, oldLookdir) adjustStatus(newPoke, ball, true, false) if useKpdoDlls then addEvent(doUpdateMoves, 5, pid) end end end end end Depois, em configuration.lua: megaEvolutions = { --[itemid] = {"poke_name", "mega_evolution"}, [11638] = {"Charizard", "Mega Charizard X"}, [11639] = {"Charizard", "Mega Charizard Y"}, } Agora, em data/actions/scripts, código da mega stone: function onUse(cid, item) local mEvolution, ball = megaEvolutions[item.itemid], getPlayerSlotItem(cid, 8).uid if not mEvolution then return doPlayerSendCancel(cid, "Sorry, this isn't a mega stone.") elseif ball < 1 then return doPlayerSendCancel(cid, "Put a pokeball in the pokeball slot.") elseif #getCreatureSummons(cid) > 0 then return doPlayerSendCancel(cid, "Return your pokemon.") elseif getItemAttribute(ball, "poke") ~= mEvolution[1] then return doPlayerSendCancel(cid, "Put a pokeball with a(n) "..mEvolution[1].." in the pokeball slot.") elseif getItemAttribute(ball, "megaStone") then return doPlayerSendCancel(cid, "Your pokemon is already holding a mega stone.") end doItemSetAttribute(ball, "megaStone", item.itemid) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Now your "..getItemAttribute(ball, "poke").." is holding a(n) "..getItemNameById(item.itemid)..".") doRemoveItem(item.uid) return true end Depois, em goback.lua: Abaixo de: if not pokes[pokemon] then return true end coloque: if pokemon:find("Mega") then local normalPoke = megaEvolutions[getItemAttribute(item.uid, "megaStone")][1] if normalPoke then doItemSetAttribute(item.uid, "poke", normalPoke) pokemon = normalPoke end end Depois, em data/creaturescripts/scripts, look.lua: Abaixo de: local boost = getItemAttribute(thing.uid, "boost") or 0 coloque: local extraInfo, megaStone = "", getItemAttribute(thing.uid, "megaStone") if megaStone then extraInfo = getItemNameById(megaStone) if pokename:find("Mega") then pokename = megaEvolutions[megaStone][1] end end Depois, acima do primeiro: doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, table.concat(str)) coloque: if extraInfo ~= "" then table.insert(str, "\nIt's holding a(n) "..extraInfo..".") end Já em data/talkactions/scripts, move1.lua: Abaixo de: function doAlertReady(cid, id, movename, n, cd) coloque: if movename == "Mega Evolution" then return true end Troque: if not move then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your pokemon doesn't recognize this move.") return true end por: if not move then local isMega = getItemAttribute(getPlayerSlotItem(cid, 8).uid, "megaStone") if not isMega or name:find("Mega") then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your pokemon doesn't recognize this move.") return true end local moveTable, index = getNewMoveTable(movestable[name]), 0 for i = 1, 12 do if not moveTable[i] then index = i break end end if tonumber(it) ~= index then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your pokemon doesn't recognize this move.") return true end local needCds = true --Coloque false se o pokémon puder mega evoluir mesmo com spells em cooldown. if needCds then for i = 1, 12 do if getCD(getPlayerSlotItem(cid, 8).uid, "move"..i) > 0 then return doPlayerSendCancel(cid, "To mega evolve, all the spells of your pokemon need to be ready.") end end end move = {name = "Mega Evolution", level = 0, cd = 0, dist = 1, target = 0, f = 0, t = "?"} end E troque: doCreatureSay(cid, ""..getPokeName(mypoke)..", "..msgs[math.random(#msgs)]..""..move.name.."!", TALKTYPE_SAY) por: local spellMessage = msgs[math.random(#msgs)]..""..move.name.."!" if move.name == "Mega Evolution" then spellMessage = "Mega Evolve!" end doCreatureSay(cid, getPokeName(mypoke)..", "..spellMessage, TALKTYPE_SAY) Se quiser que o "Mega" não apareça no nome do pokémon, vá em data/lib, level system.lua: Acima de: if getItemAttribute(item, "nick") then nick = getItemAttribute(item, "nick") end coloque: if nick:find("Mega") then nick = nick:match("Mega (.*)") if not pokes[nick] then nick = nick:explode(" ")[1] end end Caso queiram que cada mega evolução tenha um clan específico: Em move1.lua, acima de: move = {name = "Mega Evolution", level = 0, cd = 0, dist = 1, target = 0, f = 0, t = "?"} coloque: local megaEvoClans = { --[mega_stone_id] = "clan_name", [91912] = "Volcanic", [91913] = "Seavell", --etc, } if megaEvoClans[isMega] then if getPlayerClanName(cid) ~= megaEvoClans[isMega] then return doPlayerSendCancel(cid, "You can't mega evolve this pokemon.") end end Bem, é isso aí. Acho que não esqueci de nada. Até mais. Você tem alguma imagem que possa auxiliar no problema? Se sim, coloque-a aqui.
  17. .Qual servidor ou website você utiliza como base? Qual quer base esta dando a mesma coisa.. já tentei em muitas ? Qual o motivo deste tópico? Estou tentando Compila no DEV CCP ja fiz todos tutorial que tem em forum e sempre da a mesma coisa. Está surgindo algum erro? Se sim coloque-o aqui. Você tem o código disponível? Se tiver publique-o aqui: //////////////////////////////////////////////////////////////////////// // OpenTibia - an opensource roleplaying game //////////////////////////////////////////////////////////////////////// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. //////////////////////////////////////////////////////////////////////// // C++ Implementation: databaseodbc // Description: Frontend for ODBC connections // // Author: Bruno R Ferreira <[email protected]>, (C) 2007 //////////////////////////////////////////////////////////////////////// #include "otpch.h" #include <iostream> #include "database.h" #include "databaseodbc.h" #include "configmanager.h" extern ConfigManager g_config; #define RETURN_SUCCESS(ret) (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO) DatabaseODBC::DatabaseODBC() { m_connected = false; char* dns = new char[SQL_MAX_DSN_LENGTH]; char* user = new char[32]; char* pass = new char[32]; strcpy((char*)dns, g_config.getString(ConfigManager::SQL_DB).c_str()); strcpy((char*)user, g_config.getString(ConfigManager::SQL_USER).c_str()); strcpy((char*)pass, g_config.getString(ConfigManager::SQL_PASS).c_str()); SQLRETURN ret = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &m_env); if(!RETURN_SUCCESS(ret)) { std::cout << "Failed to allocate ODBC SQLHENV enviroment handle." << std::endl; m_env = NULL; return; } ret = SQLSetEnvAttr(m_env, SQL_ATTR_ODBC_VERSION, (SQLPOINTER*)SQL_OV_ODBC3, 0); if(!RETURN_SUCCESS(ret)) { std::cout << "SQLSetEnvAttr(SQL_ATTR_ODBC_VERSION): Failed to switch to ODBC 3 version." << std::endl; SQLFreeHandle(SQL_HANDLE_ENV, m_env); m_env = NULL; } if(m_env == NULL) { std::cout << "ODBC SQLHENV enviroment not initialized." << std::endl; return; } ret = SQLAllocHandle(SQL_HANDLE_DBC, m_env, &m_handle); if(!RETURN_SUCCESS(ret)) { std::cout << "Failed to allocate ODBC SQLHDBC connection handle." << std::endl; m_handle = NULL; return; } ret = SQLSetConnectAttr(m_handle, SQL_ATTR_CONNECTION_TIMEOUT, (SQLPOINTER*)5, 0); if(!RETURN_SUCCESS(ret)) { std::cout << "SQLSetConnectAttr(SQL_ATTR_CONNECTION_TIMEOUT): Failed to set connection timeout." << std::endl; SQLFreeHandle(SQL_HANDLE_DBC, m_handle); m_handle = NULL; return; } ret = SQLConnect(m_handle, (SQLCHAR*)dns, SQL_NTS, (SQLCHAR*)user, SQL_NTS, (SQLCHAR*)pass, SQL_NTS); if(!RETURN_SUCCESS(ret)) { std::cout << "Failed to connect to ODBC via DSN: " << dns << " (user " << user << ")" << std::endl; SQLFreeHandle(SQL_HANDLE_DBC, m_handle); m_handle = NULL; return; } m_connected = true; } DatabaseODBC::~DatabaseODBC() { if(m_connected) { SQLDisconnect(m_handle); SQLFreeHandle(SQL_HANDLE_DBC, m_handle); m_handle = NULL; m_connected = false; } SQLFreeHandle(SQL_HANDLE_ENV, m_env); } bool DatabaseODBC::getParam(DBParam_t param) { switch(param) { case DBPARAM_MULTIINSERT: default: break; } return false; } bool DatabaseODBC::beginTransaction() { return true; // return executeQuery("BEGIN"); } bool DatabaseODBC::rollback() { return true; // SQL_RETURN ret = SQLTransact(m_env, m_handle, SQL_ROLLBACK); // return RETURN_SUCCESS(ret); } bool DatabaseODBC::commit() { return true; // SQL_RETURN ret = SQLTransact(m_env, m_handle, SQL_COMMIT); // return RETURN_SUCCESS(ret); } bool DatabaseODBC::executeQuery(const std::string& query) { if(!m_connected) return false; #ifdef __SQL_QUERY_DEBUG__ std::cout << "ODBC QUERY: " << query << std::endl; #endif SQLHSTMT stmt; SQLRETURN ret = SQLAllocHandle(SQL_HANDLE_STMT, m_handle, &stmt); if(!RETURN_SUCCESS(ret)) { std::cout << "Failed to allocate ODBC SQLHSTMT statement." << std::endl; return false; } std::string buf = _parse(query); ret = SQLExecDirect(stmt, (SQLCHAR*)buf.c_str(), buf.length()); if(!RETURN_SUCCESS(ret)) { std::cout << "SQLExecDirect(): " << query << ": ODBC ERROR." << std::endl; return false; } return true; } DBResult* DatabaseODBC::storeQuery(const std::string& query) { if(!m_connected) return NULL; #ifdef __SQL_QUERY_DEBUG__ std::cout << "ODBC QUERY: " << query << std::endl; #endif SQLHSTMT stmt; SQLRETURN ret = SQLAllocHandle(SQL_HANDLE_STMT, m_handle, &stmt); if(!RETURN_SUCCESS(ret)) { std::cout << "Failed to allocate ODBC SQLHSTMT statement." << std::endl; return NULL; } std::string buf = _parse(query); ret = SQLExecDirect(stmt, (SQLCHAR*)buf.c_str(), buf.length() ); if(!RETURN_SUCCESS(ret)) { std::cout << "SQLExecDirect(): " << query << ": ODBC ERROR." << std::endl; return NULL; } DBResult* results = (DBResult*)new ODBCResult(stmt); return verifyResult(results); } std::string DatabaseODBC::escapeBlob(const char *s, uint32_t length) { std::string buf = "'"; for(uint32_t i = 0; i < length; i++) { switch(s) { case '\'': buf += "\'\'"; break; case '\0': buf += "\\0"; break; case '\\': buf += "\\\\"; break; case '\r': buf += "\\r"; break; case '\n': buf += "\\n"; break; default: buf += s; } } buf += "'"; return buf; } std::string DatabaseODBC::_parse(const std::string& s) { std::string query = ""; query.reserve(s.size()); bool inString = false; for(uint32_t a = 0; a < s.length(); a++) { uint8_t ch = s[a]; if(ch == '\'') { if(inString && s[a + 1] != '\'') inString = false; else inString = true; } if(ch == '`' && !inString) ch = '"'; query += ch; } return query; } int32_t ODBCResult::getDataInt(const std::string& s) { listNames_t::iterator it = m_listNames.find(s); if(it != m_listNames.end()) { int32_t value; SQLRETURN ret = SQLGetData(m_handle, it->second, SQL_C_SLONG, &value, 0, NULL); if(RETURN_SUCCESS(ret)) return value; else std::cout << "Error during getDataInt(" << s << ")." << std::endl; } std::cout << "Error during getDataInt(" << s << ")." << std::endl; return 0; // Failed } int64_t ODBCResult::getDataLong(const std::string& s) { listNames_t::iterator it = m_listNames.find(s); if(it != m_listNames.end()) { int64_t value; SQLRETURN ret = SQLGetData(m_handle, it->second, SQL_C_SBIGINT, &value, 0, NULL); if(RETURN_SUCCESS(ret)) return value; else std::cout << "Error during getDataLong(" << s << ")." << std::endl; } std::cout << "Error during getDataLong(" << s << ")." << std::endl; return 0; // Failed } std::string ODBCResult::getDataString(const std::string& s) { listNames_t::iterator it = m_listNames.find(s); if(it != m_listNames.end()) { char* value = new char[1024]; SQLRETURN ret = SQLGetData(m_handle, it->second, SQL_C_CHAR, value, 1024, NULL); if(RETURN_SUCCESS(ret)) { std::string buff = std::string(value); return buff; } else std::cout << "Error during getDataString(" << s << ")." << std::endl; } std::cout << "Error during getDataString(" << s << ")." << std::endl; return std::string(""); // Failed } const char* ODBCResult::getDataStream(const std::string& s, uint64_t& size) { listNames_t::iterator it = m_listNames.find(s); if(it != m_listNames.end()) { char* value = new char[1024]; if(RETURN_SUCCESS(SQLGetData(m_handle, it->second, SQL_C_BINARY, value, 1024, (SQLLEN*)&size))) return value; } std::cout << "Error during getDataStream(" << s << ")." << std::endl; size = 0; return 0; // Failed } void ODBCResult::free() { if(m_handle) { SQLFreeHandle(SQL_HANDLE_STMT, m_handle); delete this; } else std::cout << "[Warning - ODBCResult::free] Trying to free already freed result." << std::endl; } bool ODBCResult::next() { SQLRETURN ret = SQLFetch(m_handle); return RETURN_SUCCESS(ret); } ODBCResult::ODBCResult(SQLHSTMT stmt) { if(!res) { delete this; return; } m_handle = stmt; int16_t numCols = 0; SQLNumResultCols(m_handle, &numCols); for(int32_t i = 1; i <= numCols; i++) { char* name = new char[129]; SQLDescribeCol(m_handle, i, (SQLCHAR*)name, 129, NULL, NULL, NULL, NULL, NULL); m_listNames[name] = i; } } Você tem alguma imagem que possa auxiliar no problema? Se sim, coloque-a aqui.
  18. quando eu apago isso ela da muitos erros diferentes
  19. tem Sources?

Informação Importante

Confirmação de Termo