Author Sticky: Post Working Scripts Here
Novanus Posted: Thursday, 27 June 04:28AM
Script: Give player a "Readme"

This script is designed for multiplayer games. When a new player connects to your server, they will be given an item describing your rules or any other special information you want them to have.

To use, simply put the script in the Module's "OnClientEnter" event. Make a custom item (such as a letter or book) with the TAG that matches the one in the script (default is "Readme"). Edit the "identified text" for that item to be the information you want the player to have when they Examine the item. The script also checks to see if the player already has the item. If they do, it doesn't give it to them again.

Also included is a support function IsInInventory which returns TRUE or FALSE, depending on whether it finds the specified item in the inventory of the supplied PC, NPC, chest, etc.

NWScript:
//::///////////////////////////////////////////////

//:: Name Give Readme

//:: FileName GiveReadme.txt

//:://////////////////////////////////////////////

/*

     This script is designed to be placed in the OnClientEnter

     event of your module, which can be found under Edit ->

     Module properties -> Events.

     This script will give a player an item with the TAG "Readme",

     if that player doesn't already have it.  You should create

     a custom item (in my case, I used the Miscellaneous-Medium

     item that looked like a sealed letter), and give it the TAG

     of "Readme".  Then, for "identified text" in the item

     properties put information on your game server or module.

     For example, you could list your rules of conduct, special

     house rules you are running, and other bits of information

     new players to your server/module should know.  When the

     player examines the item (like the books in the Bioware

     campaign), they will see the text you wrote.

     To be sure that your document is unique to your server, use

     a custom TAG and change the instances of "Readme" in the

     script to your new unique TAG.  Also, note that you can change

     the NAME of your item to anything you want, just make sure

     the TAG is the same as is used in the script.  You can also

     change the line of text the server says to the player

     telling them they should examine the item.  If your item

     was a book, then you would tell them to examine the book

     and not a letter, as I have it now.

     Also included is one support function "IsInInventory" which

     is used to determine if an item exists in an object's

     inventory (PC, NPC, chest, etc).

*/

//:://////////////////////////////////////////////

//:: Created By: Ped Xing (pedx1ng@lycos.com)

//:: Created On: 26 June, 2002

//:://////////////////////////////////////////////



// This function determines if a specific item exists in the

// specfified container, which can be a creature or placeable

// object that is a container.

int IsInInventory(object oContainer, string sItemTag)

{

object oItem;

if (GetHasInventory(oContainer))

{

    oItem = GetFirstItemInInventory(oContainer);

    while ( OBJECT_INVALID != oItem )

    {

        if (GetTag(oItem) == sItemTag)

        { return TRUE; }

        oItem = GetNextItemInInventory(oContainer);

    } // end while

} // endif

return FALSE;

} // end IsInInventory



// Main code block

void main()

{

object oPC = GetEnteringObject();

if (GetIsPC(oPC))

{

    if (IsInInventory(oPC,"Readme") == FALSE)

    {

        CreateItemOnObject("Readme",oPC);

        SendMessageToPC(oPC,"You have been given a letter describing the rules of this server - Please examine it.");

    }

}

} // end main