Author Topic: compiling script error!! SOS!  (Read 491 times)

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
compiling script error!! SOS!
« on: August 18, 2010, 03:04:05 pm »


               I am having an issue with compiling the following script into the activation script

/////////////////////////////////////////////////////////////////////

if (GetIsObjectValid(oWyrmling))
{
AddHenchman(oPc, oWyrmling);
}/* end then (valid owyrmling) */
else
{
AssignCommand(oPc, ActionSpeakString("Invalid Nightmare"));
}/* end else (valid owyrmling) */
return;
}
///////////////////////////////////////////////////////////////////////////////
// Summon Nightmare Saddled
///////////////////////////////////////////////////////////////////////////////
else if (sItemTag == "Horse_17")
{
object oPc = GetItemActivator();
location lPc = GetLocation(oPc);
location lWyrmling = GetItemActivatedTargetLocation();
object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, "dla_nightmare003", lPc, TRUE);

/////////////////////////////////////// name the horse //////////////
SetName (oWyrmling, GetName(GetItemActivator()) + "'s " + " Nightmare");
/////////////////////////////////////////////////////////////////////

if (GetIsObjectValid(oWyrmling))
{
AddHenchman(oPc, oWyrmling);
}/* end then (valid owyrmling) */
else
{
AssignCommand(oPc, ActionSpeakString("Invalid Nightmare"));
}/* end else (valid owyrmling) */
return;
}
///////////////////////////////////////////////////////////////////////////////
// Summon Dark Unicorn
///////////////////////////////////////////////////////////////////////////////
else if (sItemTag == "Horse_18")
{
object oPc = GetItemActivator();
location lPc = GetLocation(oPc);
location lWyrmling = GetItemActivatedTargetLocation();
object oWyrmling = CreateObject(OBJECT_TYPE_CREATURE, "cep_unicorn001", lPc, TRUE);

/////////////////////////////////////// name the horse //////////////
SetName (oWyrmling, GetName(GetItemActivator()) + "'s " + " Unicorn");
/////////////////////////////////////////////////////////////////////

if (GetIsObjectValid(oWyrmling))
{
AddHenchman(oPc, oWyrmling);
}/* end then (valid owyrmling) */
else
{
AssignCommand(oPc, ActionSpeakString("Invalid Unicorn"));
}/* end else (valid owyrmling) */
return;
}
/////////////////////END DLA HORSE WIDGETS////////////////////
//X2 Tag based system code

//ExecuteScript(sItemTag, OBJECT_SELF);

//object oItem = GetItemActivated();

// * Generic Item Script Execution Code
// * If MODULE_SWITCH_EXECUTE_TAGBASED_SCRIPTS is set to TRUE on the module,
// * it will execute a script that has the same name as the item's tag
// * inside this script you can manage scripts for all events by checking against
// * GetUserDefinedItemEventNumber(). See x2_it_example.nss
if (GetModuleSwitchValue(MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS) == TRUE)
{
SetUserDefinedItemEventNumber(X2_ITEM_EVENT_ACTIVATE);
int nRet = ExecuteScriptAndReturnInt(GetUserDefinedItemEventScriptName(oItem),OBJECT_SELF);
if (nRet == X2_EXECUTE_SCRIPT_END)
{
return;
}
}
}

and this is the one I also want in it.

/*
ts_on_activate
by Tseramed, aka Ken Demarest
© 2003 - Free to use. Must give author credit.

To make fishing work, add the testFishingBait() to your own
module OnActivate() script
*/
void testModuleReloader( object item ) {
if( GetTag( item ) == "ModuleReloader" )
StartNewModule( GetModuleName() );
}

void testFishingBait( object item ) {
if( GetTag( item ) == "TsFishingBait" ) {
ExecuteScript( "ts_fishing", item );
}
}


void main()
{
object item = GetItemActivated();

testModuleReloader( item );
testFishingBait( item );
}

hope that you can help me....
               
               

               
            

Legacy_Genisys

  • Hero Member
  • *****
  • Posts: 961
  • Karma: +0/-0
compiling script error!! SOS!
« Reply #1 on: August 18, 2010, 05:08:45 pm »


               Um, what is the message error exactly?  And how are you GETTING said henchmen by scripting?



Are you summoning him then using a delay to find the summon?



Can you just tell me plainly what your wanting, and I can write the script (in minutes)?
               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
compiling script error!! SOS!
« Reply #2 on: August 18, 2010, 06:41:09 pm »


               no I need to add the lower part into the script above it but it doesnt work
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
compiling script error!! SOS!
« Reply #3 on: August 18, 2010, 09:14:33 pm »


               EDIT: Keep you OnActivateScript the way it was. Before any attempted changes.

Try this and see what happens. Rename the TAG of the item you are trying to activate, to "ts_fishing". That script is from 2003 and I believe that was before tag based scripting was implemented. You will also need to add a check and an include at the top of the "ts_fishing" script, like so:

#include "x2_inc_switches" <---add this just above the "ts_fishing"  void main
void main()
{

int nEvent =GetUserDefinedItemEventNumber(); <---
if(nEvent !=  X2_ITEM_EVENT_ACTIVATE)return;  <---------add these just under the "ts_fishing" void main


Hope that helps. Good luck.
               
               

               


                     Modifié par GhostOfGod, 18 août 2010 - 09:24 .
                     
                  


            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
compiling script error!! SOS!
« Reply #4 on: August 19, 2010, 04:53:13 am »


               ? so if I add #include "x2_inc_switches" <- in the onactivationscript and in the fishing script so the script would actually work for the module?
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
compiling script error!! SOS!
« Reply #5 on: August 19, 2010, 05:16:10 am »


               Assuming you have tag based scripting turned on as it is by default. Then you don't do anything at all with your OnActivateItem script. Just leave it the way it was. What you do want to do is make the changes noted above to your "ts_fishing" script. And then make sure to change the tag of the item you are using to activate this fishing script to "ts_fishing".

One of the problems with some older systems is that they predate the tag based scripting system so they always want to gunk up your OnActivateItem script.

However since tag based scripting was implemented, what happens when you use/activate(via the spell "unique power"), pick up, drop, equip/unequip an item , it automatically runs the script that has the same name as the tag of the item you just used. So you don't need to put any extra lines in your OnActivateItem script. But you do still need to add that check, that I posted above, into the fishing script so that it knows that it needs to fire because someone ACTIVATED and item. Otherwise it will fire everytime someone picks up, drops, etc.. the fishing item as well.

Hope that makes sense. IMO It's just better not to have to mess around with your module scripts if you don't have to.

EDIT: However if you want to do it the old fashioned way then you would add something like:

if( GetTag( oItem ) == "TsFishingBait" )  ExecuteScript( "ts_fishing", oItem );

just above the very last ending curly bracket of your OnActivateItem script "}". '<img'>
               
               

               


                     Modifié par GhostOfGod, 19 août 2010 - 04:29 .
                     
                  


            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
compiling script error!! SOS!
« Reply #6 on: August 19, 2010, 05:24:20 am »


               ahhh okay, thanks for the information.

so basically I need to change the tag name of the items and then put that line above the fishing script, okay awesome

               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
compiling script error!! SOS!
« Reply #7 on: August 19, 2010, 05:30:18 am »


               Add the 3 lines to your fishing script. But yes.

I also edited the end of what i last posted. You can try that too. probably easier on ya.

Anyway I hope it helps. Good luck.
               
               

               


                     Modifié par GhostOfGod, 19 août 2010 - 04:31 .