Jump to content

rafa23alzira

Inactive Member
  • Posts

    13
  • Joined

  • Last visited

  • Feedback

    0%

Posts posted by rafa23alzira

  1. int guild_get_gold(lua_State* L)
    {
    	LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
    	if(ch && ch->GetGuild())
    	{	
    		CGuild * pkGuild = CGuildManager::instance().FindGuild(ch->GetGuild()->GetID());
    		if(pkGuild)
    			lua_pushnumber(L, pkGuild ? pkGuild->GetGuildMoney() : 0);
    	}
    	return 1;
    }
    
    int guild_change_money(lua_State * L)
    {
    	int gold = (int)lua_tonumber(L, 1);
    	LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
    	if(ch && ch->GetGuild())
    	{
    		CGuild * pkGuild = CGuildManager::instance().FindGuild(ch->GetGuild()->GetID());
    		if(pkGuild && gold > 0)
    			pkGuild->RecvMoneyChange(gold);
    	}
        return 1;
    }
    

    With these you don't need to pass any arguments so just call them like that:

    when 20091.click with pc.has_guild() begin
    	local s = select("Get guild gold","Change guild gold","Exit")
    	if s == 1 then
    		say(string.format("Your guild gold: %s",guild.get_gold()))
    	end
    	else if s == 2 then
    		say("Enter your amount")
    		local gold = input("")
    		if type(gold) == "number" then
    			guild.change_gold(gold)
    			say_reward(string.format("Your new guild gold ammount is: %s",guild.get_gold()))
    		else
    			say_reward("Only numbers are allowed")
    		end
    	end	
    end
    

    I didn't really test these functions but I guess they should work.

     

    Thanks, after test edit this comment :)

     

    Edit: Thanks Denis, function perfect :)

  2. Hi, i create 2 functions for questlua_guild but no function.

     

    My c++ level is -1  :blink:

     

    First function: guild.get_gold() - For get the gold of guild, no return nothing. 

    	int guild_get_gold(lua_State* L)
    	{
    		luaL_checknumber(L, 1);
    
    		CGuild * pkGuild = CGuildManager::instance().FindGuild((DWORD) lua_tonumber(L, 1));
    
    		if (pkGuild)
    			lua_pushnumber(L, pkGuild->GetGuildMoney());
    		else
    			lua_pushnumber(L, 0);
    
    		return 1;
    	}
    

    Second function: guild.change_money() For change the money of guild, crash server  :huh:

    	int guild_change_money(lua_State * L)
    	{
    		int gold = (int)lua_tonumber(L, -1);
    		
    		//LPCHARACTER ch = q.GetCurrentCharacterPtr();
    		CGuild * pkGuild = CGuildManager::instance().FindGuild((DWORD) lua_tonumber(L, 1));
    
    		if (gold + pkGuild->GetGuildMoney() < 0)
    			sys_err("QUEST wrong ChangeGold %d (now %d)", gold, pkGuild->GetGuildMoney());
    		else{
    			DBManager::instance().Query("UPDATE guild%s SET gold=%d WHERE name = '%s'", get_table_postfix(), gold, pkGuild->GetName());
    		}
    
    		return 0;
    	}
    

    Game compile perfect.

     

    Thanks  :)

  3. Well I just made this two functions for you, but I didn't test it, so please do it for me (but it should work) ;)

    Write these into the questlua_pc.cpp:

    	int pc_get_another_pcs_flag(lua_State * L)
    	{
    		if (lua_gettop(L) != 3 && !lua_isstring(L, 1) && !lua_isstring(L, 2) && !lua_isstring(L, 3))
    		{
    			lua_pushnumber(L, -1);
    			return 1;
    		}
    
    		const char * sPC = lua_tostring(L, 1);
    		std::string qName = lua_tostring(L, 2);
    		std::string qFlag = lua_tostring(L, 3);
    
    		LPCHARACTER selPC = CHARACTER_MANAGER::instance().FindPC(sPC);
    		if (!selPC)
    		{
    			lua_pushnumber(L, -1);
    			return 1;
    		}
    		PC * qPC = CQuestManager::instance().GetPCForce(selPC->GetPlayerID());
    		if (!qPC)
    		{
    			lua_pushnumber(L, -1);
    			return 1;
    		}
    		lua_pushnumber(L, qPC->GetFlag(qName + "." + qFlag));
    		return 1;
    	}
    
    	int pc_set_another_pcs_flag(lua_State * L)
    	{
    		if (lua_gettop(L) != 4 && !lua_isstring(L, 1) && !lua_isstring(L, 2) && !lua_isstring(L, 3) && !lua_isnumber(L, 4))
    			return 0;
    
    		const char * sPC = lua_tostring(L, 1);
    		std::string qName = lua_tostring(L, 2);
    		std::string qFlag = lua_tostring(L, 3);
    
    		LPCHARACTER selPC = CHARACTER_MANAGER::instance().FindPC(sPC);
    		if (!selPC)
    			return 0;
    		PC * qPC = CQuestManager::instance().GetPCForce(selPC->GetPlayerID());
    		if (!qPC)
    			return 0;
    
    		qPC->SetFlag(qName + "." + qFlag, int(rint(lua_tonumber(L, 4))));
    		return 0;
    	}
    

    Then scroll down to it's end, and write these into the luaL_reg pc_functions[] matrix:

    { "get_otherpc_quest_flag", pc_get_another_pcs_flag },
    { "set_otherpc_quest_flag", pc_set_another_pcs_flag },
    

    The arguments the same that you wrote in the first post of this topic. If an error trigger durning get_otherpc_quest_flag, it will push back -1 as the flag's value.

    Note that it maybe works only if the other pc is online!

    Thanks masodikbela, after compile and test write pm to you :)

×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.