Robson » Code Viewer
- Path: code/s_breakparties.txt
- Lines: 121
- Size: 3.96kB
//:://///////////////////////////////////////////////:: Break Parties Script//:: s_breakparties//:: Copyright (c) 2004 Icey//::///////////////////////////////////////////////* Large PC parties generate more lag than the same number of people in smaller parties. This script runs through everyone in the server and checks the size of their party. If it's larger than the maximum allowed, all members of the faction are sent a message and removed from the faction. ** THIS SCRIPT HAS NOT BEEN TESTED ** *///::////////////////////////////////////////////////:: Created By: Icey (iceyboard.no-ip.org)//:: Created On: 3rd August, 2004//::////////////////////////////////////////////// //* FUNCTION DECLARATIONS *// // returns the size of a faction when given a memberint GetFactionSize(object oMember); // removes all members of the faction, just for PC factions// oMember = Any member of the factionvoid DestroyFaction(object oMember); //* CONSTANTS *// // the maximum amount of people allowed in a party// this must be 1 or more// setting to 1 will destroy all partiesconst int IC_MAX_PARTY_SIZE = 7; // the message sent to explain why a party was destroyedconst string IC_TALK_DESTROY_PARTY = "Large parties generate more lag so your party has been destroyed. Use smaller parties in future.";// the message to send when the max party size is invalid// the invalid amount is shown after thisconst string IC_TALK_INVALID = "The maximum allowed party size is too small. It is: "; //* FUNCTIONS *// // returns the size of a faction when given a memberint GetFactionSize(object oMember){ // this will store the amount of people in the party int nFactionSize = 0; // get the first member of the party, and only get pcs object oMember = GetFirstFactionMember(oMember, TRUE); // loop while we found another member of the party while (GetIsObjectValid(oMember)) { // don't check dms if (!GetIsDM(oMember) && !GetIsDMPossessed(oMember)) // increment the counter nFactionSize++; // get the next pc in the party oMember = GetNextFactionMember(oMember, TRUE); } // return the number of people in the party return nFactionSize;} // removes all members of the faction, just for PC factionsvoid DestroyFaction(object oMember){ // get the first member of the party, and only get pcs object oMember = GetFirstFactionMember(oMember, TRUE); // loop while we found another member of the party while (GetIsObjectValid(oMember)) { // don't remove dm's from parties if (!GetIsDM(oMember) && !GetIsDMPossessed(oMember)) { // tell them why they are being removed from the party SendMessageToPC(oMember, IC_TALK_DESTROY_PARTY); // make them leave the party RemoveFromParty(oMember); } // get the next pc in the party oMember = GetNextFactionMember(oMember, TRUE); }} // main function, see header for details of this scriptvoid main(){ // check if the max party size is invalid if (IC_MAX_PARTY_SIZE < 1) // sent to all dm's so that this script can be run from a conversation/wand/console/etc SendMessageToAllDMs(IC_TALK_INVALID + "'" + IntToString(IC_MAX_PARTY_SIZE) + "'."); // if it's valid, run the code else { // get the first pc object oPC = GetFirstPC(); // only loop while there are more pcs while (GetIsObjectValid(oPC)) { // don't check if this is a dm if (!GetIsDM(oPC) && !GetIsDMPossessed(oPC)) { // check if the party is bigger than the allowed max size if (GetFactionSize(oPC) > IC_MAX_PARTY_SIZE) // destroy the faction DestroyFaction(oPC); } // find the next pc in the module oPC = GetNextPC(); } }}