Jump to content

[Duvida] Como obtenho um valor via mysql.query


Luffy
 Share

Recommended Posts

Pessoal eu tava tentando conseguir o hp maximo de um mob através do mysql.query, mas parece não funcionar o código é esse logo abaixo

Alguém pode me ajudar?

Spoiler

quest testmaxhpmob begin
    state start begin
        when kill with not npc.is_pc() begin
        local hp =   mysql.query("SELECT max_hp FROM player.mob_proto WHERE vnum ='"..npc.get_race().."' LIMIT 1;")

      chat(""..hp.."')
            
        end
    end    
end

 

Link to comment
Share on other sites

Não seria mais fácil assim?

Vá em questlua_npc.cpp e adicione abaixo da função: int npc_set_vid_damage_mul(lua_State* L)

int npc_get_max_hp(lua_State* L)
    {
        LPCHARACTER npc = CQuestManager::instance().GetCurrentNPCCharacterPtr();
        lua_pushnumber(L, npc ? npc->GetMobTable().dwMaxHP : 0);
        return 1;
    }

depois vá em void RegisterNPCFunctionTable() e adicione isso :

{ "get_max_hp",            npc_get_max_hp            },

abaixo da definição: {"set_vid_damage_mul",  npc_set_vid_damage_mul},

Mini quest com a nova função npc.get_max_hp() :

quest mob_max_hp begin
    state start begin
    
        when kill with not npc.is_pc() begin
            syschat("HP: "..npc.get_max_hp())
        end
        
    end
end
Edited by juniorsilva
Link to comment
Share on other sites

10 horas atrás, juniorsilva disse:

Não seria mais fácil assim?

Vá em questlua_npc.cpp e adicione abaixo da função: int npc_set_vid_damage_mul(lua_State* L)


int npc_get_max_hp(lua_State* L)
    {
        LPCHARACTER npc = CQuestManager::instance().GetCurrentNPCCharacterPtr();
        lua_pushnumber(L, npc ? npc->GetMobTable().dwMaxHP : 0);
        return 1;
    }

depois vá em void RegisterNPCFunctionTable() e adicione isso :


{ "get_max_hp",            npc_get_max_hp            },

abaixo da definição: {"set_vid_damage_mul",  npc_set_vid_damage_mul},

Mini quest com a nova função npc.get_max_hp() :


quest mob_max_hp begin
    state start begin
    
        when kill with not npc.is_pc() begin
            syschat("HP: "..npc.get_max_hp())
        end
        
    end
end

Tudo dito aqui, bom trabalho.

Link to comment
Share on other sites

21 horas atrás, juniorsilva disse:

Não seria mais fácil assim?

Vá em questlua_npc.cpp e adicione abaixo da função: int npc_set_vid_damage_mul(lua_State* L)


int npc_get_max_hp(lua_State* L)
    {
        LPCHARACTER npc = CQuestManager::instance().GetCurrentNPCCharacterPtr();
        lua_pushnumber(L, npc ? npc->GetMobTable().dwMaxHP : 0);
        return 1;
    }

depois vá em void RegisterNPCFunctionTable() e adicione isso :


{ "get_max_hp",            npc_get_max_hp            },

abaixo da definição: {"set_vid_damage_mul",  npc_set_vid_damage_mul},

Mini quest com a nova função npc.get_max_hp() :


quest mob_max_hp begin
    state start begin
    
        when kill with not npc.is_pc() begin
            syschat("HP: "..npc.get_max_hp())
        end
        
    end
end

Muito Obrigado, Junior!

Eu até tentei criar algumas funções, mas ainda não compreendo a "lógica" da source do metin

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...