Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Something Wrong with AddUseItemCallback?
AGP Offline
Senior Member

Posts: 448
Threads: 45
Joined: Dec 2012
Reputation: 23
#3
RE: Something Wrong with AddUseItemCallback?

I spoke with Romulator earlier and he was able to fix it.

He said that it had to do with "for" in the if-statement, from what I understood. Basically, he overhauled a good chunk of it.

Here is what he gave me (in case anyone else ever needs this for future reference):

void OnStart()
{
for(int i = 1; i <= 4; i++)
    {
        AddUseItemCallback("ThisCrapNotWorking", "bucket_"+i, "RopeInteractArea_1", "UseBucketOnRope", false);
    }
for(int i = 1; i <= 4; i++)
    {
        AddUseItemCallback("TheKnifeWillFall", "knife_"+i, "RopeInteractArea_1", "UseBucketOnRope", false);
    }
}

void UseBucketOnRope(string &in asItem, string &in asEntity)
{
    if(StringContains(asItem, "bucket"))
    {
        if(GetLocalVarInt("RopeInArea") != 1)
        {
        SetMessage("", "", 0);
        AddDebugMessage("Rope outside of area, no interaction occurs.", false);
        return;
        }

        AddAttachedPropToProp("invisible_box_mass_2_1", "wooden_bucket_onrope_1", "wooden_bucket_onrope.ent", 0,0,0,0,0,0);
        RemoveItem(asItem);
    
        SetLocalVarInt("BucketOnRope", 1);
        
        AddDebugMessage(asItem, true);
        AddDebugMessage(asEntity, true);
    }
    else if(StringContains(asItem, "knife"))
    {
        AddDebugMessage("That's not a bucket, lol", false);
    }
}

It now works perfectly. Big shout out to Rom for this.

03-16-2018, 07:48 PM
Find


Messages In This Thread
Something Wrong with AddUseItemCallback? - by AGP - 03-16-2018, 07:59 AM
RE: Something Wrong with AddUseItemCallback? - by AGP - 03-16-2018, 07:48 PM



Users browsing this thread: 2 Guest(s)