Aller au contenu

Photo

Script Not Working - PLEASE HELP ME


  • Veuillez vous connecter pour répondre
8 réponses à ce sujet

#1
shadow5973

shadow5973
  • Members
  • 48 messages
 I am trying to add a custom item set that I created to my inventory so that it will show up the next time that I load my game. However, the script isn't working. Could someone tell me why and what I need to do to fix it? 

Here is the script I am having problems with:

#include "utility_h"#include "wrappers_h"#include "events_h"
void checkItem(resource item, int iCount);
void main(){

    resource[] itemArray;    itemArray[0]    =  R"noble_helm.uti";    itemArray[1]    =  R"noble_massive_chest.uti";    itemArray[2]    =  R"noble_massive_gloves.uti";    itemArray[3]    =  R"noble_massive_boots.uti";    itemArray[4]    =  R"noble_shield.uti";    itemArray[5]    =  R"noble_sword.uti";       
    int true                =   1;    string scriptRan        =   "item_add_script_already_ran";
    switch (GetEventType(GetCurrentEvent())){
        case EVENT_TYPE_MODULE_LOAD:{
            int iter;            int itemsToAdd      =   1;            int iModuleLoaded   =   GetLocalInt(OBJECT_SELF, scriptRan);
            for(iter = 0; (iter < GetArraySize(itemArray)) && (iModuleLoaded != true); iter++){                checkItem(itemArray[iter],itemsToAdd);            }
            SetLocalInt(OBJECT_SELF, scriptRan, true);            break;        }        default:{            break;        }    }}
void checkItem(resource item, int iCount){
    int iItemCount  =   CountItemsByTag(GetHero(), ResourceToTag(item));    if(iItemCount == 0){        UT_AddItemToInventory(item, iCount);    }}

Modifié par shadow5973, 10 juin 2010 - 01:37 .


#2
TimelordDC

TimelordDC
  • Members
  • 923 messages
Would help if you formatted it better.

Have you tried putting PrintToLog statements to see if your script is even being called?

Modifié par TimelordDC, 10 juin 2010 - 02:41 .


#3
shadow5973

shadow5973
  • Members
  • 48 messages
Not even sure how to.

I reworked the script, so now I have this, but it still doesn't work correctly. Though the module does show up in the Installed DLC tab in game.

Script:

#include "utility_h"#include "plt_my_custom_plot"
void main(){    if ( WR_GetPlotFlag( PLT_MY_CUSTOM_PLOT, MY_ITEM_CHECK_FLAG        return;    event ev = GetCurrentEvent();    int nEventType = GetEventType(ev);    switch ( nEventType )    {        case EVENT_TYPE_MODULE_LOAD        {            UT_AddItemToInventory(R"black_demon_sword.uti", 1);            UT_AddItemToInventory(R"black_demon_shield.uti", 1);            WR_SetPlotFlag( PLT_MY_CUSTOM_PLOT, MY_ITEM_CHECK_FLAG, TRUE );            break;        }        default:            break;    }}

Modifié par shadow5973, 10 juin 2010 - 03:00 .


#4
_L_o_B_o_

_L_o_B_o_
  • Members
  • 117 messages
Oh, man... That hurts my eyes. Let's do it a little cleaner:wizard:

#include "utility_h"
#include "plt_my_custom_plot"

void main()
{        
     if (WR_GetPlotFlag( PLT_MY_CUSTOM_PLOT, MY_ITEM_CHECK_FLAG              
         return;       

         event ev = GetCurrentEvent();        
         int nEventType = GetEventType(ev);        
         switch ( nEventType )        
         {                
             case EVENT_TYPE_MODULE_LOAD              
             {                        
                 UT_AddItemToInventory(R"black_demon_sword.uti", 1);
                 UT_AddItemToInventory(R"black_demon_shield.uti", 1);                       
                 WR_SetPlotFlag( PLT_MY_CUSTOM_PLOT, MY_ITEM_CHECK_FLAG, TRUE );                        
                 break;                
             }                
             default:                        
                 break;        
         }
}


Does it compile without errors? Look at this line:

    if (WR_GetPlotFlag( PLT_MY_CUSTOM_PLOT, MY_ITEM_CHECK_FLAG     


There are some right brackets missing. 

Modifié par _L_o_B_o_, 10 juin 2010 - 07:16 .


#5
shadow5973

shadow5973
  • Members
  • 48 messages
ok. thanks. going to try it out.

#6
shadow5973

shadow5973
  • Members
  • 48 messages
still not working

#7
_L_o_B_o_

_L_o_B_o_
  • Members
  • 117 messages
First thing we need to know is if it compiled correctly this time. Did you get a "compile successful" message in the log window?

Let's guess it did. Then you should follow TimelordDC's advice. Write a PrintToLog statement at the beginning of your script to check that it is being executed.

For example...

void main()
{
PrintToLog("MY MODULE :: INI");
...
}


Take a look at the Error messages and logging entry in this article if you have never used before the PrintToLog function: http://social.biowar...ipting_overview

Modifié par _L_o_B_o_, 12 juin 2010 - 12:32 .


#8
shadow5973

shadow5973
  • Members
  • 48 messages
Found this tutorial. I followed it step by step... and... nothing happened...



Link to tutorial: http://social.biowar.../5339/blog/576/

#9
shadow5973

shadow5973
  • Members
  • 48 messages
I figured out thats its much easier to add the items to a near by chest than to try to write a script to spawn them directly into the player inventory... I should have thought of that sooner.