//:://////////////////////////////////////////////
// Placeable events
//:://////////////////////////////////////////////
#include "placeable_h"
#include "utility_h"
#include "wrappers_h"
#include "events_h"
const string CAMPFIRE = "pro_campfire_lightable";
const int LIGHT_CAMPFIRE = 4007; //References the VFX_Base 2DA
void main()
{
event ev = GetCurrentEvent();
int nEvent = GetEventType(ev);
Log_Events("", ev);
int nEventHandled = FALSE; //keep track of whether the event has been handled
switch (nEvent)
{
//---------------------------------------------------------------------
// Sent by engine when creature clicks on the placeable.
//---------------------------------------------------------------------
case EVENT_TYPE_PLACEABLE_ONCLICK: // or EVENT_TYPE_APPLY_EFFECT
object oPlayer = GetHero();
object oCampfire = GetObjectByTag(CAMPFIRE);
object oFlint = GetItemPossessedBy (oPlayer, "pro_cft_camp_flint");
object [] oCampfireInvis = GetNearestObjectByTag(oPlayer, "phae_dacft_egwpn_plc", OBJECT_TYPE_PLACEABLE);
int iItemCount = CountItemsByTag(oPlayer, "pro_cft_camp_flint");
if (iItemCount == 0)
DisplayFloatyMessage(oPlayer, "You need flint in your inventory to light a fire.", FLOATY_MESSAGE, 16777215, 1.0);
if (iItemCount >= 1)
ApplyEffectOnObject (EFFECT_DURATION_TYPE_PERMANENT, EffectVisualEffect(LIGHT_CAMPFIRE),oCampfire);
SetItemStackSize( oFlint, GetItemStackSize( oFlint ) - 1);
[u][b]SetObjectInteractive(oCampfire, FALSE);[/b][/u]
WR_SetObjectActive(oCampfireInvis[0], TRUE);
nEventHandled = TRUE;
break;
}
if (!nEventHandled) //If this event wasn't handled by this script, let the core script try
{
HandleEvent(ev, RESOURCE_SCRIPT_PLACEABLE_CORE);
}
}The bold/underlined line in the above code fires regardless of the ItemCount. Everything else works just fine. Any ideas on why?
SetObjectInteractive FALSE firing regardless of condition
Débuté par
indio
, juin 26 2010 05:00
#1
Posté 26 juin 2010 - 05:00
#2
Posté 26 juin 2010 - 05:09
You need to have curly brackets around your statements in a conditional block if the block contains more than one statement. Or, in other words, the commands that need to be executed when iItemCount >= 1 should be enclosed in curly brackets. As it is now, only the first command (ApplyEffectOnObject) will be run when iItemCount >= 1
#3
Posté 26 juin 2010 - 05:20
Thanks. I, quite literally, could not do this without the help you, Mike, Phaenan and others give.
#4
Posté 26 juin 2010 - 05:20
Sure enough, it works





Retour en haut






