Author Topic: random script firing  (Read 331 times)

Legacy_seventh_son

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
random script firing
« on: September 05, 2010, 05:06:30 am »


               I am using a campfire system that I created that when you use flint it creates a campfire that is restable, the campfire is a system off the vault but the flint is of my design. My problem is that when I buy a piece of flint it creates a campfire next to one of the other players in the mod... I think it may be the script I use to create a campfire when the flint is used, but I dont know. If anyone can help me I would appreciate it, I will post the scipt i use to create a campfire when the flint is used...

void main()
{
object oPC;

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

lTarget = GetItemActivatedTargetLocation();

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

}
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
random script firing
« Reply #1 on: September 05, 2010, 05:30:10 am »


               It's because of tag based scripting(The tag of the item being the same as the name of the script). The script is firing because with tag based scripting it fires for the OnAcquire event as well. And OnUnacquire, OnEquip/UnEquip, etc. So you have to put a check at the top of these scripts to make sure it only fires for the event you want it to fire for. In this case your script with the necessary changes would look like this:

#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);

}

Hope that helps.
               
               

               


                     Modifié par GhostOfGod, 05 septembre 2010 - 04:30 .
                     
                  


            

Legacy_seventh_son

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
random script firing
« Reply #2 on: September 05, 2010, 05:35:30 am »


               that is exactly what i was looking for. I had a similar problem a while ago, and had a fix for it, but lost the script.... this is great, Thanks for the help...