Author Topic: item based script help...  (Read 697 times)

Legacy_seventh_son

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
item based script help...
« on: September 07, 2010, 03:10:05 am »


               Â You guys are going to hate me... as I have explained before I am not a scripter, I can muddle my way through a script and figure out what if will do, but cant write a script from scratch. Anyway I need some help with at least 4 more scripts, most of them may even be the same issues... basically what happens with all of the is when I buy an item say flint that I can use later to create a campfire, or a tent for later resting. a tent or a campfire will randomly appear somewhere else in the mod near another player. or with the tent when clicked later to open a convo to ask the player to pack up the tent it packs up the tent and then right away spawns in another tent in front of the player... It may also be an Onaquire or Onactivate Mod script, I can send thos along as well if you wan to look at that...




Script one: This is my camfire script that when you use flint, a campfire appears next to the player...

#include "x2_inc_switches"
void main()
{
if (GetUserDefinedEventNumber() != X2_ITEM_EVENT_ACTIVATE)return;
object oPC;

object oTarget;
object oSpawn;
location lTarget;
oPC = GetItemActivator();

lTarget = GetItemActivatedTargetLocation();

oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "rr_campsite", lTarget);

}


script two: This is my tent script, in a convo, that asks you to pack up the tent, when you do,this script fires and it spawns in another tent in front you and puts the tent bundle back in your inventory...


#include "x2_inc_switches"
void main()
{

if (GetUserDefinedEventNumber() != X2_ITEM_EVENT_ACTIVATE)return;
object oPC = GetPCSpeaker();

object oTarget;
oTarget = OBJECT_SELF;

DestroyObject(oTarget, 0.0);

//Give Item

CreateItemOnObject("geo_tent", oPC);

}



and finally my Horse script... When I buy a horse mount/dismount tool from a merchant, it immediatly opens the convo that lets you mount/dismout your horse...




#include "x2_inc_switches"
void main()
{
if (GetUserDefinedEventNumber() != X2_ITEM_EVENT_ACTIVATE)return;
object oPC;

object oTarget;
oPC = GetItemActivator();

//The PC will technically start a conversation with himself
//You should add some odd little sound to the first line in the
//conversation file, or the PC will give his normal voicegreeting.

oTarget = oPC;

AssignCommand(oTarget, ActionStartConversation(oPC, "luc_convo"));

}
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
item based script help...
« Reply #1 on: September 07, 2010, 03:23:47 am »


               You should probably check your script in your "OnModuleLoad" event. Check to see if it has this line:

SetModuleSwitch (MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS, TRUE);

And that it is uncommented (no "//" in front of it).
               
               

               
            

Legacy_seventh_son

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
item based script help...
« Reply #2 on: September 07, 2010, 03:26:00 am »


               it is in there and it is uncommented
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
item based script help...
« Reply #3 on: September 07, 2010, 03:33:33 am »


               Ok. Now does each item that you activate have it's own unique tag and each of the names of the scripts that go along with the items match exactly the tag of these items? They need to be unique. Unless you want several items to run the same script...but that's another matter.
               
               

               


                     Modifié par GhostOfGod, 07 septembre 2010 - 02:33 .
                     
                  


            

Legacy_seventh_son

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
item based script help...
« Reply #4 on: September 07, 2010, 03:35:41 am »


               yes they items being used each have a unique tag and the script firing is the same as the tag of each of the unique items...
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
item based script help...
« Reply #5 on: September 07, 2010, 03:38:17 am »


               Are you using custom scripts for your module events, such as the "OnActivateItem"?
               
               

               
            

Legacy_seventh_son

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
item based script help...
« Reply #6 on: September 07, 2010, 03:40:04 am »


               yes... I am. I figured that might be part of the problem but the script is huge and didnt want to post it here...
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
item based script help...
« Reply #7 on: September 07, 2010, 03:44:56 am »


               Don't worry about posting it just yet. Let's take a look at the first script first. Just looking at this script it should technically work if you are using it as intended.

So with this first script, the player uses an item(flint) and then select a location on the ground to put it, and then a campfire should appear on the ground at that location? If this is not happening then what are the exact issues with this one?
               
               

               
            

Legacy_seventh_son

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
item based script help...
« Reply #8 on: September 07, 2010, 03:47:45 am »


               well, actually when I wrote it that was my intent. I wanted to choose a location for the campfire, but when i use the item it automatically spawns a campfire right away. I was willing to live that, Small issue... but the real issue with that script is that when I buy the flint at a store, a campfire will immediatly spawn in with my using a flint near another player somewhere else in the mod.
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
item based script help...
« Reply #9 on: September 07, 2010, 03:52:34 am »


               Ok. For this particular one, check out its item properties and make sure you are using Cast Spell: Unique power. Not Unique power self only. And then of course make sure you edit it to how many uses you want.
               
               

               


                     Modifié par GhostOfGod, 07 septembre 2010 - 02:53 .
                     
                  


            

Legacy_seventh_son

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
item based script help...
« Reply #10 on: September 07, 2010, 03:56:23 am »


               ok, so It was "Unique power" self only, I switched it to "Unique power", interesting that i didnt notice that one...
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
item based script help...
« Reply #11 on: September 07, 2010, 03:59:31 am »


               No worries. I do that kind of stuff all the time. Hopefully that fixes that problem.
               
               

               
            

Legacy_seventh_son

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
item based script help...
« Reply #12 on: September 07, 2010, 04:02:19 am »


               that isse with the flint and campfire is more of a random thing... but the tent and the mount/dismount scripts are real issues...
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
item based script help...
« Reply #13 on: September 07, 2010, 04:02:55 am »


               Now lets go on to the second script you posted. This is the tent item. But first if you could explain exactly what you want to happen, when you use this item. Is it supposed to create the tent? Or start a conversation? Do you only want it to spawn at the player location or do you want to be able to select a location like the campfire? etc...
               
               

               


                     Modifié par GhostOfGod, 07 septembre 2010 - 03:03 .
                     
                  


            

Legacy_seventh_son

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
item based script help...
« Reply #14 on: September 07, 2010, 04:09:36 am »


               ok, bare with me here...lol. A player buys a rolled up tent, it is single use only... When he uses the rolled up tent, he picks a spot to pitch a tent. The tent appears allowing the player to rest. When the player is finished resting, he clicks on the tent opening a convo... in the convo the player can choose to pack up the tent or do nothing... if he picks to pack up tent, this script fires that destroys the tent he spawned in and gives another rolled up tent in the players inventory. the problem is that when the player choses to pack up the tent, the tent is destoyed and the rolled up tent is placed back in the players inventory but then another tent placeable spawns back in where the other one was.