ADELIJAH 1 Report post Posted March 1, 2023 I've been trying for a while, but without success, a code that expels the entire Party if one of the players leaves the map. Quote Share this post Link to post Share on other sites
Mdrst 38 Report post Posted March 1, 2023 I don't think there is a way to kick players from a party using only Lua code (someone correct me if I'm wrong). I've searched and found no useful functions in the source that could do this. You can't even send a packet to GameServer or GroupServer to kick players, because the two lua functions that can send packets (SendPacket() and SynPacket()) only send them to clients. If you want to do it in source, though, it's quite easy. Inside Expand.h, add this anywhere: inline int lua_LeaveTeam(lua_State* pLS) { T_B int nParaNum = lua_gettop(pLS); bool bSuccess = true; CCharacter* cha = (CCharacter*)lua_touserdata(pLS, 1); CPlayer* ply = nullptr; do { if(nParaNum != 1 || !cha) { bSuccess = false; break; } ply = cha->GetPlayer(); if(!ply) { bSuccess = false; break; } ply->LeaveTeam(); } while(0); if(bSuccess) { lua_pushnumber(pLS, 1); } else { lua_pushnumber(pLS, 0); } return 1; T_E} Inside RegisterLuaGameLogic, add this: REGFN(LeaveTeam); Now you can use your new C++ function in .lua files. To kick everyone once a player leaves a specific map, open the ctrl.lua file inside the map folder, search for "function before_leave_[MAP_NAME]" and call your new function there: function before_leave_garner( role ) -- First, check if character leaving is in a party. local team_size = IsChaInTeam(role) if team_size > 0 then -- A party exists, so we must disband it. for i=0,3,1 do local member = GetTeamCha(role, i) if member ~= nil then LeaveTeam(member) end end LeaveTeam(role) end end Quote "Beware of bugs in the above code; I have only proved it correct, not tried it." - Donald E. Knuth Share this post Link to post Share on other sites