Author Topic: need scripting help  (Read 311 times)

Legacy_Madwack

  • Newbie
  • *
  • Posts: 45
  • Karma: +0/-0
need scripting help
« on: August 11, 2011, 09:56:29 pm »


               Greets

I have restarted the world I was building and with updating to 1.69...I have with my limmited scripting kept things working amazingly enough...and I mean limited.


horses....player logs in and horse is gone....

now when i say i need help...you will see why....this is not my level of scripting.....

what i need my world to do is this......player logs out and script goes...ooo you have a horse and saves a Database entry

player logs in and script goes ooo you have a horse......auto move you then creat horse beside player or create horse item in player inventory so he can goto a stable and get his horse again.

if there another way of doing this I am game.


THIS IS THE SERVERS ON ENTER SCRIPT

if anyone want to help...I can post some of the other scripts as well

THANKS

MADWACK
------------------------------------------------------------------------------------------------------





#include "pp_includes"


#include "iounfunctions"


#include "persistant_inc"


#include "inc_gsystem_evnt"

#include "master_levels"


#include "x3_inc_horse"

int ScanItemListBad( object oPC, string Player_DB, string Player_Index )
  {

  int CurrentModuleVersion = 1;   //  Modifying this will update all players on entry.

  int iFound = 0;

  int iDoingEquipt = 1;
  int iEquipSlot = 0;


   // See if the player is reloading part way through the process.
  string RefList =  GetCampaignString( Player_DB, "PW_PITM-"+Player_Index );
  if( GetStringLength( RefList ) > 1 )
    return( 1 );
  RefList = "";

  if( GetCampaignInt( Player_DB, "PW_PVER-"+Player_Index ) ==  CurrentModuleVersion )
    return( 0 );

  string sResref = "";


  //Scan through equiped items and standard inventory.

  object oItem = GetItemInSlot( iEquipSlot, oPC );


  SetCampaignInt( Player_DB, "PW_PVER-"+Player_Index ,CurrentModuleVersion );


    while( iEquipSlot < NUM_INVENTORY_SLOTS )
    {

    if( oItem != OBJECT_INVALID )
      {
      if( GetGoldPieceValue( oItem ) > 10000 )
      if( ! GetItemCursedFlag( oItem ) )
      if( ! GetHasInventory( oItem ) )
      if( GetItemStackSize( oItem ) == 1 )
        {

        RefList +=  GetResRef( oItem ) + "," ;

        DestroyObject( oItem, 0.2 );

        iFound++;

        }
      }


      iEquipSlot++;
      oItem = GetItemInSlot( iEquipSlot, oPC );

    }


  SetLocalString( oPC, "LOGIN_EQ_SWAP", RefList );

  oItem = GetFirstItemInInventory( oPC );


  while( oItem != OBJECT_INVALID )
    {

      if( GetGoldPieceValue( oItem ) > 10000 )
      if( ! GetItemCursedFlag( oItem ) )
      if( ! GetHasInventory( oItem ) )
      if( GetItemStackSize( oItem ) == 1 )
        {

        RefList +=  GetResRef( oItem ) + "," ;

        SetLocalString( oPC, "LOGIN_EQ_SWAP", RefList );

        DestroyObject( oItem, 0.2 );
        iFound++;

        }

      oItem = GetNextItemInInventory( oPC );
    }

  SetCampaignString( Player_DB, "PW_PITM-"+Player_Index, RefList );
  SetLocalString( oPC, "LOGIN_EQ_SWAP", "" );

  if( iFound > 0 )
    {
    SendMessageToPC( oPC, "Please visit the bank on the island to retrieve your equipment." );
    return( 1 );
    }

  return( 0 );

  }




// Module : OnClientEnter by Brian "spilth" Kelly
// For Neverwinter Nights - Binding Stone Tutorial

// Modified by David Bills to include persistant data.

void main()
  {
       object oPC = GetEnteringObject();





//HORSE

  ExecuteScript("x3_mod_pre_enter",OBJECT_SELF); // Override for other skin systems
    if ((GetIsPC(oPC)||GetIsDM(oPC))&&!GetHasFeat(FEAT_HORSE_MENU,oPC))

    { // add horse menu
        HorseAddHorseMenu(oPC);
        if (GetLocalInt(GetModule(),"X3_ENABLE_MOUNT_DB"))
        { // restore PC horse status from database
            DelayCommand(2.0,HorseReloadFromDatabase(oPC,X3_HORSE_DATABASE));
        } // restore PC horse status from database

    } // add horse menu
    if (GetIsPC(oPC))

    { // more details
        // restore appearance in case you export your character in mounted form, etc.
        if (!GetSkinInt(oPC,"bX3_IS_MOUNTED")) HorseIfNotDefaultAppearanceChange(oPC);
        // pre-cache horse animations for player as attaching a tail to the model
        HorsePreloadAnimations(oPC);
        DelayCommand(3.0,HorseRestoreHenchmenLocations(oPC));

    }

// more details










    if (GetIsDM(oPC) == TRUE && GetItemPossessedBy(oPC,"hh_dm_tool")==OBJECT_INVALID)
    {
        CreateItemOnObject("hh_dm_tool",oPC,1);
    }

 //  PGSModuleClientEnterEvent();



  SetLocalInt( oPC, "restallow", 0);
    SetIounOnEnter(oPC);
    PPDisable(oPC);
  if (GetIsPC(oPC))
    {


    effect eEffect = GetFirstEffect( oPC );
    int nFound = FALSE;
    while ( GetIsEffectValid( eEffect ) && !nFound )
    {
      if ( GetEffectType( eEffect ) == EFFECT_TYPE_MOVEMENT_SPEED_INCREASE )

      {
        RemoveEffect( oPC, eEffect );
        nFound = TRUE;
      }
      eEffect = GetNextEffect( oPC );
    }



    // Let's get the player's account and character name.
    // And we need to parse out garbage characters from the name.


    string Player_DB = GetPCPlayerName( oPC );

    string sPCName = GetStringLowerCase( GetName( oPC ) );
    int iNameLength = GetStringLength( sPCName );
    int iNameCnt = 0;
    int iNameValidChars = 0;
    string Player_Index = "";
    string sPCLetter;

    object oBook_Remove;

    while( iNameCnt < iNameLength   &&  iNameValidChars < 16 )
      {
      sPCLetter = GetSubString( sPCName, iNameCnt, 1 );
      if( TestStringAgainstPattern( "*a", sPCLetter ) )
        {
        Player_Index = Player_Index + sPCLetter;
        iNameValidChars++;
        }
      iNameCnt++;
      }





/* This returns to the last location/hitpoints section. */
        int nPCHP = GetLocalInt(oPC,"Current_HP");
        if(nPCHP > 0)
          {
          int nMaxPCHP = GetCurrentHitPoints(oPC);
          int nPCDamage = nMaxPCHP - nPCHP;
          if(nPCHP < nMaxPCHP)
            ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectDamage(nPCDamage),oPC);
          }


   int iRein = 0;
   if( GetItemPossessedBy( oPC, "reincarnate4" ) != OBJECT_INVALID )
     {
     iRein = 4;
     SetLocalInt( oPC, "Reincarnate", 4 );
     oBook_Remove = GetItemPossessedBy( oPC, "reincarnate1" );
     if( oBook_Remove != OBJECT_INVALID )
       DestroyObject( oBook_Remove, 1.0 );
     oBook_Remove = GetItemPossessedBy( oPC, "reincarnate2" );
     if( oBook_Remove != OBJECT_INVALID )
       DestroyObject( oBook_Remove, 1.2 );
     oBook_Remove = GetItemPossessedBy( oPC, "reincarnate3" );
     if( oBook_Remove != OBJECT_INVALID )
       DestroyObject( oBook_Remove, 1.4 );
     }
   else
   if( GetItemPossessedBy( oPC, "reincarnate3" ) != OBJECT_INVALID )
     {
     iRein = 3;
     SetLocalInt( oPC, "Reincarnate", 3 );
     oBook_Remove = GetItemPossessedBy( oPC, "reincarnate1" );
     if( oBook_Remove != OBJECT_INVALID )
       DestroyObject( oBook_Remove, 1.0 );
     oBook_Remove = GetItemPossessedBy( oPC, "reincarnate2" );
     if( oBook_Remove != OBJECT_INVALID )
       DestroyObject( oBook_Remove, 1.2 );
     }
   else
   if( GetItemPossessedBy( oPC, "reincarnate2" ) != OBJECT_INVALID )
     {
     iRein = 2;
     SetLocalInt( oPC, "Reincarnate", 2 );
     oBook_Remove = GetItemPossessedBy( oPC, "reincarnate1" );
     if( oBook_Remove != OBJECT_INVALID )
       DestroyObject( oBook_Remove, 1.0 );
     }
   else
   if( GetItemPossessedBy( oPC, "reincarnate1" ) != OBJECT_INVALID )
     {
     iRein = 1;
     SetLocalInt( oPC, "Reincarnate", 1 );
     }
   else
     SetLocalInt( oPC, "Reincarnate", 0 );



       // These variables are used instead of the normal functions for GetName.
      // The reason for this is the OnClientExit function wipes the player
      // name and character name before entry, but not the local variables.
    SetLocalInt( oPC, "PW_Is_Player", 1 );
    SetLocalString( oPC, "PW_Player", Player_DB );
    SetLocalString( oPC, "PW_Character", GetName( oPC ) );

    SetLocalInt( oPC, "PW_Needs_Sanc", 0 );

    SetLocalString( oPC, "PW_DataBase", Player_DB );
    SetLocalString( oPC, "PW_DataBase_Index", Player_Index );

   if( iRein > 0 )
     SendMessageToPC( oPC, "Welcome reincarnate " + GetName( oPC ) +
             ", to the Lands of Arda persistant world."  );
   else
    SendMessageToPC(oPC, "Welcome, " + GetName( oPC ) +
             ", to the Lands of Arda persistant world."  );

//    SendMessageToPC(oPC, "Character autosave now running."  );  // Really old

    SendMessageToPC(oPC, "Website: http://loa.lyngthyssen.dk/index.html" );
    SendMessageToPC(oPC, "Enjoy your stay."  );

  //  Temporary script stuff.  Erase for the real game.

  //  SendMessageToPC(oPC, "Account: '" + Player_DB + "'" );
  //  SendMessageToPC(oPC, "DB_Index: '" + Player_Index + "'" );

  // Cut here.


        // Autospell saved stuff
    int nSpells = GetCampaignInt(  Player_DB, "PW_Spells-"+Player_Index );
    SetLocalInt( oPC, "Spells", nSpells);
    string sSpell;
    while( nSpells > 0 )
      {
      sSpell = IntToString(nSpells);
      SetLocalInt( oPC, "Spells"+sSpell,
        GetCampaignInt(  Player_DB, "PW_Spe-"+sSpell+"-" +Player_Index ) );
      nSpells --;
      }





    int iScanned = ScanItemListBad( oPC, Player_DB, Player_Index );


    location lPC_Location;



      // Load the PW Location Data if they are not already moving.
    if( GetLocalInt( oPC, "Need_To_Move" ) == 0  &&
        GetLocalInt( oPC, "Need_To_Move_Wait" ) == 0 )
        {


      vector   vPC_Location;
      float    fPC_Facing;
      object   oPC_area;

      oPC_area = GetObjectByTag(
          GetCampaignString( Player_DB, "PW_LOCN-"+Player_Index ) );

      fPC_Facing =
          GetCampaignFloat(  Player_DB, "PW_LOCD-"+Player_Index );

      vPC_Location = Vector(
          GetCampaignFloat(  Player_DB, "PW_LOCX-"+Player_Index ),
          GetCampaignFloat(  Player_DB, "PW_LOCY-"+Player_Index ), 0.0 );

      lPC_Location = Location( oPC_area, vPC_Location, fPC_Facing );

      SetLocalLocation( oPC, "PW_Location", lPC_Location );

//      SetLocalLocation( oPC, "PW_Location",
//             GetCampaignLocation( Player_DB, "PW_LOC-"+Player_Index ) );

        }

   // SetLocalInt( oPC, "Dead",
   //     GetCampaignInt( Player_DB, "PW_DEAD-"+Player_Index ) );




   //   This is just to display the database file name.
   //SendMessageToPC( oPC, "Player Database <"+Player_DB+">" );
   //SendMessageToPC( oPC, "Player Index <"+Player_Index+">" );


    string sBindPoint =
        GetCampaignString( Player_DB, "PW_BND-"+Player_Index );


     //  Force the player to move to bank if there exists items in it.
     if( iScanned == 1 )
       {
       lPC_Location = GetLocation( GetObjectByTag( "ardaloginsign" ) );
       SetLocalLocation( oPC, "PW_Location", lPC_Location );
       SetLocalInt( oPC, "Need_To_Move", 1 );
       SetLocalInt( oPC, "Need_To_Move_Wait", 1 );
       AssignCommand( oPC, ClearAllActions() );
       AssignCommand( oPC, SetCommandable(FALSE)  );
       }
    else
     // This person has not been given persistant data.
     // It could also be a brand new player.
    if( sBindPoint == "" )
      {  // This guy has not set up persistant data.
      SetLocalString(oPC, "BindPoint", "mithbind");
      SetLocalLocation( oPC, "PW_Last_Location", GetLocation( oPC ) );
      AssignCommand( oPC, ClearAllActions() );
      AssignCommand( oPC, SetCommandable(TRUE)  );

       // This guy just started the game.

      if( GetXP(oPC) == 0  &&
         GetLocalInt(oPC, "startgold") == FALSE )
        {
        TakeGoldFromCreature( GetGold(oPC), oPC, TRUE );
        GiveGoldToCreature(oPC, 2000);
        GiveXPToCreature(oPC,1001);
        SetLocalInt(oPC, "startgold", TRUE);

        CreateItemOnObject("striderjournal", oPC);

        int nCnt = 0;
        while( nCnt < 25 )
          {
          CreateItemOnObject("smallcampsitekit", oPC);
          nCnt++;
          }
        }
      }
    else
      {

      if( GetLocalString(oPC, "BindPoint" ) == "" )
        {

        // This person is starting after a reboot.

        location lLoc  =  GetLocalLocation(oPC, "PW_Location" );

        SetLocalLocation( oPC, "PW_Last_Location", lLoc );

        string sArea = GetTag( GetAreaFromLocation( lLoc ) );
        string shortArea = GetStringLeft( sArea, 4);

        /*  Reboot will take you back to where you came from unless camping
            or on a boat */

        if( GetLocalInt( GetModule(), "HeartbeatCounter" ) > 300  ||
            sArea == "sea_boat"   )
          {
          lLoc = GetLocation( GetObjectByTag( sBindPoint ) );

          SetLocalLocation( oPC, "PW_Location", lLoc );
          SetLocalLocation( oPC, "PW_Last_Location", lLoc );
          SendMessageToPC(oPC, "You are being moved to your binding stone because the area you were in does not allow your return."  );
          }
        else
          {
          /* Make the character temporarily hidden and damage proof */
          SetLocalInt( oPC, "PW_Needs_Sanc", 1 );

          SendMessageToPC(oPC, "You are being moved to your last location." );
          SendMessageToPC(oPC, "You now have temporary sanctuary." );
          }

       object oArea1 = GetAreaFromLocation( lLoc ) ;


          SendMessageToPC(oPC,"Your last location: "+GetName(oArea1)+".");

          SetLocalInt( oPC, "Need_To_Move", 1);
          SetLocalInt( oPC, "Need_To_Move_Wait", 1);  // Slow them a bit more.

          AssignCommand( oPC, ClearAllActions() );
          AssignCommand( oPC, SetCommandable(FALSE)  );

        // This is a player that just loaded after a reboot.
        // This person cannot be a brand new player.
        SetLocalString(oPC, "BindPoint", sBindPoint );
        }
      else
        {

        // This person is starting normally.

        location lLoc = GetLocalLocation( oPC, "PW_Last_Location" );
        string sArea = GetTag( GetAreaFromLocation( lLoc ) );
        string shortArea = GetStringLeft( sArea, 4);

        int Beat_Counter = GetLocalInt( GetModule(), "HeartbeatCounter" ) -
                           GetLocalInt( oPC, "HeartbeatCounterPC" );


        AVRestoreSpells( oPC );


        if( GetLocalInt( oPC, "Need_To_Move" ) > 0  ||
            GetLocalInt( oPC, "Need_To_Move_Wait" ) > 0  )
          {
            SetLocalInt( oPC, "Need_To_Move", 1 );
            SetLocalInt( oPC, "Need_To_Move_Wait", 1 );
            AssignCommand( oPC, ClearAllActions() );
            AssignCommand( oPC, SetCommandable(FALSE)  );
            SendMessageToPC(oPC, "You are being moved to a new location."  );
          }
        else
        if( sArea == "sea_boat" ||
            ( shortArea == "anti"   &&   Beat_Counter > 60 ) )
                // These are in heartbeat ticks, so each is 6 seconds.
          {
          lLoc = GetLocation( GetObjectByTag(
                      GetLocalString(oPC, "BindPoint" ) ) );
          SetLocalLocation( oPC, "PW_Location", lLoc );
          SetLocalLocation( oPC, "PW_Last_Location", lLoc );

             // Be sure to preserve their new location.
          SetLocalInt( oPC, "Need_To_Move", 0);
          SetLocalInt( oPC, "Need_To_Move_Wait", 0);
          Save_Persistant_Data( oPC );


            SetLocalInt( oPC, "Need_To_Move", 1);
            SetLocalInt( oPC, "Need_To_Move_Wait", 1);
            AssignCommand( oPC, ClearAllActions() );
            AssignCommand( oPC, SetCommandable(FALSE)  );
            SendMessageToPC(oPC, "You are being moved to your binding stone because the area you were in does not allow your return."  );
          }
        else
          {
          AssignCommand( oPC, ClearAllActions() );
          AssignCommand( oPC, SetCommandable(TRUE)  );

          if( GetLocalInt( oPC, "Reincarnate" ) > 0 )
            Reincarnate_Level_Apply( oPC );

          }

        }
      }

    if( GetLocalInt(oPC,"Dead") == 1 )
      {
      effect Deathstroke=EffectDeath(TRUE);
      ApplyEffectToObject(DURATION_TYPE_INSTANT,Deathstroke,oPC);
      }

    }




  }
               
               

               


                     Modifié par Madwack, 11 août 2011 - 09:10 .