Author Topic: Client Enter: Give item from race adding to script.  (Read 381 times)

Legacy_Guest_NWN Dragon-Blade_*

  • Jr. Member
  • **
  • Posts: 92
  • Karma: +0/-0
Client Enter: Give item from race adding to script.
« on: March 01, 2011, 02:58:40 am »


               I am trying to add the script below to the one below that. I think my if statements are off I am trying to make it so that if the PC is elven, and does not have the amulet he is given it. Then I am trying to add it to my current on enter script. Thankyou, Dragon-Blade suckish scripter '<img'>

The item script.
object oPC = GetEnteringObject();
if (!GetIsPC(oPC)) return;
if ((GetRacialType(oPC)==RACIAL_TYPE_ELF))
   {
   if (GetItemPossessedBy(oPC, "Ammy_Elf")== OBJECT_INVALID)
      {
      CreateItemOnObject("elf_ammy", oPC);
      }
   }
}




Script trying to add it to
#include "gs_inc_common"
#include "gs_inc_text"
void main()
{
    object oEntering   = GetEnteringObject();
    if (GetIsDM(oEntering)) return;
    //check if cd key is banned
    object oBanishment = GetLocalObject(OBJECT_SELF, "GS_BANISHMENT");
    if (GetIsObjectValid(oBanishment))
    {
        string sCDKey = GetPCPublicCDKey(oEntering);
        if (GetIsObjectValid(GetItemPossessedBy(oBanishment, "GS_BA_" + sCDKey)))
        {
            SendMessageToAllDMs(
                gsCMReplaceString(
                    GS_T_16777425,
                    GetName(oEntering),
                    GetPCPlayerName(oEntering),
                    sCDKey));
            BootPC(oEntering);
            return;
        }
    }
    AddJournalQuestEntry("GS_DIARY_001", 1, oEntering, FALSE);
    AddJournalQuestEntry("GS_DIARY_002", 1, oEntering, FALSE);
    if (GetLocalInt(oEntering, "GS_ENABLED"))
    {
        //restore health
        int nHealth = GetLocalInt(OBJECT_SELF, "GS_HEALTH_" + ObjectToString(oEntering));
        gsCMSetHitPoints(nHealth, oEntering);
        SetLocalInt(oEntering, "GS_ENABLED", -1);
    }
    //activity
    SetLocalInt(oEntering, "GS_ACTIVE", TRUE);
    ExecuteScript("activateclimbing",OBJECT_SELF);
}
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Client Enter: Give item from race adding to script.
« Reply #1 on: March 01, 2011, 03:23:20 am »


               Something kinda like so:

#include "gs_inc_common"
#include "gs_inc_text"
void main()
{
    object oEntering   = GetEnteringObject();
    if (GetIsDM(oEntering)) return;
    //check if cd key is banned
    object oBanishment = GetLocalObject(OBJECT_SELF, "GS_BANISHMENT");
    if (GetIsObjectValid(oBanishment))
    {
        string sCDKey = GetPCPublicCDKey(oEntering);
        if (GetIsObjectValid(GetItemPossessedBy(oBanishment, "GS_BA_" + sCDKey)))
        {
            SendMessageToAllDMs(
                gsCMReplaceString(
                    GS_T_16777425,
                    GetName(oEntering),
                    GetPCPlayerName(oEntering),
                    sCDKey));
            BootPC(oEntering);
            return;
        }
    }
    AddJournalQuestEntry("GS_DIARY_001", 1, oEntering, FALSE);
    AddJournalQuestEntry("GS_DIARY_002", 1, oEntering, FALSE);
    if (GetLocalInt(oEntering, "GS_ENABLED"))
    {
        //restore health
        int nHealth = GetLocalInt(OBJECT_SELF, "GS_HEALTH_" + ObjectToString(oEntering));
        gsCMSetHitPoints(nHealth, oEntering);
        SetLocalInt(oEntering, "GS_ENABLED", -1);
    }
    //activity
    SetLocalInt(oEntering, "GS_ACTIVE", TRUE);
    ExecuteScript("activateclimbing",OBJECT_SELF);

    if (GetRacialType(oPC)==RACIAL_TYPE_ELF && GetIsPC(oPC))
    {
        if (GetItemPossessedBy(oPC, "Ammy_Elf")== OBJECT_INVALID)
        {
            CreateItemOnObject("elf_ammy", oPC);
        }
    }
}

Hope it helps.
               
               

               


                     Modifié par GhostOfGod, 01 mars 2011 - 03:24 .
                     
                  


            

Legacy_Guest_NWN Dragon-Blade_*

  • Jr. Member
  • **
  • Posts: 92
  • Karma: +0/-0
Client Enter: Give item from race adding to script.
« Reply #2 on: March 01, 2011, 05:24:31 pm »


               Error, variable defined without type '<img'>


#include "gs_inc_common"
#include "gs_inc_text"
void main()
{
    object oEntering   = GetEnteringObject();
    if (GetIsDM(oEntering)) return;
    //check if cd key is banned
    object oBanishment = GetLocalObject(OBJECT_SELF, "GS_BANISHMENT");
    if (GetIsObjectValid(oBanishment))
    {
        string sCDKey = GetPCPublicCDKey(oEntering);
        if (GetIsObjectValid(GetItemPossessedBy(oBanishment, "GS_BA_" + sCDKey)))
        {
            SendMessageToAllDMs(
                gsCMReplaceString(
                    GS_T_16777425,
                    GetName(oEntering),
                    GetPCPlayerName(oEntering),
                    sCDKey));
            BootPC(oEntering);
            return;
        }
    }
    AddJournalQuestEntry("GS_DIARY_001", 1, oEntering, FALSE);
    AddJournalQuestEntry("GS_DIARY_002", 1, oEntering, FALSE);
    if (GetLocalInt(oEntering, "GS_ENABLED"))
    {
        //restore health
        int nHealth = GetLocalInt(OBJECT_SELF, "GS_HEALTH_" + ObjectToString(oEntering));
        gsCMSetHitPoints(nHealth, oEntering);
        SetLocalInt(oEntering, "GS_ENABLED", -1);
    }
    //activity
    SetLocalInt(oEntering, "GS_ACTIVE", TRUE);
    ExecuteScript("activateclimbing",OBJECT_SELF);
    if (GetRacialType(oPC)==RACIAL_TYPE_ELF && GetIsPC(oPC))
    {
        if (GetItemPossessedBy(oPC, "Ammy_Elf")== OBJECT_INVALID)
        {
            CreateItemOnObject("elf_ammy", oPC);
        }
    }
}
               
               

               


                     Modifié par NWN Dragon-Blade, 01 mars 2011 - 05:25 .
                     
                  


            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Client Enter: Give item from race adding to script.
« Reply #3 on: March 01, 2011, 06:14:18 pm »


               Change oPC to oEntering.
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Client Enter: Give item from race adding to script.
« Reply #4 on: March 01, 2011, 06:14:55 pm »


               The next 2 lines also will need that change.
               
               

               
            

Legacy_Guest_NWN Dragon-Blade_*

  • Jr. Member
  • **
  • Posts: 92
  • Karma: +0/-0
Client Enter: Give item from race adding to script.
« Reply #5 on: March 01, 2011, 06:41:19 pm »


               Thanks it worked!
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Client Enter: Give item from race adding to script.
« Reply #6 on: March 01, 2011, 07:53:38 pm »


               oops. sorry bout that.