Active Member ReFresh 2340 Posted March 30, 2019 Active Member Share Posted March 30, 2019 Hey guys, have someone function is same guild? What I need? I need to check if target player have the same guild as me. I tried something like this: local x, y, targetGuild = pc.get_x() * 100, pc.get_y() * 100, pc.get_guild() But it didn't work when I tried to use this: if targetGuild != pc.get_guild() then Thanks for answers! Sincerely, ReFresh I'll be always helpful! Link to comment Share on other sites More sharing options...
Premium WeedHex 635 Posted March 30, 2019 Premium Share Posted March 30, 2019 You can keep the string name of the guild and compare if is same or not. Btw I think that you can already use something with GuildID. Link to comment Share on other sites More sharing options...
OtherChoice 77 Posted March 31, 2019 Share Posted March 31, 2019 LPGUILD objects can be compared through operator ==. pPlayer1->GetGuild() == pPlayer2->GetGuild() 1 Link to comment Share on other sites More sharing options...
Premium WeedHex 635 Posted March 31, 2019 Premium Share Posted March 31, 2019 CGuild* pkGuild = CGuildManager::instance().FindGuild(GetGuildID()); pkGuild->GetName(); pkGuild->GetID(); pkGuild->GetMasterPID(); You can do what you wish. (It's from Meley, just to make a fast example) Other example on: ACMD(do_priv_guild) Link to comment Share on other sites More sharing options...
Active Member ReFresh 2340 Posted March 31, 2019 Author Active Member Share Posted March 31, 2019 @OtherChoice As you can see I need to compare guild names with lua not with c++. I'll be always helpful! Link to comment Share on other sites More sharing options...
Premium Syreldar 1875 Posted March 31, 2019 Premium Share Posted March 31, 2019 You need to compare the guild of 2 players and see if they're the same guild? 1. Declare an empty variable that will store the guild of the target player. (e.s. local target_player_guild;) 2. Declare a variable that stores your own vid. (e.s. local player_vid = pc.get_vid();) 3. Get Target player's vid. (e.s. local target_vid = npc.get_vid();) #When to trigger it is up to you :shrugs: 4. Select his vid (pc.select(target_vid);) 5. set target_player_guild = pc.get_guild(); 6. Go back to your vid. (pc.select(player_vid);) 7. if (target_player_guild == pc.get_guild()) then -- do things. end -- if 1 "Nothing's free in this life. Ignorant people have an obligation to make up for their ignorance by paying those who help them. Either you got the brains or cash, if you lack both you're useless." Syreldar Link to comment Share on other sites More sharing options...
Forum Moderator Solution VegaS™ 10274 Posted March 31, 2019 Forum Moderator Solution Share Posted March 31, 2019 If you want to compare the guild of 2 players and see if they're in the same guild you should do a global function for LUA, which can be used everywhere. Src/Server/game/src/questlua_global.cpp Spoiler // Search for: ALUA(_get_locale) { lua_pushstring(L, g_stLocale.c_str()); return 1; } // Add after: ALUA(_is_same_guild) { if (!lua_isstring(L, 1) || !lua_isstring(L, 2)) { sys_err("invalid argument"); lua_pushboolean(L, 0); return 1; } // Get name of players (arg1, arg2). const std::string c_rstrName = lua_tostring(L, 1); const std::string c_rstrTargetName = lua_tostring(L, 2); // Get character pointer by name. const LPCHARACTER pkChr = CHARACTER_MANAGER::instance().FindPC(c_rstrName.c_str()); const LPCHARACTER pkChrTarget = CHARACTER_MANAGER::instance().FindPC(c_rstrTargetName.c_str()); // Check if players are in a guild and if they're same. if ((pkChr && pkChrTarget) && (pkChr->GetGuild() && pkChrTarget->GetGuild())) { lua_pushboolean(L, pkChr->GetGuild() == pkChrTarget->GetGuild()); } else { lua_pushboolean(L, 0); } return 1; } // Search for: { "get_locale", _get_locale }, // Add after: { "is_same_guild", _is_same_guild }, share/locale/germany/quest_function Spoiler is_same_guild quest_example.lua Spoiler local name = pc.get_name() local target_name = "UnknownName" if (is_same_guild(name, target_name)) then -- They're in the same guild. else -- They aren't in the same guild. end 2 Check my GitHub Profile Click to find all the threads started by me [TOOL] Text file loader + JSON Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now