Author Sticky: Post Working Scripts Here
johnymutton Posted: Monday, 22 July 09:14PM
1. Script Name: Who All

2. What it does: Script that gives a list of all players in the module, with their levels and locations.

3. Notes: Instructions for implementation are included as comments in the first script. In addition, you can dl a module that demonstrates the script http://home.austin.rr.com/maffei/NWN/WhoStone.zip

4. The Script itself

NWScript:
//

// Script: Who All

//

//     jcm_whoall

//

// By: John Maffei

//     jmaffei@austin.rr.com

//     johnymutton (bioware community handle)

//

// Description:

//

//     Sends a message to the user containing all the players

//     in the module including their locations and levels

//

//     It is based on the /whoall command in Everquest

//

// Implementation

//

//     Make an item that will be your Who Stone

//     Give it a tag of "whostone"

//     Give it a blueprint of "whostone"

//     Give it a name of "Who Stone"

//     Click on the plot item checkbox

//     Give it a property of "Cast Spell: Unique power self only unlimited uses"

//

//     There are 3 scripts that must be included for the Who Stone to work

//

//     jcm_whoall           - must be included in the module

//     jcm_trig_whoall      - placed on any placeable object's OnUsed event

//                            that you want to trigger the script

//     jcm_activatemod      - placed on the OnActivateItem event of your module

//

//     in addition, depending on how you want to have the player acquire the Who Stone

//     you can add the script jcm_giv_whostone to a conversation tree.

void main()

{

    object oPC = OBJECT_SELF;

    object oSearchPC;

    object oArea;

    string sArea;

    string sMessage;

    string sName;

    string sAreaTag;

    string sLevel;

    SendMessageToPC(oPC, "---------------------------------------");

    SendMessageToPC(oPC, "Players in Who Stone Example");

    SendMessageToPC(oPC, "---------------------------------------");



    oSearchPC = GetFirstPC();

    while (oSearchPC != OBJECT_INVALID)

    {

        oArea = GetArea(oSearchPC);

        sAreaTag = GetTag(oArea);

        sName = GetName(oSearchPC);

        sArea = GetName(oArea);



        int nDruid     = GetLevelByClass(CLASS_TYPE_DRUID, oSearchPC);

        int nMonk      = GetLevelByClass(CLASS_TYPE_MONK, oSearchPC);

        int nRogue     = GetLevelByClass(CLASS_TYPE_ROGUE, oSearchPC);

        int nWizard    = GetLevelByClass(CLASS_TYPE_WIZARD, oSearchPC);

        int nSorcerer  = GetLevelByClass(CLASS_TYPE_SORCERER, oSearchPC);

        int nFighter   = GetLevelByClass(CLASS_TYPE_FIGHTER, oSearchPC);

        int nBarbarian = GetLevelByClass(CLASS_TYPE_BARBARIAN, oSearchPC);

        int nBard      = GetLevelByClass(CLASS_TYPE_BARD, oSearchPC);

        int nCleric    = GetLevelByClass(CLASS_TYPE_CLERIC, oSearchPC);

        int nPaladin   = GetLevelByClass(CLASS_TYPE_PALADIN, oSearchPC);

        int nRanger    = GetLevelByClass(CLASS_TYPE_RANGER, oSearchPC);

        string sDruidLevel      = IntToString(nDruid);

        string sMonkLevel       = IntToString(nMonk);

        string sRogueLevel      = IntToString(nRogue);

        string sWizardLevel     = IntToString(nWizard);

        string sSorcererLevel   = IntToString(nSorcerer);

        string sFighterLevel    = IntToString(nFighter);

        string sBarbarianLevel  = IntToString(nBarbarian);

        string sBardLevel       = IntToString(nBard);

        string sClericLevel     = IntToString(nCleric);

        string sPaladinLevel    = IntToString(nPaladin);

        string sRangerLevel     = IntToString(nRanger);

        if(nDruid)      sLevel = sLevel + "Druid:"      + sDruidLevel + " ";

        if(nMonk)       sLevel = sLevel + "Monk:"       + sMonkLevel + " ";

        if(nRogue)      sLevel = sLevel + "Rogue:"      + sRogueLevel + " ";

        if(nWizard)     sLevel = sLevel + "Wizard:"     + sWizardLevel + " ";

        if(nSorcerer)   sLevel = sLevel + "Sorcerer:"   + sSorcererLevel + " ";

        if(nFighter)    sLevel = sLevel + "Fighter:"    + sFighterLevel + " ";

        if(nBarbarian)  sLevel = sLevel + "Barbarian:"  + sBarbarianLevel + " ";

        if(nBard)       sLevel = sLevel + "Bard:"       + sBardLevel + " ";

        if(nCleric)     sLevel = sLevel + "Cleric:"     + sClericLevel + " ";

        if(nPaladin)    sLevel = sLevel + "Paladin:"    + sPaladinLevel + " ";

        if(nRanger)     sLevel = sLevel + "Ranger:"     + sRangerLevel + " ";



        SendMessageToPC(oPC, sName + " - " + sLevel + "- "  + sAreaTag);

        sLevel = "";



        oSearchPC = GetNextPC();

    }



    SendMessageToPC(oPC, "---------------------------------------");



}



NWScript:
//

// Script: Activate Module

//

//     jcm_activatemod

//

// By: John Maffei

//     jmaffei@austin.rr.com

//     johnymutton (bioware community handle)

//

// Description:

//

//     When the stone is useds this script triggers the Who All script

//

void main()

{

    object      oItemUsed;                      //The item used

    object      oItemUser;                      //The person who activated that item

    string      sItemTag;                       //The tag (resref) of that item

    event       eUserEvent;                     //Used for signalling a user defined event later

    oItemUsed = GetItemActivated();             //Get the item that was used

    sItemTag = GetTag(oItemUsed);               //Find out what its name is

    if (sItemTag == "whostone")

    {

        oItemUser = GetItemActivator();         //Get the person who activated our item

        ExecuteScript("jcm_whoall", oItemUser); // Execute the script

    }

}



NWScript:
//

// Script: Trigger Who All

//

//     jcm_trig_whoall

//

// By: John Maffei

//     jmaffei@austin.rr.com

//     johnymutton (bioware community handle)

//

// Description:

//

//     Triggers the Who All script

//



void main()

{

    object oPC = GetLastUsedBy();

    ExecuteScript("jcm_whoall", oPC);

}



NWScript:
//

// Script: Give Who Stone

//

//     jcm_giv_whostone

//

// By: John Maffei

//     jmaffei@austin.rr.com

//     johnymutton (bioware community handle)

//

// Description:

//

//     Gives the player the Who Stone via a conversation tree

//



void main()

{

    object      oPC;

    oPC = GetPCSpeaker();

    CreateItemOnObject("whostone", oPC);

}



_________________
Server Name: Midnight Odyssey
Genre: Action
My NWN Resource Page I Cant Find My Sheep